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


PHP Model::bindModel方法代码示例

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


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

示例1: setup

 /**
  * Initiate WhoDidIt Behavior
  *
  * @param object $Model
  * @param array $config  behavior settings you would like to override
  * @return void
  * @access public
  */
 public function setup(Model $Model, $config = array())
 {
     //assign default settings
     $this->settings[$Model->alias] = $this->_defaults;
     //merge custom config with default settings
     $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], (array) $config);
     $hasFieldCreatedBy = $Model->hasField($this->settings[$Model->alias]['created_by_field']);
     $hasFieldModifiedBy = $Model->hasField($this->settings[$Model->alias]['modified_by_field']);
     $hasFieldConfirmedBy = $Model->hasField($this->settings[$Model->alias]['confirmed_by_field']);
     $this->settings[$Model->alias]['has_created_by'] = $hasFieldCreatedBy;
     $this->settings[$Model->alias]['has_modified_by'] = $hasFieldModifiedBy;
     $this->settings[$Model->alias]['has_confirmed_by'] = $hasFieldConfirmedBy;
     //handles model binding to the User model
     //according to the auto_bind settings (default true)
     if ($this->settings[$Model->alias]['auto_bind']) {
         if ($hasFieldCreatedBy) {
             $commonBelongsTo = array('CreatedBy' => array('className' => $this->settings[$Model->alias]['user_model'], 'foreignKey' => $this->settings[$Model->alias]['created_by_field']));
             $Model->bindModel(array('belongsTo' => $commonBelongsTo), false);
         }
         if ($hasFieldModifiedBy) {
             $commonBelongsTo = array('ModifiedBy' => array('className' => $this->settings[$Model->alias]['user_model'], 'foreignKey' => $this->settings[$Model->alias]['modified_by_field']));
             $Model->bindModel(array('belongsTo' => $commonBelongsTo), false);
         }
         if ($hasFieldConfirmedBy) {
             $commonBelongsTo = array('ConfirmedBy' => array('className' => $this->settings[$Model->alias]['user_model'], 'foreignKey' => $this->settings[$Model->alias]['confirmed_by_field']));
             $Model->bindModel(array('belongsTo' => $commonBelongsTo), false);
         }
     }
 }
开发者ID:robksawyer,项目名称:grabitdown,代码行数:37,代码来源:WhoDidItBehavior.php

示例2: setup

 /**
  * Initiate WhoMadeIt Behavior
  *
  * @param object $model
  * @param array $config  behavior settings you would like to override
  * @return void
  * @access public
  */
 function setup(Model $model, $config = array())
 {
     if ($model->alias != 'Dashboard' && $model->alias != 'NotificaionType' && $model->alias != 'Page') {
         //assigne default settings
         $this->settings[$model->alias] = $this->_defaults;
         //merge custom config with default settings
         $this->settings[$model->alias] = array_merge($this->settings[$model->alias], (array) $config);
         $hasFieldCreatedBy = $model->hasField($this->settings[$model->alias]['created_by_field']);
         $hasFieldModifiedBy = $model->hasField($this->settings[$model->alias]['modified_by_field']);
         $this->settings[$model->alias]['has_created_by'] = $hasFieldCreatedBy;
         $this->settings[$model->alias]['has_modified_by'] = $hasFieldModifiedBy;
         //handles model binding to the User model
         //according to the auto_bind settings (default true)
         if ($this->settings[$model->alias]['auto_bind']) {
             if ($hasFieldCreatedBy) {
                 $commonBelongsTo = array('CreatedBy' => array('className' => $this->settings[$model->alias]['user_model'], 'foreignKey' => $this->settings[$model->alias]['created_by_field'], 'fields' => array('id', 'name')));
                 $model->bindModel(array('belongsTo' => $commonBelongsTo), false);
             }
             if ($hasFieldModifiedBy) {
                 $commonBelongsTo = array('ModifiedBy' => array('className' => $this->settings[$model->alias]['user_model'], 'foreignKey' => $this->settings[$model->alias]['modified_by_field'], 'fields' => array('id', 'name')));
                 $model->bindModel(array('belongsTo' => $commonBelongsTo), false);
             }
         }
     }
 }
