本文整理汇总了PHP中Cake\ORM\Behavior::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Behavior::__construct方法的具体用法?PHP Behavior::__construct怎么用?PHP Behavior::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Behavior
的用法示例。
在下文中一共展示了Behavior::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param \Cake\ORM\Table $table Table who requested the behavior.
* @param array $config Options.
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
$this->Table = $table;
if ($this->config('created_by')) {
$this->Table->belongsTo('CreatedBy', ['foreignKey' => $this->config('created_by'), 'className' => $this->config('userModel'), 'propertyName' => $this->config('createdByPropertyName')]);
}
if ($this->config('modified_by')) {
$this->Table->belongsTo('ModifiedBy', ['foreignKey' => $this->config('modified_by'), 'className' => $this->config('userModel'), 'propertyName' => $this->config('modifiedByPropertyName')]);
}
}
示例2: __construct
public function __construct(Table $table, array $config = [])
{
$this->_defaultConfig['ancestor_table_name'] = $table->schema()->name() . '_ancestors';
parent::__construct($table, $config);
$this->_table = $table;
$this->addValidationRules();
}
示例3: __construct
/**
* Default configuration.
*
* @var array
*
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
$this->_table = $table;
$this->_table->addBehavior('Timestamp');
$this->bindTagAssociations();
}
示例4: __construct
/**
* Sets up the configuration for the model, and loads ACL models if they haven't been already
*
* @param Table $model Table instance being attached
* @param array $config Configuration
* @return void
*/
public function __construct(Table $model, array $config = [])
{
$this->_table = $model;
if (isset($config[0])) {
$config['type'] = $config[0];
unset($config[0]);
}
if (isset($config['type'])) {
$config['type'] = strtolower($config['type']);
}
parent::__construct($model, $config);
$types = $this->_typeMaps[$this->config()['type']];
if (!is_array($types)) {
$types = [$types];
}
foreach ($types as $type) {
$alias = Inflector::pluralize($type);
$className = App::className($alias . 'Table', 'Model/Table');
if ($className == false) {
$className = App::className('Acl.' . $alias . 'Table', 'Model/Table');
}
$config = [];
if (!TableRegistry::exists($alias)) {
$config = ['className' => $className];
}
$model->hasMany($type, ['targetTable' => TableRegistry::get($alias, $config)]);
}
if (!method_exists($model->entityClass(), 'parentNode')) {
trigger_error(__d('cake_dev', 'Callback {0} not defined in {1}', ['parentNode()', $model->entityClass()]), E_USER_WARNING);
}
}
示例5: __construct
/**
* Constructor
*
* @param Table $table The table this behavior is attached to.
* @param array $settings The settings for this behavior.
*/
public function __construct(Table $table, array $settings = [])
{
parent::__construct($table, $settings);
$class = '\\Imagine\\' . $this->config('engine') . '\\Imagine';
$this->Imagine = new $class();
$this->_table = $table;
}
示例6: __construct
/**
* Constructor
*
* If events are specified - do *not* merge them with existing events,
* overwrite the events to listen on
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config The config for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
//Merge $config with application-wide scopeBehavior config
$config = array_merge(MTApp::config('scopeBehavior'), $config);
parent::__construct($table, $config);
$this->_table = $table;
}
示例7: __construct
/**
* Constructor
*
* If events are specified - do *not* merge them with existing events,
* overwrite the events to listen on
*
* @param Table $table The table this behavior is attached to.
* @param array $config The config for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
if (isset($config['events'])) {
$this->config('events', $config['events'], false);
}
}
示例8: __construct
/**
* @param \Cake\ORM\Table $table
* @param array $config
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
if (!$this->_config['message']) {
$this->_config['message'] = __d('tools', 'Please confirm the checkbox');
}
}
示例9: __construct
/**
* Constructor
*
* @param Table $table The table this behavior is attached to.
* @param array $config The config for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
$this->_table = $table;
$config = $this->_config;
$this->setupFieldAssociations($config['fields'], $config['translationTable']);
}
示例10: __construct
/**
* Constructor
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config 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);
}
示例11: __construct
/**
* Constructor.
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config The config for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
if (!empty($config['implementedEvents'])) {
$this->_defaultConfig['implementedEvents'] = $config['implementedEvents'];
unset($config['implementedEvents']);
}
parent::__construct($table, $config);
}
示例12: __construct
/**
* Constructor.
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config The config for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
parent::__construct($table, $config);
$this->_table = $table;
/**
* Instance the Folder with the root configuration.
*/
$this->_folder = new Folder($this->_config['root']);
}
示例13: __construct
/**
* Constructor
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config The settings for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
$this->_defaultConfig = Hash::merge($this->_defaultConfig, (array) Configure::read('FileStorage.Behavior'));
parent::__construct($table, $config);
$this->_table = $table;
if ($this->_config['validate'] === true) {
$this->configureUploadValidation($this->_config['validator']);
}
}
示例14: __construct
/**
* Adding validation rules
* also adds and merges config settings (direct + configure)
*
* @return void
*/
public function __construct(Table $table, array $config = [])
{
$defaults = $this->_defaultConfig;
if ($configureDefaults = Configure::read('Reset')) {
$defaults = $configureDefaults + $defaults;
}
$config + $defaults;
parent::__construct($table, $config);
}
示例15: __construct
/**
* Constructor
*
* @param \Cake\ORM\Table $table The table this behavior is attached to.
* @param array $config The settings for this behavior.
*/
public function __construct(Table $table, array $config = [])
{
$this->_defaultConfig = Hash::merge($this->_defaultConfig, (array) Configure::read('UserTools.Behavior'));
parent::__construct($table, $config);
$this->_table = $table;
if ($this->_config['defaultValidation'] === true) {
$this->setupDefaultValidation($this->_table);
}
$this->eventManager()->attach($this->_table);
}