/** * setup method * * @param Model $model * @param array $config * @return void */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); if (isset($config['mangle'])) { $config['mangle'] .= ' mangled'; } $this->settings[$model->alias] = array_merge(array('beforeFind' => 'on', 'afterFind' => 'off'), $config); }
public function setup(Model $model, $config = array()) { parent::setup($model, $config); if (!isset($this->settings[$model->alias])) { $this->settings[$model->alias] = $this->_defaults; } $this->settings[$model->alias] = array_merge($this->settings[$model->alias], $config); }
/** * Setup this behavior with the specified configuration settings. * * @param Model $model Model using this behavior * @param array $config Configuration settings for $model * @return void */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); foreach ($config as $field) { $this->settings[$model->alias]['fields'][] = $field; } $this->validateDb($model); }
/** * Setup the behaviour and merge in the settings. Check that the model has the * required fields * * @param Model $model * @param array $config */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); $this->settings[$model->alias] = array_merge($this->defaults, $config); $this->modelAlias = $model->alias; $this->hasField($model); $this->checkPrefix($model); if (!ClassRegistry::isKeySet($this->settings[$model->alias]['statusModel'])) { $this->Status = ClassRegistry::init($this->settings[$model->alias]['statusModel']); } }
/** * Setup * @param Model $model * @param array $config * @throws ErrorException */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); if (empty($config['list'])) { throw new ErrorException('The list id is necessary to save the contact.'); } $this->listId = $config['list']; // If key fields exists if (!empty($config['fields'])) { $this->fields = $config['fields']; } $this->Contact = new MediaPostContact(null); }
/** * SetUp behavior * * @param object $model instance of model * @param array $config array of configuration settings. * @return void */ public function setup(Model $model, $config = array()) { if (isset($config['model'])) { $this->__model = $config['model']; } else { $this->__model = $model->name; } if (isset($config['field'])) { $this->__field = $config['field']; } else { $this->__field = 'key'; } parent::setup($model, $config); }
public function setup(Model $Model, $config = []) { $this->_settings = $config; $this->_Grid = $Model->getDataSource()->getMongoDb()->getGridFS(); return parent::setup($Model, $this->_settings); }
/** * Initialize Serializable Behavior * * @param Model $Model Model which uses behaviour * @param array $config Behaviour config */ public function setup(Model $Model, $config = array()) { parent::setup($Model, $config); $this->config[$Model->alias] = $config + (array) Configure::read('Serializable') + array('fields' => array(), 'serialize' => 'serialize', 'unserialize' => 'unserialize', 'aliases' => array(), 'merge' => false); }
/** * Sets up a connection using passed settings * * ### Config * - `config` The name of an existing Cache configuration to use. Default is 'default' * - `clearOnSave` Whether or not to delete the cache on saves * - `clearOnDelete` Whether or not to delete the cache on deletes * - `auto` Automatically cache or look for `'cache'` in the find conditions * where the key is `true` or a duration * * @param Model $model The calling model * @param array $config Configuration settings * @return void * @see Cache::config() */ public function setup(Model $model, $config = array()) { $settings = array_merge($this->_defaults, $config); // Modified and set config for CachedSoure by behavior setting $ds = ConnectionManager::getDataSource($model->useDbConfig); $dsConfig = array_merge($ds->config, array('original' => $model->useDbConfig, 'datasource' => 'Cache.CachedSource', 'config' => $settings['config'], 'map' => $settings['map'], 'gzip' => $settings['gzip'])); if (!in_array('cached', ConnectionManager::sourceList())) { ConnectionManager::create('cached', $dsConfig); } else { $ds = ConnectionManager::getDataSource('cached'); $ds->setConfig($dsConfig); } // Merge behavior setting if (!isset($this->settings[$model->alias])) { $this->settings[$model->alias] = $settings; } else { $this->settings[$model->alias] = array_merge($this->settings[$model->alias], $settings); } return parent::setup($model, $config); }
/** * Initialize Caching Behavior * * @param Model $Model Model which uses behaviour * @param array $config Behaviour config */ public function setup(Model $Model, $config = array()) { parent::setup($Model, $config); $this->config[$Model->alias] = $config + array('cache' => 'default', 'cachedObject' => 'Caching.CachedObject'); }
/** * Setup this behavior with the specified configuration settings. * * @param Model $model Model using this behavior * @param array $config Configuration settings for $model * @return void */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); $model->loadModels(['RolesRoomsUser' => 'Rooms.RolesRoomsUser', 'Room' => 'Rooms.Room', 'Space' => 'Rooms.Space']); }
public function setup(\Model $model, $config = array()) { return parent::setup($model, $config); }
/** * Populates the settings property of the behavior in an array in the form: * * array( * $model->alias => array( * $habtmAlias => array( * 'counterCache' => '<counterCache field name>' * 'counterScope' => array('field' => 'value') // Usual CakePHP condition * 'underCounterCache' => '<counterTree field name>' * ), * ), * ) * * @param AppModel $model * @param array $config Configuration is very flexible, for example: * - Just attach and it will do counter caching for all hatbm * associated models that have the counterCache field. E.g. * * var $actsAs = array('HabtmCounterCache.HabtmCounterCache'); * * - Specify counterCache, counterScope and/or underCounterCache keys * in the configuration options when you attach the behavior for these * settings to be applied to all habtm associations. E.g. * * var $actsAs = array( * 'HabtmCounterCache.HabtmCounterCache' => array( * 'counterScope' => array('active' => 1) * ), * ); * * - Introduce habtm association specific counterCache and counterScope * settings by using the habtm alias as the key E.g. * * var $actsAs = array( * 'HabtmCounterCache.HabtmCounterCache' => array( * 'Tag' => array( * 'counterCache' => 'weight' * ) * ), * ); */ public function setup(\Model $model, $config = array()) { parent::setup($model, $config); // Work out the default names of what we expect the counter cache and under // counter cache fields to be. These will be overridden if specified in the // config. $defaultCounterCacheField = Inflector::underscore($model->alias) . '_count'; $defaultUnderCounterCacheField = 'under_' . $defaultCounterCacheField; // Set up the default settings for this model. Default counterCache field is // post_count for Post model, no counterScope. $defaults = array('counterCache' => $defaultCounterCacheField, 'counterScope' => null, 'underCounterCache' => $defaultUnderCounterCacheField); // Get the settings for all habtm associations, if set. $allHabtmSettings = $this->_config2settings($config); $allHabtmSettings = array_merge($defaults, $allHabtmSettings); // Iterate through the habtms of the model, assigning the settings to the // settings property of the behavior foreach ($model->hasAndBelongsToMany as $habtmAlias => $habtmAssocData) { $habtmSpecificSettings = array(); // Check whether habtm specific settings have been set for this alias if (isset($config[$habtmAlias])) { if ($config[$habtmAlias] == false) { continue; } else { $habtmSpecificSettings = $this->_config2settings($config[$habtmAlias]); } // Check whether habtm specific settings have been set for this habtm's // class name (note, you may have 2 assocs using the same class name) } elseif (isset($config[$habtmAssocData['className']])) { if ($config[$habtmAssocData['className']] == false) { continue; } else { $habtmSpecificSettings = $this->_config2settings($config[$habtmAssocData['className']]); } } // The behavior needs to know the className, joinTable, foreignKey and // associationForeignKey of the assoc later, so may as well grab them now. $habtmSpecificSettings += array_intersect_key($habtmAssocData, array_flip(array('className', 'joinTable', 'foreignKey', 'associationForeignKey'))); // It also needs to know the joinModel, so may as well determine that now $habtmSpecificSettings['joinModel'] = Inflector::camelize(Inflector::singularize($habtmSpecificSettings['joinTable'])); // Merge any habtm specific settings for the current association with the // defaults and the config for all associations $habtmSpecificSettings = array_merge($allHabtmSettings, $habtmSpecificSettings); // Verify the counterCache and underCounterCache fields specified or // determined from the defaults actually exist on the habtm model. $habtmSchema = $model->{$habtmAlias}->schema(); if (!array_key_exists($habtmSpecificSettings['counterCache'], $habtmSchema)) { $habtmSpecificSettings['counterCache'] = false; } if (!array_key_exists('lft', $habtmSchema) || !array_key_exists('rght', $habtmSchema) || !array_key_exists($habtmSpecificSettings['underCounterCache'], $habtmSchema)) { $habtmSpecificSettings['underCounterCache'] = false; } if (!$habtmSpecificSettings['counterCache'] && !$habtmSpecificSettings['underCounterCache']) { continue; } // Store the merged settings in the behavior's settings property indexed // by the model->alias and the habtmAlias $this->settings[$model->alias][$habtmAlias] = $habtmSpecificSettings; } }
/** * Setup the model * * @param Model $Model * @param array $settings * @return void * @author David Kullmann */ public function setup(Model $Model, $settings = array()) { parent::setup($Model, $settings); $Model->findMethods['geo'] = true; $this->settings[$Model->alias] = Set::merge($this->_defaults, $settings); }
/** * Setup behavior */ public function setup(Model $Model, $config = array()) { parent::setup($Model, $config); $this->settings[$Model->name] = Hash::merge($this->_defaults, $config); }
/** * Setup this behavior with the specified configuration settings. * * @param Model $model Model using this behavior * @param array $config Configuration settings for $model * @return void */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); //ビヘイビアの優先順位 $this->settings['priority'] = 9; }
public function setup(Model $model, $config = array()) { $model->validate += array('recaptcha_response_field' => array('checkRecaptcha' => array('rule' => array('checkRecaptcha'), 'required' => true, 'allowEmpty' => false, 'message' => 'You did not enter the words correctly. Please try again.'))); return parent::setup($model, $config); }
/** * Setup this behavior with the specified configuration settings. * * @param Model $model Model using this behavior * @param array $config Configuration settings for $model * * @return void */ public function setup(\Model $model, $config = []) { parent::setup($model, $config); }
/** * Setup this behavior with the specified configuration settings. * * @param Model $model Model using this behavior * @param array $config Configuration settings for $model * @return void */ public function setup(Model $model, $config = array()) { parent::setup($model, $config); $model->loadModels(['SiteSetting' => 'SiteManager.SiteSetting']); }