/** * 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')]); } }
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(); }
/** * Default configuration. * * @var array * */ public function __construct(Table $table, array $config = []) { parent::__construct($table, $config); $this->_table = $table; $this->_table->addBehavior('Timestamp'); $this->bindTagAssociations(); }
/** * 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); } }
/** * 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; }
/** * 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; }
/** * 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); } }
/** * @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'); } }
/** * 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']); }
/** * 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); }
/** * 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); }
/** * 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']); }
/** * 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']); } }
/** * 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); }
/** * 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); }
/** * Constructor. * * @param \Cake\ORM\Table $table The table this behavior is attached to. * @param array $config The config for this behavior. * @throws \Search\Error\EngineNotFoundException When no engine was * configured */ public function __construct(Table $table, array $config = []) { parent::__construct($table, $config); $engineClass = $this->config('engine.className'); $engineClass = empty($engineClass) ? 'Search\\Engine\\Generic\\GenericEngine' : $engineClass; if (!class_exists($engineClass)) { throw new EngineNotFoundException(__d('search', 'The search engine "{0}" was not found.', $engineClass)); } $this->_engine = new $engineClass($table, (array) $this->config('engine.config')); }
/** * Adding validation rules * also adds and merges config settings (direct + configure) * * @param \Cake\ORM\Table $table * @param array $config */ public function __construct(Table $table, array $config = []) { $defaults = $this->_defaultConfig; $configureDefaults = Configure::read('Passwordable'); if ($configureDefaults) { $defaults = $configureDefaults + $defaults; } $config += $defaults; parent::__construct($table, $config); }
/** * Initiate behavior for the model using specified settings. Available settings: * * - address: (array | string, optional) set to the field name that contains the * string from where to generate the slug, or a set of field names to * concatenate for generating the slug. * * - expect: (array)postal_code, locality, sublocality, ... * * - accuracy: see above * * - overwrite: lat/lng overwrite on changes? * * - update: what fields to update (key=>value array pairs) * * - before: validate/save (defaults to save) * set to false if you only want to use the validation rules etc * * Merges config with the default and store in the config property * * Does not retain a reference to the Table object. If you need this * you should override the 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 = []) { $defaults = (array) Configure::read('Geocoder'); parent::__construct($table, $config + $defaults); // Bug in core about merging keys of array values if ($this->_config['address'] === null) { $this->_config['address'] = ['street', 'postal_code', 'city', 'country']; } $this->_table = $table; }
public function __construct(Table $table, array $config = []) { $this->_defaultConfig['notices'] = Configure::read('debug'); $this->_defaultConfig['label'] = $table->displayField(); foreach ($this->_defaultConfig['replace'] as $key => $value) { $this->_defaultConfig['replace'][$key] = __d('tools', $value); } $config += (array) Configure::read('Slugged'); parent::__construct($table, $config); }
/** * __construct * * @param Table $table Table. * @param array $config Config. */ public function __construct(Table $table, array $config = []) { parent::__construct($table, $config); Type::map('Utils.File', 'Utils\\Database\\Type\\FileType'); $schema = $table->schema(); foreach ($this->getFieldList() as $field => $settings) { $schema->columnType($field, 'Utils.File'); } $table->schema($schema); $this->_Table = $table; }
/** * Constructor * * Merges config with the default and store in the config property * * @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 (isset($config['columns']) && is_string($config['columns'])) { $config['columns'] = [$config['columns']]; } parent::__construct($table, $config); if (!Type::map('serialized')) { Type::map('serialized', 'CMS\\Database\\Type\\SerializedType'); } foreach ($this->config('columns') as $column) { $this->_table->schema()->columnType($column, 'serialized'); } }
/** * Constructor. * * @param \Cake\ORM\Table $table The table this behavior is attached to * @param array $config Configuration array for this behavior */ public function __construct(Table $table, array $config = []) { $this->_table = $table; parent::__construct($this->_table, $config); if ($this->config('autoBind')) { if ($this->_table->hasField($this->config('createdByField'))) { $this->_table->belongsTo('CreatedBy', ['className' => $this->config('userModel'), 'foreignKey' => $this->config('createdByField'), 'propertyName' => 'created_by']); } if ($this->_table->hasField($this->config('modifiedByField'))) { $this->_table->belongsTo('ModifiedBy', ['className' => $this->config('userModel'), 'foreignKey' => $this->config('modifiedByField'), 'propertyName' => 'modified_by']); } } }
/** * Constructor * * Merges config with the default and store in the config property * * Does not retain a reference to the Table object. If you need this * you should override the 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 = []) { $defaults = (array) Configure::read('Hashid'); parent::__construct($table, $config + $defaults); $this->_table = $table; $this->_primaryKey = $table->primaryKey(); if ($this->_config['salt'] === null) { $this->_config['salt'] = Configure::read('Security.salt') ? sha1(Configure::read('Security.salt')) : null; } if ($this->_config['debug'] === null) { $this->_config['debug'] = Configure::read('debug'); } if ($this->_config['field'] === null) { $this->_config['field'] = $this->_primaryKey; } }
/** * Constructor * * Merges config with the default and store in the config property * * @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 = []) { $columns = $table->schema()->columns(); foreach (['deleted', 'trashed'] as $name) { if (in_array($name, $columns, true)) { $this->_defaultConfig['field'] = $name; break; } } if (empty($this->_defaultConfig['field']) && ($field = Configure::read('Muffin/Trash.field'))) { $this->_defaultConfig['field'] = $field; } parent::__construct($table, $config); if (!empty($config['events'])) { $this->config('events', $config['events'], false); } }
/** * 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 = []) { parent::__construct($table, $config); if (isset($config['events'])) { $this->config('events', $config['events'], false); } /* if (isset($config['belongsTo'])) { $this->config('belongsTo', $config['belongsTo'], false); } */ if ($this->config('belongsTo')) { foreach ($this->config('belongsTo') as $model => $options) { if (!$table->association($model)) { $table->belongsTo($model, $options); } } } }
/** * 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)]; parent::__construct($table, $config); }
/** * 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; }
/** * Constructor. * * Here we associate `Comments` table with the table this behavior is attached to. * * @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 = []) { $this->_table = $table; $this->_table->hasMany('Comments', ['className' => 'Comment.Comments', 'foreignKey' => 'entity_id', 'conditions' => ['table_alias' => Inflector::underscore($this->_table->alias()), 'status' => 'approved'], 'joinType' => 'LEFT', 'dependent' => true]); parent::__construct($table, $config); }
/** * __construct * * @param Table $table Table. * @param array $config Config. */ public function __construct(Table $table, array $config = []) { parent::__construct($table, $config); Type::map('WRUtils.File', 'WRUtils\\Database\\Type\\FileType'); $schema = $table->schema(); foreach ($this->getFieldList() as $field => $settings) { $schema->columnType($field, 'WRUtils.File'); } $table->schema($schema); $this->_Table = $table; // Amazon S3 config $config = $this->config($field); $credentials = new Credentials($config['S3Key'], $config['S3Secret']); $options = ['region' => $config['S3Region'], 'version' => $config['S3Version'], 'http' => ['verify' => false], 'signature_version' => $config['S3SignatureVersion'], 'credentials' => $credentials]; $this->_s3Client = new S3Client($options); }
/** * 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()]; parent::__construct($table, $config); }