當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。