aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Catalogue
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Catalogue')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Catalogue/AbstractOperation.php146
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Catalogue/DiffOperation.php49
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Catalogue/MergeOperation.php45
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Catalogue/OperationInterface.php63
4 files changed, 0 insertions, 303 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/AbstractOperation.php b/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/AbstractOperation.php
deleted file mode 100644
index 062056b7..00000000
--- a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/AbstractOperation.php
+++ /dev/null
@@ -1,146 +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
12namespace Symfony\Component\Translation\Catalogue;
13
14use Symfony\Component\Translation\MessageCatalogue;
15use Symfony\Component\Translation\MessageCatalogueInterface;
16
17/**
18 * Base catalogues binary operation class.
19 *
20 * @author Jean-François Simon <contact@jfsimon.fr>
21 */
22abstract class AbstractOperation implements OperationInterface
23{
24 /**
25 * @var MessageCatalogueInterface
26 */
27 protected $source;
28
29 /**
30 * @var MessageCatalogueInterface
31 */
32 protected $target;
33
34 /**
35 * @var MessageCatalogue
36 */
37 protected $result;
38
39 /**
40 * @var null|array
41 */
42 private $domains;
43
44 /**
45 * @var array
46 */
47 protected $messages;
48
49 /**
50 * @param MessageCatalogueInterface $source
51 * @param MessageCatalogueInterface $target
52 *
53 * @throws \LogicException
54 */
55 public function __construct(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
56 {
57 if ($source->getLocale() !== $target->getLocale()) {
58 throw new \LogicException('Operated catalogues must belong to the same locale.');
59 }
60
61 $this->source = $source;
62 $this->target = $target;
63 $this->result = new MessageCatalogue($source->getLocale());
64 $this->domains = null;
65 $this->messages = array();
66 }
67
68 /**
69 * {@inheritdoc}
70 */
71 public function getDomains()
72 {
73 if (null === $this->domains) {
74 $this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains())));
75 }
76
77 return $this->domains;
78 }
79
80 /**
81 * {@inheritdoc}
82 */
83 public function getMessages($domain)
84 {
85 if (!in_array($domain, $this->getDomains())) {
86 throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
87 }
88
89 if (!isset($this->messages[$domain]['all'])) {
90 $this->processDomain($domain);
91 }
92
93 return $this->messages[$domain]['all'];
94 }
95
96 /**
97 * {@inheritdoc}
98 */
99 public function getNewMessages($domain)
100 {
101 if (!in_array($domain, $this->getDomains())) {
102 throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
103 }
104
105 if (!isset($this->messages[$domain]['new'])) {
106 $this->processDomain($domain);
107 }
108
109 return $this->messages[$domain]['new'];
110 }
111
112 /**
113 * {@inheritdoc}
114 */
115 public function getObsoleteMessages($domain)
116 {
117 if (!in_array($domain, $this->getDomains())) {
118 throw new \InvalidArgumentException(sprintf('Invalid domain: %s.', $domain));
119 }
120
121 if (!isset($this->messages[$domain]['obsolete'])) {
122 $this->processDomain($domain);
123 }
124
125 return $this->messages[$domain]['obsolete'];
126 }
127
128 /**
129 * {@inheritdoc}
130 */
131 public function getResult()
132 {
133 foreach ($this->getDomains() as $domain) {
134 if (!isset($this->messages[$domain])) {
135 $this->processDomain($domain);
136 }
137 }
138
139 return $this->result;
140 }
141
142 /**
143 * @param string $domain
144 */
145 abstract protected function processDomain($domain);
146}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/DiffOperation.php b/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/DiffOperation.php
deleted file mode 100644
index 1672d121..00000000
--- a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/DiffOperation.php
+++ /dev/null
@@ -1,49 +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
12namespace Symfony\Component\Translation\Catalogue;
13
14/**
15 * Diff operation between two catalogues.
16 *
17 * @author Jean-François Simon <contact@jfsimon.fr>
18 */
19class DiffOperation extends AbstractOperation
20{
21 /**
22 * {@inheritdoc}
23 */
24 protected function processDomain($domain)
25 {
26 $this->messages[$domain] = array(
27 'all' => array(),
28 'new' => array(),
29 'obsolete' => array(),
30 );
31
32 foreach ($this->source->all($domain) as $id => $message) {
33 if ($this->target->has($id, $domain)) {
34 $this->messages[$domain]['all'][$id] = $message;
35 $this->result->add(array($id => $message), $domain);
36 } else {
37 $this->messages[$domain]['obsolete'][$id] = $message;
38 }
39 }
40
41 foreach ($this->target->all($domain) as $id => $message) {
42 if (!$this->source->has($id, $domain)) {
43 $this->messages[$domain]['all'][$id] = $message;
44 $this->messages[$domain]['new'][$id] = $message;
45 $this->result->add(array($id => $message), $domain);
46 }
47 }
48 }
49}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/MergeOperation.php b/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/MergeOperation.php
deleted file mode 100644
index 0052363e..00000000
--- a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/MergeOperation.php
+++ /dev/null
@@ -1,45 +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
12namespace Symfony\Component\Translation\Catalogue;
13
14/**
15 * Merge operation between two catalogues.
16 *
17 * @author Jean-François Simon <contact@jfsimon.fr>
18 */
19class MergeOperation extends AbstractOperation
20{
21 /**
22 * {@inheritdoc}
23 */
24 protected function processDomain($domain)
25 {
26 $this->messages[$domain] = array(
27 'all' => array(),
28 'new' => array(),
29 'obsolete' => array(),
30 );
31
32 foreach ($this->source->all($domain) as $id => $message) {
33 $this->messages[$domain]['all'][$id] = $message;
34 $this->result->add(array($id => $message), $domain);
35 }
36
37 foreach ($this->target->all($domain) as $id => $message) {
38 if (!$this->source->has($id, $domain)) {
39 $this->messages[$domain]['all'][$id] = $message;
40 $this->messages[$domain]['new'][$id] = $message;
41 $this->result->add(array($id => $message), $domain);
42 }
43 }
44 }
45}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/OperationInterface.php b/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/OperationInterface.php
deleted file mode 100644
index d72378a3..00000000
--- a/vendor/symfony/translation/Symfony/Component/Translation/Catalogue/OperationInterface.php
+++ /dev/null
@@ -1,63 +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
12namespace Symfony\Component\Translation\Catalogue;
13
14use Symfony\Component\Translation\MessageCatalogueInterface;
15
16/**
17 * Represents an operation on catalogue(s).
18 *
19 * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
20 */
21interface OperationInterface
22{
23 /**
24 * Returns domains affected by operation.
25 *
26 * @return array
27 */
28 public function getDomains();
29
30 /**
31 * Returns all valid messages after operation.
32 *
33 * @param string $domain
34 *
35 * @return array
36 */
37 public function getMessages($domain);
38
39 /**
40 * Returns new messages after operation.
41 *
42 * @param string $domain
43 *
44 * @return array
45 */
46 public function getNewMessages($domain);
47
48 /**
49 * Returns obsolete messages after operation.
50 *
51 * @param string $domain
52 *
53 * @return array
54 */
55 public function getObsoleteMessages($domain);
56
57 /**
58 * Returns resulting catalogue.
59 *
60 * @return MessageCatalogueInterface
61 */
62 public function getResult();
63}