开发者ID:Techmentis,项目名称:flinkiso-lite,代码行数:33,代码来源:WhoDidItBehavior.php

示例3: bindCommentModels

 /**
  * Binds the commend and user model and the current model to the comments model
  *
  * @param Model $model
  * @return void
  */
 public function bindCommentModels(Model $model)
 {
     $config = $this->settings[$model->alias];
     if (!empty($config['commentModel']) && is_array($config['commentModel'])) {
         $model->bindModel(array('hasMany' => array('Comment' => $config['commentModel'])), false);
     } else {
         $model->bindModel(array('hasMany' => array('Comment' => array('className' => $config['commentModel'], 'foreignKey' => 'foreign_key', 'unique' => true, 'conditions' => '', 'fields' => '', 'dependent' => true, 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''))), false);
     }
     $model->Comment->bindModel(array('belongsTo' => array($model->alias => array('className' => $model->name, 'foreignKey' => 'foreign_key', 'unique' => true, 'conditions' => '', 'fields' => '', 'counterCache' => true, 'dependent' => false))), false);
     if (!empty($config['userModel']) && is_array($config['userModel'])) {
         $model->bindModel(array('belongsTo' => array($config['userModelAlias'] => $config['userModel'])), false);
     } else {
         $model->Comment->bindModel(array('belongsTo' => array($config['userModelAlias'] => array('className' => $config['userModelClass'], 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'counterCache' => true, 'order' => ''))), false);
     }
 }
开发者ID:jxav,项目名称:comments,代码行数:21,代码来源:CommentableBehavior.php

示例4: _setupMultirole

 /**
  * Enable Multiple Role, dynamically bind User Habtm Role
  */
 protected function _setupMultirole(Model $model)
 {
     if (!Configure::read('Access Control.multiRole')) {
         return;
     }
     $model->bindModel(array('hasAndBelongsToMany' => array('Role' => array('className' => 'Users.Role', 'unique' => 'keepExisting'))), false);
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:10,代码来源:UserAroBehavior.php

示例5: bindTagAssociations

 /**
  * Bind tag assocations
  *
  * @param Model $model Model instance that behavior is attached to
  * @return void
  */
 public function bindTagAssociations(Model $model)
 {
     extract($this->settings[$model->alias]);
     list($plugin, $withClass) = pluginSplit($withModel, true);
     $model->bindModel(array('hasAndBelongsToMany' => array($tagAlias => array('className' => $tagClass, 'foreignKey' => $foreignKey, 'associationForeignKey' => $associationForeignKey, 'unique' => true, 'conditions' => array($withClass . '.model' => $model->name), 'fields' => '', 'dependent' => true, 'with' => $withModel))), $resetBinding);
     $model->{$tagAlias}->bindModel(array('hasMany' => array($taggedAlias => array('className' => $taggedClass))), $resetBinding);
 }
开发者ID:tnoi,项目名称:tags,代码行数:13,代码来源:TaggableBehavior.php

示例6: beforeFind

 /**
  * beforeFind callback
  * 
  * @param object $Model
  * @param array $query
  */
 public function beforeFind(Model $Model, $query)
 {
     $Model->bindModel(array('hasOne' => array('Alias' => array('className' => 'Alias', 'foreignKey' => 'value', 'dependent' => true, 'conditions' => array('Alias.controller' => Inflector::tableize($Model->name)), 'fields' => '', 'order' => 'Alias.modified DESC'))), false);
     $query['contain'][] = 'Alias';
     $query['group'] = !empty($query['group']) ? $query['group'] : array($Model->alias => 'id');
     return parent::beforeFind($Model, $query);
 }
开发者ID:ajayphp,项目名称:Zuha,代码行数:13,代码来源:OptimizableBehavior.php

示例7: bindCartModel

 /**
  * Binds the cart association if no HABTM assoc named 'Cart' already exists.
  *
  * @param Model $Model
  * @return void
  */
 public function bindCartModel(Model $Model)
 {
     extract($this->settings[$Model->alias]);
     if (!isset($Model->hasAndBelongsToMany['Cart'])) {
         $Model->bindModel(array('hasAndBelongsToMany' => array('Cart' => array('className' => 'Cart.Cart', 'foreignKey' => 'foreign_key', 'associationForeignKey' => 'cart_id', 'joinTable' => 'carts_items', 'with' => 'Cart.CartsItem'))), false);
     }
 }
开发者ID:mikebirch,项目名称:cakephp-cart-plugin,代码行数:13,代码来源:BuyableBehavior.php

示例8: setup

 /**
  * Setup
  *
  * @param AppModel $Model
  * @param array $settings
  */
 public function setup(Model $Model, $settings = array())
 {
     if (!isset($this->settings[$Model->alias])) {
         $this->settings[$Model->alias] = $this->_defaults;
     }
     $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings);
     $this->settings[$Model->alias]['withModel'] = $this->settings[$Model->alias]['taggedClass'];
     $Model->bindModel(array('hasAndBelongsToMany' => array('Tag' => array('className' => $this->settings[$Model->alias]['tagClass'], 'foreignKey' => $this->settings[$Model->alias]['foreignKey'], 'associationForeignKey' => $this->settings[$Model->alias]['associationForeignKey'], 'unique' => true, 'conditions' => array('Tagged.model' => $Model->name), 'fields' => '', 'dependent' => true, 'with' => $this->settings[$Model->alias]['withModel']))), $this->settings[$Model->alias]['resetBinding']);
 }
