setConditionGroup() 공개 메소드

Set conditionGroup.
public setConditionGroup ( ConditionGroup $conditionGroup ) : Condition
$conditionGroup ConditionGroup
리턴 Condition
예제 #1
0
 /**
  * Adds a condition group to the given filter.
  *
  * @param Filter $filter The filter to add the condition group to
  * @param array $conditionGroupData The array containing the data for the additional condition group
  *
  * @return bool
  *
  * @throws EntityIdAlreadySetException
  * @throws FilterDependencyNotFoundException
  */
 protected function addConditionGroup(Filter $filter, $conditionGroupData)
 {
     if (array_key_exists('id', $conditionGroupData)) {
         throw new EntityIdAlreadySetException(self::$conditionGroupEntityName, $conditionGroupData['id']);
     } elseif (array_key_exists('conditions', $conditionGroupData)) {
         $conditionGroup = new ConditionGroupEntity();
         $conditionGroup->setFilter($filter->getEntity());
         foreach ($conditionGroupData['conditions'] as $conditionData) {
             if (array_key_exists('id', $conditionData)) {
                 throw new EntityIdAlreadySetException(self::$conditionEntityName, $conditionData['id']);
             } elseif ($this->isValidConditionData($conditionData)) {
                 $condition = new ConditionEntity();
                 $condition->setType($conditionData['type']);
                 $value = $this->getValueForCondition($conditionData['value'], $conditionData['type']);
                 $condition->setValue($value);
                 $condition->setOperator($conditionData['operator']);
                 $condition->setField($conditionData['field']);
                 $condition->setConditionGroup($conditionGroup);
                 $conditionGroup->addCondition($condition);
                 $conditionGroup->setFilter($filter->getEntity());
                 $this->em->persist($condition);
             }
         }
         $filter->getEntity()->addConditionGroup($conditionGroup);
         $this->em->persist($conditionGroup);
     }
     return true;
 }
예제 #2
0
 protected function createCondition($conditionGroup, $type, $value, $operator, $name)
 {
     $condition = new Condition();
     $condition->setType($type);
     $condition->setValue($value);
     $condition->setOperator($operator);
     $condition->setField($name);
     $condition->setConditionGroup($conditionGroup);
     $this->em->persist($condition);
     return $condition;
 }