composer package updates
[openemr.git] / vendor / symfony / translation / Catalogue / MergeOperation.php
blob6db3f801f3b2b19a804a0246e52336517d674d59
1 <?php
3 /*
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Catalogue;
14 /**
15 * Merge operation between two catalogues as follows:
16 * all = source ∪ target = {x: x ∈ source ∨ x ∈ target}
17 * new = all ∖ source = {x: x ∈ target ∧ x ∉ source}
18 * obsolete = source ∖ all = {x: x ∈ source ∧ x ∉ source ∧ x ∉ target} = ∅
19 * Basically, the result contains messages from both catalogues.
21 * @author Jean-François Simon <contact@jfsimon.fr>
23 class MergeOperation extends AbstractOperation
25 /**
26 * {@inheritdoc}
28 protected function processDomain($domain)
30 $this->messages[$domain] = array(
31 'all' => array(),
32 'new' => array(),
33 'obsolete' => array(),
36 foreach ($this->source->all($domain) as $id => $message) {
37 $this->messages[$domain]['all'][$id] = $message;
38 $this->result->add(array($id => $message), $domain);
39 if (null !== $keyMetadata = $this->source->getMetadata($id, $domain)) {
40 $this->result->setMetadata($id, $keyMetadata, $domain);
44 foreach ($this->target->all($domain) as $id => $message) {
45 if (!$this->source->has($id, $domain)) {
46 $this->messages[$domain]['all'][$id] = $message;
47 $this->messages[$domain]['new'][$id] = $message;
48 $this->result->add(array($id => $message), $domain);
49 if (null !== $keyMetadata = $this->target->getMetadata($id, $domain)) {
50 $this->result->setMetadata($id, $keyMetadata, $domain);