本文整理汇总了PHP中Cake\ORM\Behavior::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP Behavior::initialize方法的具体用法?PHP Behavior::initialize怎么用?PHP Behavior::initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Behavior
的用法示例。
在下文中一共展示了Behavior::initialize方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public function initialize(array $config = [])
{
parent::initialize($config);
if (isset($config['states']) && is_array($config['states'])) {
$this->config('states', $config['states'], false);
}
}
示例2: initialize
/**
* Constructor hook method.
*
* Implement this method to avoid having to overwrite
* the constructor and call parent.
*
* @param array $config The configuration settings provided to this behavior.
* @return void
*/
public function initialize(array $config)
{
$this->Attachments = TableRegistry::get('Attachments.Attachments');
// Dynamically attach the hasMany relationship
$this->_table->hasMany('Attachments.Attachments', ['conditions' => ['Attachments.model' => $this->_table->registryAlias()], 'foreignKey' => 'foreign_key', 'dependent' => true]);
$this->Attachments->belongsTo($this->_table->registryAlias(), ['conditions' => ['Attachments.model' => $this->_table->registryAlias()], 'foreignKey' => 'foreign_key']);
parent::initialize($config);
}
示例3: initialize
/**
* Behavior configuration
*
* @param array $config
* @return void
*/
public function initialize(array $config = [])
{
$config += (array) Configure::read('Captcha');
parent::initialize($config);
$engine = $this->config('engine');
$this->_engine = new $engine($this->config());
$this->_captchasTable = TableRegistry::get('Captcha.Captchas');
}
示例4: initialize
/**
* Constructor hook method.
*
* @param array $config The configuration settings provided to this behavior.
* @return void
*/
public function initialize(array $config)
{
// Set default translations
$this->config('translations', ['id' => __d('model_history', 'field.id'), 'comment' => __d('model_history', 'field.comment'), 'created' => __d('model_history', 'field.created'), 'modified' => __d('model_history', 'field.modified')]);
$this->ModelHistory = TableRegistry::get('ModelHistory.ModelHistory');
// Dynamically attach the hasMany relationship
$this->_table->hasMany('ModelHistory.ModelHistory', ['conditions' => ['ModelHistory.model' => $this->_table->registryAlias()], 'order' => ['ModelHistory.revision DESC'], 'foreignKey' => 'foreign_key', 'dependent' => false]);
parent::initialize($config);
}
示例5: initialize
/**
* Initialize hook
*
* @param array $config The config for this behavior.
* @return void
* @throws \RuntimeException
*/
public function initialize(array $config)
{
$expected = 'Postgres\\Database\\Driver\\Postgres';
if (!is_a($this->_table->connection()->driver(), $expected)) {
$msgstr = sprintf('Driver for table "%s" is not an instance of "%s" (using "%s" connection)', $this->_table->table(), $expected, $this->_table->connection()->configName());
throw new \RuntimeException($msgstr);
}
parent::initialize($config);
$this->config($config);
}
示例6: initialize
public function initialize(array $config)
{
parent::initialize($config);
if (array_key_exists('private', $config)) {
$this->upload_private = $config['private'];
}
if (array_key_exists('encrypted', $config)) {
$this->upload_encrypted = $config['encrypted'];
}
if (array_key_exists('fields', $config)) {
$this->upload_fields = $config['fields'];
}
}
示例7: initialize
public function initialize(array $config)
{
parent::initialize($config);
if (isset($config['fields'])) {
$result = [];
foreach ((array) $config['fields'] as $field => $when) {
if (is_int($field)) {
$field = $when;
$when = 'new';
}
$result[$field] = $when;
}
$this->config('fields', $result, false);
}
}
示例8: initialize
/**
* Constructor hook method.
*
* Implement this method to avoid having to overwrite
* the constructor and call parent.
*
* @param array $config The configuration settings provided to this behavior.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$habtm = $this->config('habtm');
/*
* Ensure that no HABTM models which are already auditable
* snuck into the settings array. That would be bad. Same for
* any model which isn't a HABTM association.
*/
foreach ($habtm as $index => $modelName) {
$association = $this->_table->association($modelName);
if (!$association instanceof \Cake\ORM\Association\BelongsToMany) {
continue;
}
if ($this->_table->{$modelName}->hasBehavior('Auditable')) {
unset($habtm[$index]);
}
}
$this->config('habtm', $habtm, false);
}
示例9: initialize
/**
* Initializes the behavior and its parent
*
* @param array $config Array of configuration settings
*/
public function initialize(array $config)
{
parent::initialize($config);
// TODO: Change the autogenerated stub
}
示例10: initialize
/**
* Initialize behavior
*
* @param array $config Config
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->_normalizeConfig($config);
}
示例11: initialize
public function initialize(array $config)
{
parent::initialize($config);
$this->_table->hasMany('Revisions', ['className' => 'Revisions.Revisions', 'foreignKey' => 'ref_id', 'order' => 'Revisions.created DESC', 'conditions' => ['ref' => $this->_table->alias()]]);
}
示例12: initialize
/**
* Initialize method
*
* @param array $config The configuration for the Table.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
$this->foreignKey = Inflector::singularize($this->_table->table()) . '_id';
$this->_table->hasMany('Historics', ['foreignKey' => $this->foreignKey, 'conditions' => ['Historics.is_active' => true], 'className' => $this->config()['class']]);
}
示例13: initialize
/**
* Initialize
*
* Initialize callback for Behaviors.
*
* @param array $config Options.
* @return void
*/
public function initialize(array $config)
{
parent::initialize($config);
}