src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php
protected function updateConditionGroup(ConditionGroupEntity $conditionGroup, $matchedEntry)
    {
        if (array_key_exists('id', $matchedEntry) && isset($matchedEntry['conditions'])) {
            $conditionIds = [];
            foreach ($matchedEntry['conditions'] as $conditionData) {
                if (array_key_exists('id', $conditionData)) {
                    /** @var ConditionEntity $conditionEntity */
                    $conditionEntity = $this->conditionRepository->findById($conditionData['id']);

                    // check if condition exists at all
                    if (!$conditionEntity) {
                        throw new FilterDependencyNotFoundException(
                            self::$conditionEntityName,
                            $conditionData['id']
                        );
                    }

                    // check if conditions is related with condition group
                    if ($conditionEntity->getConditionGroup()->getId() !== $conditionGroup->getId()) {
                        throw new ConditionGroupMismatchException(
                            $matchedEntry['id']
                        );
                    }

                    $conditionIds[] = $conditionEntity->getId();
                } else {
                    $conditionEntity = new ConditionEntity();
                    $conditionEntity->setConditionGroup($conditionGroup);
                    $conditionGroup->addCondition($conditionEntity);
                    $this->em->persist($conditionEntity);
                    $conditionIds[] = $conditionEntity->getId();
                }

                $conditionEntity->setField($this->getProperty($conditionData, 'field', $conditionEntity->getField()));
                $conditionEntity->setOperator(
                    $this->getProperty($conditionData, 'operator', $conditionEntity->getOperator())
                );

                $conditionEntity->setType($this->getProperty($conditionData, 'type', $conditionEntity->getType()));
                $value = $this->getValueForCondition(
                    $this->getProperty($conditionData, 'value', $conditionEntity->getValue()),
                    $conditionEntity->getType()
                );
                $conditionEntity->setValue($value);
            }

            $this->removeNonExistentConditions($conditionGroup, $conditionIds);
        }

        return true;
    }
protected function updateConditionGroup(ConditionGroupEntity $conditionGroup, $matchedEntry)
    {
        if (array_key_exists('id', $matchedEntry) && isset($matchedEntry['conditions'])) {
            $conditionIds = [];
            foreach ($matchedEntry['conditions'] as $conditionData) {
                if (array_key_exists('id', $conditionData)) {
                    /** @var ConditionEntity $conditionEntity */
                    $conditionEntity = $this->conditionRepository->findById($conditionData['id']);

                    // check if condition exists at all
                    if (!$conditionEntity) {
                        throw new FilterDependencyNotFoundException(
                            self::$conditionEntityName,
                            $conditionData['id']
                        );
                    }

                    // check if conditions is related with condition group
                    if ($conditionEntity->getConditionGroup()->getId() !== $conditionGroup->getId()) {
                        throw new ConditionGroupMismatchException(
                            $matchedEntry['id']
                        );
                    }

                    $conditionIds[] = $conditionEntity->getId();
                } else {
                    $conditionEntity = new ConditionEntity();
                    $conditionEntity->setConditionGroup($conditionGroup);
                    $conditionGroup->addCondition($conditionEntity);
                    $this->em->persist($conditionEntity);
                    $conditionIds[] = $conditionEntity->getId();
                }

                $conditionEntity->setField($this->getProperty($conditionData, 'field', $conditionEntity->getField()));
                $conditionEntity->setOperator(
                    $this->getProperty($conditionData, 'operator', $conditionEntity->getOperator())
                );

                $conditionEntity->setType($this->getProperty($conditionData, 'type', $conditionEntity->getType()));
                $value = $this->getValueForCondition(
                    $this->getProperty($conditionData, 'value', $conditionEntity->getValue()),
                    $conditionEntity->getType()
                );
                $conditionEntity->setValue($value);
            }

            $this->removeNonExistentConditions($conditionGroup, $conditionIds);
        }

        return true;
    }
protected function updateConditionGroup ( ConditionGroupEntity $ conditionGroup , $ matchedEntry ) { if ( array_key_exists ( 'id' , $ matchedEntry ) && isset ( $ matchedEntry [ 'conditions' ] ) ) { $ conditionIds = [ ] ; foreach ( $ matchedEntry [ 'conditions' ] as $ conditionData ) { if ( array_key_exists ( 'id' , $ conditionData ) ) { /** @var ConditionEntity $conditionEntity */ $ conditionEntity = $ this -> conditionRepository -> findById ( $ conditionData [ 'id' ] ) ; // check if condition exists at all if ( ! $ conditionEntity ) { throw new FilterDependencyNotFoundException ( self :: $ conditionEntityName , $ conditionData [ 'id' ] ) ; } // check if conditions is related with condition group if ( $ conditionEntity -> getConditionGroup ( ) -> getId ( ) !== $ conditionGroup -> getId ( ) ) { throw new ConditionGroupMismatchException ( $ matchedEntry [ 'id' ] ) ; } $ conditionIds [ ] = $ conditionEntity -> getId ( ) ; } else { $ conditionEntity = new ConditionEntity ( ) ; $ conditionEntity -> setConditionGroup ( $ conditionGroup ) ; $ conditionGroup -> addCondition ( $ conditionEntity ) ; $ this -> em -> persist ( $ conditionEntity ) ; $ conditionIds [ ] = $ conditionEntity -> getId ( ) ; } $ conditionEntity -> setField ( $ this -> getProperty ( $ conditionData , 'field' , $ conditionEntity -> getField ( ) ) ) ; $ conditionEntity -> setOperator ( $ this -> getProperty ( $ conditionData , 'operator' , $ conditionEntity -> getOperator ( ) ) ) ; $ conditionEntity -> setType ( $ this -> getProperty ( $ conditionData , 'type' , $ conditionEntity -> getType ( ) ) ) ; $ value = $ this -> getValueForCondition ( $ this -> getProperty ( $ conditionData , 'value' , $ conditionEntity -> getValue ( ) ) , $ conditionEntity -> getType ( ) ) ; $ conditionEntity -> setValue ( $ value ) ; } $ this -> removeNonExistentConditions ( $ conditionGroup , $ conditionIds ) ; } return true ; }
Updates the given condition group with the values from the given array.

@param ConditionGroupEntity $conditionGroup
@param array $matchedEntry

@return bool

@throws ConditionGroupMismatchException
@throws FilterDependencyNotFoundException
Updates the given condition group with the values from the given array .