LazyRecord\Schema\DeclareSchema::export PHP Метод

export() публичный Метод

public export ( )
    public function export()
    {
        $columnArray = array();
        foreach ($this->columns as $name => $column) {
            // This idea is from:
            // http://search.cpan.org/~tsibley/Jifty-DBI-0.75/lib/Jifty/DBI/Schema.pm
            //
            // if the refer attribute is defined, we should create the belongsTo relationship
            if ($refer = $column->refer) {
                // remove _id suffix if possible
                $accessorName = preg_replace('#_id$#', '', $name);
                $schema = null;
                $schemaClass = $refer;
                // convert class name "Post" to "PostSchema"
                if (substr($refer, -strlen('Schema')) != 'Schema') {
                    if (class_exists($refer . 'Schema', true)) {
                        $refer = $refer . 'Schema';
                    }
                }
                if (!class_exists($refer)) {
                    throw new Exception("refer schema from '{$refer}' not found.");
                }
                $o = new $refer();
                // schema is defined in model
                $schemaClass = $refer;
                if (!isset($this->relations[$accessorName])) {
                    $this->belongsTo($accessorName, $schemaClass, 'id', $name);
                }
            }
            $columnArray[$name] = $column->export();
        }
        return array('label' => $this->getLabel(), 'table' => $this->getTable(), 'column_data' => $columnArray, 'column_names' => $this->columnNames, 'primary_key' => $this->primaryKey, 'model_class' => $this->getModelClass(), 'collection_class' => $this->getCollectionClass(), 'relations' => $this->relations, 'read_data_source' => $this->readSourceId, 'write_data_source' => $this->writeSourceId);
    }