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


PHP Model::getBehaviors方法代码示例

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


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

示例1: findVariationModelBatches

 /**
  * @param Model|ActiveRecordInterface $model
  * @return array list of variation models in format: behaviorName => Model[]
  */
 protected function findVariationModelBatches($model)
 {
     $variationModels = [];
     foreach ($model->getBehaviors() as $name => $behavior) {
         if (empty($this->variationNames) && $behavior instanceof VariationBehavior || in_array($name, $this->variationNames)) {
             $variationModels[$name] = $behavior->getVariationModels();
         }
     }
     return $variationModels;
 }
开发者ID:Ryadnov,项目名称:admin,代码行数:14,代码来源:VariationTrait.php

示例2: findRoleModels

 /**
  * @param Model|ActiveRecordInterface $model
  * @return array list of variation models in format: behaviorName => Model[]
  */
 private function findRoleModels($model)
 {
     $roleModels = [];
     foreach ($model->getBehaviors() as $name => $behavior) {
         if (empty($this->roleNames) && $behavior instanceof \yii2tech\ar\role\RoleBehavior || in_array($name, $this->roleNames)) {
             $roleModels[$name] = $behavior->getRoleRelationModel();
         }
     }
     return $roleModels;
 }
开发者ID:yii2tech,项目名称:admin,代码行数:14,代码来源:RoleBehavior.php

示例3: isAttachedTo

 /**
  * Tests that a ActiveWorkflowBehavior behavior is attached to the object passed as argument.
  *
  * This method returns FALSE if $model is not an instance of BaseActiveRecord (has ActiveWorkflowBehavior can only be attached
  * to instances of this class) or if none of its attached behaviors is a or inherit from ActiveWorkflowBehavior.
  *
  * @param Model|ActiveWorkflowBehavior $model the model to test.
  * @return bool TRUE if at least one ActiveWorkflowBehavior behavior is attached to $model, FALSE otherwise
  * @throws WorkflowException
  */
 public static function isAttachedTo($model)
 {
     if ($model instanceof Model) {
         foreach ($model->getBehaviors() as $behavior) {
             if ($behavior instanceof ActiveWorkflowBehavior) {
                 return true;
             }
         }
     } else {
         throw new WorkflowException('Invalid argument type : $model must be an instance of yii\\base\\Model');
     }
     return false;
 }
开发者ID:fproject,项目名称:workflowii,代码行数:23,代码来源:ActiveWorkflowBehavior.php


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