Cake\ORM\Behavior\TranslateBehavior::__construct PHP Метод

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

Constructor
public __construct ( Table $table, array $config = [] )
$table Cake\ORM\Table The table this behavior is attached to.
$config array The config for this behavior.
    public function __construct(Table $table, array $config = [])
    {
        $config += ['defaultLocale' => I18n::defaultLocale(), 'referenceName' => $this->_referenceName($table)];
        if (isset($config['tableLocator'])) {
            $this->_tableLocator = $config['tableLocator'];
        }
        parent::__construct($table, $config);
    }

Usage Example

 /**
  * Constructor
  *
  * @param \Cake\ORM\Table $table Table instance
  * @param array $config Configuration
  */
 public function __construct(Table $table, array $config = [])
 {
     $tableAlias = $table->alias();
     list($plugin) = pluginSplit($table->registryAlias(), true);
     if (isset($config['referenceName'])) {
         $tableReferenceName = $config['referenceName'];
     } else {
         $tableReferenceName = $this->_referenceName($table);
     }
     $config += ['mainTableAlias' => $tableAlias, 'translationTable' => $plugin . $tableReferenceName . 'Translations', 'hasOneAlias' => $tableAlias . 'Translation'];
     parent::__construct($table, $config);
 }