Spot\Mapper::entity PHP Method

entity() public method

Get name of the Entity class mapper was instantiated with
public entity ( ) : string
return string $entityName
    public function entity()
    {
        return $this->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($this->escapeIdentifier($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::entity