protected function prepareItem($item)
    {
        if (!isset($item["type"])) {
            return $item;
        }

        if (isset($item["children"])) {
            $item["children"] = $this->prepareItems($item["children"]);
        }

        switch ($item['type']) {
            case 'select':
                if (isset($item['sql'])) {
                    $connectionName = isset($item['connection']) ? $item['connection'] : 'default';
                    $sql            = $item['sql'];
                    $options        = isset($item["options"]) ? $item["options"] : array();

                    unset($item['sql']);
                    unset($item['connection']);
                    /** @var Connection $connection */
                    $connection = $this->container->get("doctrine.dbal.{$connectionName}_connection");
                    $all        = $connection->fetchAll($sql);
                    foreach ($all as $option) {
                        $options[] = array(reset($option), end($option));
                    }
                    $item["options"] = $options;
                }

                if (isset($item['service'])) {
                    $serviceInfo = $item['service'];
                    $serviceName = isset($serviceInfo['serviceName']) ? $serviceInfo['serviceName'] : 'default';
                    $method      = isset($serviceInfo['method']) ? $serviceInfo['method'] : 'get';
                    $args        = isset($serviceInfo['args']) ? $item['args'] : '';
                    $service     = $this->container->get($serviceName);
                    $options     = $service->$method($args);

                    $item['options'] = $options;
                }

                if (isset($item['dataStore'])) {
                    $dataStoreInfo = $item['dataStore'];
                    $dataStore     = $this->container->get('data.source')->get($dataStoreInfo["id"]);
                    $options       = array();
                    foreach ($dataStore->search() as $dataItem) {
                        $options[ $dataItem->getId() ] = $dataItem->getAttribute($dataStoreInfo["text"]);
                    }
                    if (isset($item['dataStore']['popupItems'])) {
                        $item['dataStore']['popupItems'] = $this->prepareItems($item['dataStore']['popupItems']);
                    }
                    $item['options'] = $options;
                }
                break;
        }
        return $item;
    }
protected function prepareItem($item)
    {
        if (!isset($item["type"])) {
            return $item;
        }

        if (isset($item["children"])) {
            $item["children"] = $this->prepareItems($item["children"]);
        }

        switch ($item['type']) {
            case 'select':
                if (isset($item['sql'])) {
                    $connectionName = isset($item['connection']) ? $item['connection'] : 'default';
                    $sql            = $item['sql'];
                    $options        = isset($item["options"]) ? $item["options"] : array();

                    unset($item['sql']);
                    unset($item['connection']);
                    /** @var Connection $connection */
                    $connection = $this->container->get("doctrine.dbal.{$connectionName}_connection");
                    $all        = $connection->fetchAll($sql);
                    foreach ($all as $option) {
                        $options[] = array(reset($option), end($option));
                    }
                    $item["options"] = $options;
                }

                if (isset($item['service'])) {
                    $serviceInfo = $item['service'];
                    $serviceName = isset($serviceInfo['serviceName']) ? $serviceInfo['serviceName'] : 'default';
                    $method      = isset($serviceInfo['method']) ? $serviceInfo['method'] : 'get';
                    $args        = isset($serviceInfo['args']) ? $item['args'] : '';
                    $service     = $this->container->get($serviceName);
                    $options     = $service->$method($args);

                    $item['options'] = $options;
                }

                if (isset($item['dataStore'])) {
                    $dataStoreInfo = $item['dataStore'];
                    $dataStore     = $this->container->get('data.source')->get($dataStoreInfo["id"]);
                    $options       = array();
                    foreach ($dataStore->search() as $dataItem) {
                        $options[ $dataItem->getId() ] = $dataItem->getAttribute($dataStoreInfo["text"]);
                    }
                    if (isset($item['dataStore']['popupItems'])) {
                        $item['dataStore']['popupItems'] = $this->prepareItems($item['dataStore']['popupItems']);
                    }
                    $item['options'] = $options;
                }
                break;
        }
        return $item;
    }
protected function prepareItem ( $ item ) { if ( ! isset ( $ item [ "type" ] ) ) { return $ item ; } if ( isset ( $ item [ "children" ] ) ) { $ item [ "children" ] = $ this -> prepareItems ( $ item [ "children" ] ) ; } switch ( $ item [ 'type' ] ) { case 'select' : if ( isset ( $ item [ 'sql' ] ) ) { $ connectionName = isset ( $ item [ 'connection' ] ) ? $ item [ 'connection' ] : 'default' ; $ sql = $ item [ 'sql' ] ; $ options = isset ( $ item [ "options" ] ) ? $ item [ "options" ] : array ( ) ; unset ( $ item [ 'sql' ] ) ; unset ( $ item [ 'connection' ] ) ; /** @var Connection $connection */ $ connection = $ this -> container -> get ( "doctrine.dbal.{$connectionName}_connection" ) ; $ all = $ connection -> fetchAll ( $ sql ) ; foreach ( $ all as $ option ) { $ options [ ] = array ( reset ( $ option ) , end ( $ option ) ) ; } $ item [ "options" ] = $ options ; } if ( isset ( $ item [ 'service' ] ) ) { $ serviceInfo = $ item [ 'service' ] ; $ serviceName = isset ( $ serviceInfo [ 'serviceName' ] ) ? $ serviceInfo [ 'serviceName' ] : 'default' ; $ method = isset ( $ serviceInfo [ 'method' ] ) ? $ serviceInfo [ 'method' ] : 'get' ; $ args = isset ( $ serviceInfo [ 'args' ] ) ? $ item [ 'args' ] : '' ; $ service = $ this -> container -> get ( $ serviceName ) ; $ options = $ service -> $ method ( $ args ) ; $ item [ 'options' ] = $ options ; } if ( isset ( $ item [ 'dataStore' ] ) ) { $ dataStoreInfo = $ item [ 'dataStore' ] ; $ dataStore = $ this -> container -> get ( 'data.source' ) -> get ( $ dataStoreInfo [ "id" ] ) ; $ options = array ( ) ; foreach ( $ dataStore -> search ( ) as $ dataItem ) { $ options [ $ dataItem -> getId ( ) ] = $ dataItem -> getAttribute ( $ dataStoreInfo [ "text" ] ) ; } if ( isset ( $ item [ 'dataStore' ] [ 'popupItems' ] ) ) { $ item [ 'dataStore' ] [ 'popupItems' ] = $ this -> prepareItems ( $ item [ 'dataStore' ] [ 'popupItems' ] ) ; } $ item [ 'options' ] = $ options ; } break ; } return $ item ; }
Prepare element by type

@param $item
@return mixed
@internal param $type
Prepare element by type