Bravo3\Orm\Mappers\Yaml\YamlMapper::loadMap PHP Method

loadMap() protected method

Parse a map file, loading metadata from YAML
protected loadMap ( string $fn )
$fn string
    protected function loadMap($fn)
    {
        $map = $this->getParser()->parse(file_get_contents($fn));
        foreach ($map as $class => $schema) {
            $table = $this->getNode($schema, Schema::TABLE_NAME);
            $entity = new Entity($class, $table);
            // Columns
            $columns = $this->getNode($schema, Schema::COLUMNS);
            foreach ($columns as $property => $column_schema) {
                if ($this->getNode($column_schema, Schema::REL_ASSOCIATION, false)) {
                    $rel = $this->createRelationship($property, $column_schema);
                    $rel->setSource($class);
                    $entity->addRelationship($rel);
                } else {
                    $entity->addColumn($this->createColumn($property, $column_schema));
                }
            }
            // Table sortables
            $entity->setSortables($this->createSortables($schema));
            // Table indices
            $indices = $this->getNode($schema, Schema::STD_INDICES, false, []);
            foreach ($indices as $name => $index_schema) {
                $index = new Index($table, $name);
                $index->setColumns($this->getNode($index_schema, Schema::INDEX_COLUMNS, false, []));
                $index->setMethods($this->getNode($index_schema, Schema::INDEX_METHODS, false, []));
                $entity->addIndex($index);
            }
            // Add to map
            $this->entities[$class] = $entity;
        }
        return $this;
    }