Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,90 +0,0 @@
1
-<?php
2
-
3
-/*
4
- * This file is part of the Symfony package.
5
- *
6
- * (c) Fabien Potencier <fabien@symfony.com>
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
-namespace Symfony\Component\Translation\Writer;
13
-
14
-use Symfony\Component\Translation\Dumper\DumperInterface;
15
-use Symfony\Component\Translation\Exception\InvalidArgumentException;
16
-use Symfony\Component\Translation\Exception\RuntimeException;
17
-use Symfony\Component\Translation\MessageCatalogue;
18
-
19
-/**
20
- * TranslationWriter writes translation messages.
21
- *
22
- * @author Michel Salib <michelsalib@hotmail.com>
23
- */
24
-class TranslationWriter implements TranslationWriterInterface
25
-{
26
-    private $dumpers = [];
27
-
28
-    /**
29
-     * Adds a dumper to the writer.
30
-     *
31
-     * @param string          $format The format of the dumper
32
-     * @param DumperInterface $dumper The dumper
33
-     */
34
-    public function addDumper($format, DumperInterface $dumper)
35
-    {
36
-        $this->dumpers[$format] = $dumper;
37
-    }
38
-
39
-    /**
40
-     * Disables dumper backup.
41
-     *
42
-     * @deprecated since Symfony 4.1
43
-     */
44
-    public function disableBackup()
45
-    {
46
-        @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED);
47
-
48
-        foreach ($this->dumpers as $dumper) {
49
-            if (method_exists($dumper, 'setBackup')) {
50
-                $dumper->setBackup(false);
51
-            }
52
-        }
53
-    }
54
-
55
-    /**
56
-     * Obtains the list of supported formats.
57
-     *
58
-     * @return array
59
-     */
60
-    public function getFormats()
61
-    {
62
-        return array_keys($this->dumpers);
63
-    }
64
-
65
-    /**
66
-     * Writes translation from the catalogue according to the selected format.
67
-     *
68
-     * @param MessageCatalogue $catalogue The message catalogue to write
69
-     * @param string           $format    The format to use to dump the messages
70
-     * @param array            $options   Options that are passed to the dumper
71
-     *
72
-     * @throws InvalidArgumentException
73
-     */
74
-    public function write(MessageCatalogue $catalogue, $format, $options = [])
75
-    {
76
-        if (!isset($this->dumpers[$format])) {
77
-            throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
78
-        }
79
-
80
-        // get the right dumper
81
-        $dumper = $this->dumpers[$format];
82
-
83
-        if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
84
-            throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
85
-        }
86
-
87
-        // save
88
-        $dumper->dump($catalogue, $options);
89
-    }
90
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,90 @@
1
+<?php
2
+
3
+/*
4
+ * This file is part of the Symfony package.
5
+ *
6
+ * (c) Fabien Potencier <fabien@symfony.com>
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+namespace Symfony\Component\Translation\Writer;
13
+
14
+use Symfony\Component\Translation\Dumper\DumperInterface;
15
+use Symfony\Component\Translation\Exception\InvalidArgumentException;
16
+use Symfony\Component\Translation\Exception\RuntimeException;
17
+use Symfony\Component\Translation\MessageCatalogue;
18
+
19
+/**
20
+ * TranslationWriter writes translation messages.
21
+ *
22
+ * @author Michel Salib <michelsalib@hotmail.com>
23
+ */
24
+class TranslationWriter implements TranslationWriterInterface
25
+{
26
+    private $dumpers = [];
27
+
28
+    /**
29
+     * Adds a dumper to the writer.
30
+     *
31
+     * @param string          $format The format of the dumper
32
+     * @param DumperInterface $dumper The dumper
33
+     */
34
+    public function addDumper($format, DumperInterface $dumper)
35
+    {
36
+        $this->dumpers[$format] = $dumper;
37
+    }
38
+
39
+    /**
40
+     * Disables dumper backup.
41
+     *
42
+     * @deprecated since Symfony 4.1
43
+     */
44
+    public function disableBackup()
45
+    {
46
+        @trigger_error(sprintf('The "%s()" method is deprecated since Symfony 4.1.', __METHOD__), E_USER_DEPRECATED);
47
+
48
+        foreach ($this->dumpers as $dumper) {
49
+            if (method_exists($dumper, 'setBackup')) {
50
+                $dumper->setBackup(false);
51
+            }
52
+        }
53
+    }
54
+
55
+    /**
56
+     * Obtains the list of supported formats.
57
+     *
58
+     * @return array
59
+     */
60
+    public function getFormats()
61
+    {
62
+        return array_keys($this->dumpers);
63
+    }
64
+
65
+    /**
66
+     * Writes translation from the catalogue according to the selected format.
67
+     *
68
+     * @param MessageCatalogue $catalogue The message catalogue to write
69
+     * @param string           $format    The format to use to dump the messages
70
+     * @param array            $options   Options that are passed to the dumper
71
+     *
72
+     * @throws InvalidArgumentException
73
+     */
74
+    public function write(MessageCatalogue $catalogue, $format, $options = [])
75
+    {
76
+        if (!isset($this->dumpers[$format])) {
77
+            throw new InvalidArgumentException(sprintf('There is no dumper associated with format "%s".', $format));
78
+        }
79
+
80
+        // get the right dumper
81
+        $dumper = $this->dumpers[$format];
82
+
83
+        if (isset($options['path']) && !is_dir($options['path']) && !@mkdir($options['path'], 0777, true) && !is_dir($options['path'])) {
84
+            throw new RuntimeException(sprintf('Translation Writer was not able to create directory "%s"', $options['path']));
85
+        }
86
+
87
+        // save
88
+        $dumper->dump($catalogue, $options);
89
+    }
90
+}