Esempio n. 1
0
 protected function createOperator($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);
     $operatorValue = new OperatorValue();
     $operatorValue->setOperator($operator);
     $operatorValue->setValue('value');
     $operatorValueTrans = new OperatorValueTranslation();
     $operatorValueTrans->setLocale($locale);
     $operatorValueTrans->setName('letzte Woche');
     $operatorValueTrans->setOperatorValue($operatorValue);
     $operatorValue1 = new OperatorValue();
     $operatorValue1->setOperator($operator);
     $operatorValue1->setValue('value1');
     $operatorValueTrans1 = new OperatorValueTranslation();
     $operatorValueTrans1->setLocale($locale);
     $operatorValueTrans1->setName('letzte Woche');
     $operatorValueTrans1->setOperatorValue($operatorValue1);
     $operatorValue2 = new OperatorValue();
     $operatorValue2->setOperator($operator);
     $operatorValue2->setValue('value2');
     $operatorValueTrans2 = new OperatorValueTranslation();
     $operatorValueTrans2->setLocale($locale);
     $operatorValueTrans2->setName('letzte Woche');
     $operatorValueTrans2->setOperatorValue($operatorValue2);
     $this->em->persist($operator);
     $this->em->persist($translation);
     $this->em->persist($operatorValue);
     $this->em->persist($operatorValueTrans);
     $this->em->persist($operatorValue1);
     $this->em->persist($operatorValueTrans1);
     $this->em->persist($operatorValue2);
     $this->em->persist($operatorValueTrans2);
     return $operator;
 }
Esempio n. 2
0
 /**
  * Process translations of an operator.
  *
  * @param ObjectManager $manager
  * @param $xpath \DOMXpath
  * @param Operator $operator
  * @param $values \DOMNodeList
  */
 protected function processValues($manager, $xpath, $operator, $values)
 {
     /** @var $node DOMNode */
     foreach ($values as $node) {
         $value = new OperatorValue();
         $value->setValue($node->getAttribute('value'));
         $translations = $xpath->query('translations/translation', $node);
         /** @var $trans DOMNode */
         foreach ($translations as $trans) {
             $translation = new OperatorValueTranslation();
             $translation->setLocale($trans->getAttribute('locale'));
             $translation->setName($trans->nodeValue);
             $translation->setOperatorValue($value);
             $value->addTranslation($translation);
             $manager->persist($translation);
         }
         $value->setOperator($operator);
         $operator->addValue($value);
         $manager->persist($value);
     }
 }