LazyRecord\Schema\SchemaUtils::buildSchemaMap PHP Метод

buildSchemaMap() публичный статический Метод

* static public function find_schema_parents(array $classes) { $parents = []; foreach ($classes as $class) { $schema = new $class; // declare schema foreach ($schema->relations as $relKey => $rel ) { if (!isset($rel['foreign_schema'])) { continue; } $foreignClass = ltrim($rel['foreign_schema'],'\\'); $schema = new $foreignClass; if ($rel->type == Relationship::BELONGS_TO) { $parents[$class][] = $foreignClass; } else if ($rel->type == Relationship::HAS_ONE || $rel->type == Relationship::HAS_MANY) { $parents[$foreignClass][] = $class; } } } return $parents; }
public static buildSchemaMap ( array $schemas )
$schemas array
    public static function buildSchemaMap(array $schemas)
    {
        $schemaMap = [];
        // map table names to declare schema objects
        foreach ($schemas as $schema) {
            $schemaMap[$schema->getTable()] = $schema;
        }
        return $schemaMap;
    }

Usage Example

Пример #1
0
 /**
  * @return DeclareSchema[] Return declared schema object in associative array
  */
 public static function loadSchemaTableMap()
 {
     $schemas = self::loadDeclaredSchemas();
     return SchemaUtils::buildSchemaMap($schemas);
 }