SymfonyComponentTranslationCatalogueTargetOperation

Target operation between two catalogues: intersection = source * target = {x: x * source * x * target} all = intersection * (target * intersection) = target new = all * source = {x: x * target * x * source} obsolete = source * all = source * target = {x: x * source * x * target} Basically, the result contains messages from the target catalogue.

Defined (1)

The class is defined in the following location(s).

/vendor/symfony/translation/Catalogue/TargetOperation.php  
  1. class TargetOperation extends AbstractOperation 
  2. /** 
  3. * {@inheritdoc} 
  4. */ 
  5. protected function processDomain($domain) 
  6. $this->messages[$domain] = array( 
  7. 'all' => array(),  
  8. 'new' => array(),  
  9. 'obsolete' => array(),  
  10. ); 
  11.  
  12. // For 'all' messages, the code can't be simplified as ``$this->messages[$domain]['all'] = $target->all($domain);``,  
  13. // because doing so will drop messages like {x: x * source * x * target.all * x * target.fallback} 
  14. // 
  15. // For 'new' messages, the code can't be simplied as ``array_diff_assoc($this->target->all($domain), $this->source->all($domain));`` 
  16. // because doing so will not exclude messages like {x: x * target * x * source.all * x * source.fallback} 
  17. // 
  18. // For 'obsolete' messages, the code can't be simplifed as ``array_diff_assoc($this->source->all($domain), $this->target->all($domain))`` 
  19. // because doing so will not exclude messages like {x: x * source * x * target.all * x * target.fallback} 
  20.  
  21. foreach ($this->source->all($domain) as $id => $message) { 
  22. if ($this->target->has($id, $domain)) { 
  23. $this->messages[$domain]['all'][$id] = $message; 
  24. $this->result->add(array($id => $message), $domain); 
  25. if (null !== $keyMetadata = $this->source->getMetadata($id, $domain)) { 
  26. $this->result->setMetadata($id, $keyMetadata, $domain); 
  27. } else { 
  28. $this->messages[$domain]['obsolete'][$id] = $message; 
  29.  
  30. foreach ($this->target->all($domain) as $id => $message) { 
  31. if (!$this->source->has($id, $domain)) { 
  32. $this->messages[$domain]['all'][$id] = $message; 
  33. $this->messages[$domain]['new'][$id] = $message; 
  34. $this->result->add(array($id => $message), $domain); 
  35. if (null !== $keyMetadata = $this->target->getMetadata($id, $domain)) { 
  36. $this->result->setMetadata($id, $keyMetadata, $domain);