Spot\Mapper::entityManager PHP Method

entityManager() public method

Entity manager class for storing information and meta-data about entities
public entityManager ( ) : Manager
return Spot\Entity\Manager
    public function entityManager()
    {
        $entityName = $this->entity();
        if (!isset(self::$entityManager[$entityName])) {
            self::$entityManager[$entityName] = new Entity\Manager($entityName);
        }
        return self::$entityManager[$entityName];
    }

Usage Example

Example #1
0
 /**
  * Migrate create schema
  *
  * @return \Doctrine\DBAL\Schema\Schema
  */
 public function migrateCreateSchema()
 {
     $entityName = $this->mapper->entity();
     $table = $entityName::table();
     $fields = $this->mapper->entityManager()->fields();
     $fieldIndexes = $this->mapper->entityManager()->fieldKeys();
     $schema = new \Doctrine\DBAL\Schema\Schema();
     $table = $schema->createTable($table);
     foreach ($fields as $field => $fieldInfo) {
         $fieldType = $fieldInfo['type'];
         unset($fieldInfo['type']);
         $table->addColumn($field, $fieldType, $fieldInfo);
     }
     // PRIMARY
     if ($fieldIndexes['primary']) {
         $table->setPrimaryKey($fieldIndexes['primary']);
     }
     // UNIQUE
     foreach ($fieldIndexes['unique'] as $keyName => $keyFields) {
         $table->addUniqueIndex($keyFields, $keyName);
     }
     // INDEX
     foreach ($fieldIndexes['index'] as $keyName => $keyFields) {
         $table->addIndex($keyFields, $keyName);
     }
     return $schema;
 }
All Usage Examples Of Spot\Mapper::entityManager