开发者ID:neterslandreau,项目名称:bones,代码行数:15,代码来源:taggable.php

示例9: setup

 /**
  *
  * @param Model $Model
  * @param array $settings
  */
 public function setup(Model $Model, $settings = array())
 {
     // settings go here
     $this->settings[$Model->alias] = $settings;
     if (isset($this->settings[$Model->alias]['hasMany'])) {
         // our main $Model hasOne UserGroup
         $Model->bindModel(array('hasOne' => array('UserGroup' => array('className' => 'Users.UserGroup', 'foreignKey' => 'foreign_key', 'conditions' => array('UserGroup.model' => $Model->alias), 'dependent' => true))), false);
     }
 }
开发者ID:ayaou,项目名称:Zuha,代码行数:14,代码来源:UserGroupableBehavior.php

示例10: bindModelBbsArticlesUser

 /**
  * Set bindModel BbsArticlesUser
  *
  * @param object $model instance of model
  * @param bool $reset Set to false to make the binding permanent
  * @return void
  */
 public function bindModelBbsArticlesUser(Model $model, $reset)
 {
     if ($model->hasField('bbs_article_key')) {
         $field = 'bbs_article_key';
     } else {
         $field = 'key';
     }
     $model->bindModel(array('belongsTo' => array('BbsArticlesUser' => array('className' => 'Bbses.BbsArticlesUser', 'foreignKey' => false, 'conditions' => array('BbsArticlesUser.bbs_article_key = ' . $model->alias . '.' . $field, 'BbsArticlesUser.user_id' => Current::read('User.id'))))), $reset);
 }
开发者ID:Onasusweb,项目名称:Bbses,代码行数:16,代码来源:BbsArticlesUserBehavior.php

示例11: _setupBelongsTo

 /**
  * Bind relationship on the fly
  */
 protected function _setupBelongsTo(Model $model)
 {
     if (!empty($model->belongsTo['TrackableCreator'])) {
         return;
     }
     $config = $this->settings[$model->alias];
     list($plugin, $modelName) = pluginSplit($config['userModel']);
     $className = isset($plugin) ? $plugin . '.' . $modelName : $modelName;
     $model->bindModel(array('belongsTo' => array('TrackableCreator' => array('className' => $className, 'foreignKey' => $config['fields']['created_by']), 'TrackableUpdater' => array('className' => $className, 'foreignKey' => $config['fields']['updated_by']))), false);
 }
开发者ID:saydulk,项目名称:croogo,代码行数:13,代码来源:TrackableBehavior.php

