Bake\Shell\Task\ModelTask::getTableContext PHP Метод

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

Get table context for baking a given table.
public getTableContext ( Table $tableObject, string $table, string $name ) : array
$tableObject Cake\ORM\Table The model name to generate.
$table string The table name for the model being baked.
$name string The model name to generate.
Результат array
    public function getTableContext($tableObject, $table, $name)
    {
        $associations = $this->getAssociations($tableObject);
        $this->applyAssociations($tableObject, $associations);
        $primaryKey = $this->getPrimaryKey($tableObject);
        $displayField = $this->getDisplayField($tableObject);
        $propertySchema = $this->getEntityPropertySchema($tableObject);
        $fields = $this->getFields();
        $validation = $this->getValidation($tableObject, $associations);
        $rulesChecker = $this->getRules($tableObject, $associations);
        $behaviors = $this->getBehaviors($tableObject);
        $connection = $this->connection;
        $hidden = $this->getHiddenFields($tableObject);
        return compact('associations', 'primaryKey', 'displayField', 'table', 'propertySchema', 'fields', 'validation', 'rulesChecker', 'behaviors', 'connection', 'hidden');
    }

Usage Example

 /**
  * Compare bake table result with static comparison file
  *
  * @return void
  */
 protected function _compareBakeTableResult($name, $comparisonFile)
 {
     $table = $this->Task->getTable($name);
     $tableObject = $this->Task->getTableObject($name, $table);
     $data = $this->Task->getTableContext($tableObject, $table, $name);
     $result = $this->Task->bakeTable($tableObject, $data);
     $this->assertSameAsFile($comparisonFile . '.php', $result);
 }