protected function createFilter($name, $conjunction, $context, $private, $user = null) { $filter = new Filter(); $filter->setConjunction($conjunction); $filter->setContext($context); $filter->setChanged(new \DateTime()); $filter->setCreated(new \DateTime()); $filter->setPrivate($private); $filter->setUser($user); $filter->setCreator($this->getTestUser()); $filter->setChanger($this->getTestUser()); $trans = new FilterTranslation(); $trans->setLocale('de'); $trans->setName($name); $trans->setFilter($filter); $filter->addTranslation($trans); $conditionGroup1 = new ConditionGroup(); $conditionGroup1->setFilter($filter); $conditionGroup1->addCondition($this->createCondition($conditionGroup1, DataTypes::STRING_TYPE, 'test', 'LIKE', 'name')); $conditionGroup2 = new ConditionGroup(); $conditionGroup2->setFilter($filter); $conditionGroup2->addCondition($this->createCondition($conditionGroup2, DataTypes::NUMBER_TYPE, '2', '=', 'id')); $conditionGroup3 = new ConditionGroup(); $conditionGroup3->setFilter($filter); $conditionGroup3->addCondition($this->createCondition($conditionGroup3, DataTypes::DATETIME_TYPE, '2015-01-01', '>', 'created')); $conditionGroup3->addCondition($this->createCondition($conditionGroup3, DataTypes::DATETIME_TYPE, '2015-02-02', '<', 'created')); $filter->addConditionGroup($conditionGroup1); $filter->addConditionGroup($conditionGroup2); $filter->addConditionGroup($conditionGroup3); $this->em->persist($filter); $this->em->persist($trans); $this->em->persist($conditionGroup1); $this->em->persist($conditionGroup2); $this->em->persist($conditionGroup3); return $filter; }
/** * Get translation by locale. * * @return FilterTranslation */ private function getTranslation() { $filterTranslation = null; foreach ($this->entity->getTranslations() as $translation) { if ($translation->getLocale() == $this->locale) { $filterTranslation = $translation; } } if (!$filterTranslation) { $filterTranslation = new FilterTranslation(); $filterTranslation->setLocale($this->locale); $filterTranslation->setFilter($this->entity); $this->entity->addTranslation($filterTranslation); } return $filterTranslation; }