/** * Process translations of an operator. * * @param ObjectManager $manager * @param Operator $operator * @param \DOMNodeList $translations */ protected function processTranslations($manager, $operator, $translations) { /** @var $node DOMNode */ foreach ($translations as $node) { $translation = new OperatorTranslation(); $translation->setLocale($node->getAttribute('locale')); $translation->setName($node->nodeValue); $translation->setOperator($operator); $operator->addTranslation($translation); $manager->persist($translation); } }
/** * Get translation by locale. * * @return OperatorTranslation */ private function getTranslation() { $operatorTranslation = null; foreach ($this->entity->getTranslations() as $translation) { if ($translation->getLocale() == $this->locale) { $operatorTranslation = $translation; } } if (!$operatorTranslation) { $operatorTranslation = new OperatorTranslation(); $operatorTranslation->setLocale($this->locale); $operatorTranslation->setOperator($this->entity); $this->entity->addTranslation($operatorTranslation); } return $operatorTranslation; }
protected function createSimpleOperator($type, $inputType, $operatorValue, $name, $locale = 'de') { $operator = new Operator(); $operator->setType($type); $operator->setInputType($inputType); $operator->setOperator($operatorValue); $translation = new OperatorTranslation(); $translation->setLocale($locale); $translation->setName($name); $translation->setOperator($operator); $this->em->persist($operator); $this->em->persist($translation); return $operator; }