当前位置: 首页>>代码示例>>PHP>>正文


PHP Behavior::initialize方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:mindforce,项目名称:cakephp-platform,代码行数:7,代码来源:StateableBehavior.php

示例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);
 }
开发者ID:cleptric,项目名称:cake-attachments,代码行数:17,代码来源:AttachmentsBehavior.php

示例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');
 }
开发者ID:dereuromark,项目名称:cakephp-captcha,代码行数:14,代码来源:CaptchaBehavior.php

示例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);
 }
开发者ID:codekanzlei,项目名称:cake-model-history,代码行数:15,代码来源:HistorizableBehavior.php

示例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);
 }
开发者ID:jmjjg,项目名称:cakephp-postgres,代码行数:17,代码来源:AutovalidateBehavior.php

示例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'];
     }
 }
开发者ID:robisacommonusername,项目名称:rran-site,代码行数:13,代码来源:UploadableBehavior.php

示例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);
     }
 }
开发者ID:thefredfox,项目名称:cakephp-ip-behavior,代码行数:15,代码来源:IpBehavior.php

示例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);
 }
开发者ID:jippi,项目名称:cakephp-audit-log,代码行数:29,代码来源:AuditableBehavior.php

示例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
 }
开发者ID:syntaxera,项目名称:cakephp-secureids-plugin,代码行数:10,代码来源:IdentifiableBehavior.php

示例10: initialize

 /**
  * Initialize behavior
  *
  * @param array $config Config
  * @return void
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
     $this->_normalizeConfig($config);
 }
开发者ID:UseMuffin,项目名称:Orderly,代码行数:11,代码来源:OrderlyBehavior.php

示例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()]]);
 }
开发者ID:noczcore,项目名称:cakephp3-revisions,代码行数:5,代码来源:RevisionsBehavior.php

示例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']]);
 }
开发者ID:oxenti,项目名称:historic,代码行数:12,代码来源:HistoricBehavior.php

示例13: initialize

 /**
  * Initialize
  *
  * Initialize callback for Behaviors.
  *
  * @param array $config Options.
  * @return void
  */
 public function initialize(array $config)
 {
     parent::initialize($config);
 }
开发者ID:Tomicapo,项目名称:cakephp-utils,代码行数:12,代码来源:WhoDidItBehavior.php


注:本文中的Cake\ORM\Behavior::initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。