示例12: setup

 /**
  * Behaviors Setup
  * Called before all actions
  *
  * @param  Model $model
  * @param  $config
  * @author Oleg
  */
 function setup(Model $model, $config = array())
 {
     $this->settings = $config;
     if (!isset($this->settings['required'])) {
         $this->settings['required'] = false;
     }
     $this->settings['baseDir'] = WWW_ROOT . 'img' . DS . $model->name . DS;
     $this->settings['thumbsDir'] = WWW_ROOT . 'img' . DS . $model->name . DS . 'thumbs' . DS;
     $model->bindModel(array('hasMany' => array('Image' => array('className' => 'Image', 'className' => 'Image', 'conditions' => 'model="' . $model->name . '"', 'order' => '', 'limit' => '', 'foreignKey' => 'model_id', 'dependent' => false, 'exclusive' => false, 'finderQuery' => ''))));
 }
开发者ID:sgh1986915,项目名称:cakephp2-bpong,代码行数:18,代码来源:ImageBehavior.php

示例13: setup

 /**
  * Setup
  *
  * @param AppModel $model
  * @param array $settings
  */
 public function setup(Model $model, $settings = array())
 {
     if (!isset($this->settings[$model->alias])) {
         $this->settings[$model->alias] = $this->defaults;
     }
     $this->settings[$model->alias] = am($this->settings[$model->alias], !empty(is_array($settings)) ? $settings : array());
     $cfg = $this->settings[$model->alias];
     $model->bindModel(array('hasMany' => array($cfg['commentAlias'] => array('className' => $cfg['commentModel'], 'foreignKey' => 'foreign_key', 'unique' => true, 'conditions' => '', 'fields' => '', 'dependent' => true, 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => ''))), false);
     $model->{$cfg['commentAlias']}->bindModel(array('belongsTo' => array($model->alias => array('className' => $model->name, 'foreignKey' => 'foreign_key', 'unique' => true, 'conditions' => '', 'fields' => '', 'counterCache' => true, 'dependent' => false))), false);
     $model->{$cfg['commentAlias']}->bindModel(array('belongsTo' => array($cfg['userModelAlias'] => array('className' => $cfg['userModelClass'], 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'counterCache' => true, 'order' => ''))), false);
 }
开发者ID:rodrigorm,项目名称:comments,代码行数:17,代码来源:BlackHoleException.php

示例14: setup

 /**
  * Setup
  *
  * @param Model $model
  * @param array $config
  * @return void
  */
 public function setup(Model $model, $config = array())
 {
     if (is_string($config)) {
         $config = array($config);
     }
     $this->settings[$model->alias] = $config;
     $model->bindModel(array('hasMany' => array('Meta' => array('className' => 'Meta.Meta', 'foreignKey' => 'foreign_key', 'dependent' => true, 'conditions' => array('Meta.model' => $model->alias), 'order' => 'Meta.key ASC'))), false);
     $callback = array($this, 'onBeforeSaveNode');
     $eventManager = $model->getEventManager();
     $eventManager->attach($callback, 'Model.Node.beforeSaveNode');
 }
开发者ID:saydulk,项目名称:croogo,代码行数:18,代码来源:MetaBehavior.php

示例15: setupHabtmRelations

 /**
  * Setup HABTM relations
  * 
  * @author	Anthony Putignano <anthony@wizehive.com>
  * @since	1.0
  * @param	Model		$Model
  * @return	void
  */
 public function setupHabtmRelations(Model $Model)
 {
     $associated = $Model->getAssociated();
     foreach ($this->__settings[$Model->alias]['fields'] as $field => $settings) {
         extract($settings);
         if (!array_key_exists($joinModel, $associated)) {
             // This relation takes care of deletions for us
             $Model->bindModel(array('hasMany' => array($joinModel => array('className' => $joinModel, 'foreignKey' => $foreignKey, 'dependent' => true, 'request' => true))));
         }
     }
 }
开发者ID:manzapanza,项目名称:cakephp-api-utils,代码行数:19,代码来源:VirtualHabtmBehavior.php


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