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


PHP ModelBehavior::setup方法代码示例

本文整理汇总了PHP中ModelBehavior::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP ModelBehavior::setup方法的具体用法?PHP ModelBehavior::setup怎么用?PHP ModelBehavior::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelBehavior的用法示例。


在下文中一共展示了ModelBehavior::setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

/**
 * 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);
	}
开发者ID:hungnt88,项目名称:5stars-1,代码行数:14,代码来源:BehaviorCollectionTest.php

示例2: setup

 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);
 }
开发者ID:bokac1984,项目名称:genije,代码行数:8,代码来源:OnlineBehavior.php

示例3: setup

 /**
  * 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);
 }
开发者ID:hevertonfreitas,项目名称:dbupload,代码行数:15,代码来源:DbUploadBehavior.php

示例4: setup

 /**
  * 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']);
     }
 }
开发者ID:Adnan0703,项目名称:CakePHP-Statusable,代码行数:18,代码来源:StatusableBehavior.php

示例5: setup

 /**
  * 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);
 }
开发者ID:lsantosc,项目名称:cakephp-mediapost,代码行数:19,代码来源:MediaPostBehavior.php

示例6: setup

 /**
  * 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);
 }
开发者ID:Onasusweb,项目名称:Likes,代码行数:21,代码来源:LikeBehavior.php

示例7: setup

 public function setup(Model $Model, $config = [])
 {
     $this->_settings = $config;
     $this->_Grid = $Model->getDataSource()->getMongoDb()->getGridFS();
     return parent::setup($Model, $this->_settings);
 }
开发者ID:pdedkov,项目名称:cakephp-mongo,代码行数:6,代码来源:GridFsBehavior.php

示例8: setup

 /**
  * 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);
 }
开发者ID:imsamurai,项目名称:cakephp-serializable-behaviour,代码行数:11,代码来源:SerializableBehavior.php

示例9: setup

 /**
  * 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);
 }
开发者ID:oanhnn,项目名称:cache,代码行数:35,代码来源:CachedBehavior.php

示例10: setup

 /**
  * 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');
 }
开发者ID:imsamurai,项目名称:cakephp-caching-behavior,代码行数:11,代码来源:CachingBehavior.php

示例11: setup

 /**
  * 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']);
 }
开发者ID:NetCommons3,项目名称:PrivateSpace,代码行数:12,代码来源:PrivateSpaceBehavior.php

示例12: setup

 public function setup(\Model $model, $config = array())
 {
     return parent::setup($model, $config);
 }
开发者ID:jgprolluxer,项目名称:prosales,代码行数:4,代码来源:AppmenuBehavior.php

示例13: setup

 /**
  * 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;
     }
 }
开发者ID:hurad,项目名称:hurad,代码行数:100,代码来源:HabtmCounterCacheBehavior.php

示例14: setup

 /**
  * 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);
 }
开发者ID:el-barto,项目名称:cakephp-elastic-search-datasource,代码行数:14,代码来源:IndexableBehavior.php

示例15: setup

 /**
  * Setup behavior
  */
 public function setup(Model $Model, $config = array())
 {
     parent::setup($Model, $config);
     $this->settings[$Model->name] = Hash::merge($this->_defaults, $config);
 }
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:8,代码来源:HashedFieldBehavior.php


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