CrudKit\Data\SQLDataProvider::processColumns PHP Method

processColumns() protected method

Converts columns from raw objects to more powerful cool objects
protected processColumns ( )
    protected function processColumns()
    {
        // Get a schema manager and get the list of columns
        $sm = $this->conn->getSchemaManager();
        $columns = $sm->listTableColumns($this->tableName);
        $type_lookup = array();
        /**
         * @var $col Column
         */
        foreach ($columns as $col) {
            $type_lookup[$col->getName()] = $col;
        }
        foreach ($this->colDefs as $item) {
            $id = $item['id'];
            $category = $item['category'];
            $opts = $item['options'];
            /**
             * @var $target SQLColumn
             */
            $target = null;
            switch ($category) {
                case SQLColumn::CATEGORY_VALUE:
                    $target = new ValueColumn($id, $category, $opts);
                    break;
                    // case "foreign":
                    //     $target = new ForeignColumn($id, $category, $opts);
                    //     break;
                // case "foreign":
                //     $target = new ForeignColumn($id, $category, $opts);
                //     break;
                case SQLColumn::CATEGORY_PRIMARY:
                    $target = new PrimaryColumn($id, $category, $opts);
                    break;
                case SQLColumn::CATEGORY_EXTERNAL:
                    $target = new ExternalColumn($id, $category, $opts);
                    break;
                default:
                    //TODO: Throw library-specific exceptions
                    throw new \Exception("Unknown category for column {$category}");
            }
            $target->doctrineColumnLookup($type_lookup);
            $target->init();
            $this->columns[$id] = $target;
        }
    }