/**
  * Default configuration.
  *
  * @var array
  *
  */
 public function __construct(Table $table, array $config = [])
 {
     parent::__construct($table, $config);
     $this->_table = $table;
     $this->_table->addBehavior('Timestamp');
     $this->bindTagAssociations();
 }
 /**
  * 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']);
 }
 /**
  * @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');
     }
 }
Example #4
0
 /**
  * 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;
 }
 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();
 }
 /**
  * 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);
     }
 }
 public function initialize(array $config = [])
 {
     parent::initialize($config);
     if (isset($config['states']) && is_array($config['states'])) {
         $this->config('states', $config['states'], false);
     }
 }
Example #9
0
 /**
  * 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;
 }
Example #10
0
 public function verifyConfig()
 {
     if ($this->config('implementedMethods') && !$this->config('implementedServices')) {
         throw new Exception('No reviews types defined.');
     }
     parent::verifyConfig();
 }
Example #11
0
 /**
  * イベント設定
  *
  * @access public
  * @author sakuragawa
  */
 public function implementedEvents()
 {
     $events = parent::implementedEvents();
     // buildValidatorを登録
     $events['Model.buildValidator'] = 'buildValidator';
     return $events;
 }
Example #12
0
 /**
  * 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 = [])
 {
     $config += ['defaultLocale' => I18n::defaultLocale(), 'referenceName' => $this->_referenceName($table)];
     if (isset($config['tableLocator'])) {
         $this->_tableLocator = $config['tableLocator'];
     }
     parent::__construct($table, $config);
 }
 /**
  * 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');
 }
 /**
  * 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);
 }
 /**
  * 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 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']);
     }
 }
 /**
  * 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);
 }
 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);
 }
Example #21
0
 /**
  * Verify config.
  *
  * @return void
  */
 public function verifyConfig()
 {
     if (!($strategy = $this->config('strategy'))) {
         throw new Exception('Missing required obfuscation strategy.');
     }
     if (!$strategy instanceof StrategyInterface) {
         throw new Exception('Strategy must implement the `Muffin\\Obfuscate\\Model\\Behavior\\Strategy\\StrategyInterface`');
     }
     parent::verifyConfig();
 }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * 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;
 }
 /**
  * __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;
 }
 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'];
     }
 }
 /**
  * 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']);
         }
     }
 }
Example #30
0
 public function verifyConfig()
 {
     $config = $this->config();
     $table = $this->_table();
     if (!in_array($config['typeField'], $table->schema()->columns())) {
         throw new \Exception();
     }
     if (!$config['table']) {
         $this->config('table', $table->table());
     }
     foreach ($config['typeMap'] as $key => $entityClass) {
         $this->addType($key, $entityClass);
     }
     parent::verifyConfig();
 }