src/BackendIntegration/InputScreen/InputScreen.php
protected function transformConditions($conditions)
    {
        // First pass, sort them into pid.
        $sorted = array();
        $byPid  = array();
        foreach ($conditions as $i => $condition) {
            $sorted[$condition['id']]   = $conditions[$i];
            $byPid[$condition['pid']][] = $condition['id'];
        }

        $instances = array();
        // Second pass, handle them.
        foreach ($sorted as $id => $condition) {
            $instances[$id] = $this->transformCondition($condition);
        }

        // Sort all conditions into their parents.
        foreach ($byPid as $pid => $ids) {
            foreach ($ids as $id) {
                $settingId = $sorted[$id]['settingId'];
                if (!isset($this->conditions[$settingId])) {
                    $this->conditions[$settingId] = new PropertyConditionChain();
                }
                $result    = $this->conditions[$settingId];
                $condition = $instances[$id];
                $parent    = ($pid == 0) ? $result : $instances[$pid];

                // have other classes in the future.
                if ($parent instanceof ConditionChainInterface) {
                    $parent->addCondition($condition);
                } elseif ($parent instanceof NotCondition) {
                    $parent->setCondition($condition);
                }
            }
        }
    }
protected function transformConditions($conditions)
    {
        // First pass, sort them into pid.
        $sorted = array();
        $byPid  = array();
        foreach ($conditions as $i => $condition) {
            $sorted[$condition['id']]   = $conditions[$i];
            $byPid[$condition['pid']][] = $condition['id'];
        }

        $instances = array();
        // Second pass, handle them.
        foreach ($sorted as $id => $condition) {
            $instances[$id] = $this->transformCondition($condition);
        }

        // Sort all conditions into their parents.
        foreach ($byPid as $pid => $ids) {
            foreach ($ids as $id) {
                $settingId = $sorted[$id]['settingId'];
                if (!isset($this->conditions[$settingId])) {
                    $this->conditions[$settingId] = new PropertyConditionChain();
                }
                $result    = $this->conditions[$settingId];
                $condition = $instances[$id];
                $parent    = ($pid == 0) ? $result : $instances[$pid];

                // have other classes in the future.
                if ($parent instanceof ConditionChainInterface) {
                    $parent->addCondition($condition);
                } elseif ($parent instanceof NotCondition) {
                    $parent->setCondition($condition);
                }
            }
        }
    }
protected function transformConditions ( $ conditions ) { // First pass, sort them into pid. $ sorted = array ( ) ; $ byPid = array ( ) ; foreach ( $ conditions as $ i => $ condition ) { $ sorted [ $ condition [ 'id' ] ] = $ conditions [ $ i ] ; $ byPid [ $ condition [ 'pid' ] ] [ ] = $ condition [ 'id' ] ; } $ instances = array ( ) ; // Second pass, handle them. foreach ( $ sorted as $ id => $ condition ) { $ instances [ $ id ] = $ this -> transformCondition ( $ condition ) ; } // Sort all conditions into their parents. foreach ( $ byPid as $ pid => $ ids ) { foreach ( $ ids as $ id ) { $ settingId = $ sorted [ $ id ] [ 'settingId' ] ; if ( ! isset ( $ this -> conditions [ $ settingId ] ) ) { $ this -> conditions [ $ settingId ] = new PropertyConditionChain ( ) ; } $ result = $ this -> conditions [ $ settingId ] ; $ condition = $ instances [ $ id ] ; $ parent = ( $ pid == 0 ) ? $ result : $ instances [ $ pid ] ; // have other classes in the future. if ( $ parent instanceof ConditionChainInterface ) { $ parent -> addCondition ( $ condition ) ; } elseif ( $ parent instanceof NotCondition ) { $ parent -> setCondition ( $ condition ) ; } } } }
Transform the given condition array into real conditions.

@param array $conditions The property condition information.

@return void
Transform the given condition array into real conditions .