本文整理汇总了PHP中Cake\ORM\Behavior类的典型用法代码示例。如果您正苦于以下问题:PHP Behavior类的具体用法?PHP Behavior怎么用?PHP Behavior使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Behavior类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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();
}
示例2: __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;
}
示例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: __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']);
}
}
示例5: __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']);
}
示例6: __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');
}
}
示例7: __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);
}
}
示例8: __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;
}
示例9: __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();
}
示例10: __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);
}
}
示例11: initialize
public function initialize(array $config = [])
{
parent::initialize($config);
if (isset($config['states']) && is_array($config['states'])) {
$this->config('states', $config['states'], false);
}
}
示例12: verifyConfig
public function verifyConfig()
{
if ($this->config('implementedMethods') && !$this->config('implementedServices')) {
throw new Exception('No reviews types defined.');
}
parent::verifyConfig();
}
示例13: implementedEvents
/**
* イベント設定
*
* @access public
* @author sakuragawa
*/
public function implementedEvents()
{
$events = parent::implementedEvents();
// buildValidatorを登録
$events['Model.buildValidator'] = 'buildValidator';
return $events;
}
示例14: __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);
}
示例15: __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);
}