當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ActiveRecord::getBehavior方法代碼示例

本文整理匯總了PHP中yii\db\ActiveRecord::getBehavior方法的典型用法代碼示例。如果您正苦於以下問題:PHP ActiveRecord::getBehavior方法的具體用法?PHP ActiveRecord::getBehavior怎麽用?PHP ActiveRecord::getBehavior使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::getBehavior方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: run

 public function run($action)
 {
     $this->type = Yii::$app->request->get('type');
     $this->behaviorName = Yii::$app->request->get('behaviorName');
     $this->galleryId = Yii::$app->request->get('galleryId');
     $pkNames = call_user_func([$this->types[$this->type], 'primaryKey']);
     $pkValues = explode($this->pkGlue, $this->galleryId);
     $pk = array_combine($pkNames, $pkValues);
     $this->owner = call_user_func([$this->types[$this->type], 'findOne'], $pk);
     $this->behavior = $this->owner->getBehavior($this->behaviorName);
     switch ($action) {
         case 'delete':
             return $this->actionDelete(Yii::$app->request->post('id'));
             break;
         case 'ajaxUpload':
             return $this->actionAjaxUpload();
             break;
         case 'changeData':
             return $this->actionChangeData(Yii::$app->request->post('photo'));
             break;
         case 'order':
             return $this->actionOrder(Yii::$app->request->post('order'));
             break;
         default:
             throw new HttpException(400, 'Action do not exists');
             break;
     }
 }
開發者ID:tamvodopad,項目名稱:yii2-gallery-manager,代碼行數:28,代碼來源:GalleryManagerAction.php

示例2: run

 /**
  * @return null|string
  */
 public function run()
 {
     /**
      * @var \notgosu\yii2\modules\metaTag\components\MetaTagBehavior $behavior
      */
     $behavior = $this->model->getBehavior('seo');
     if (!$behavior) {
         return null;
     }
     $languageList = $behavior->languages;
     return $this->render('default', ['model' => $this->model, 'languageList' => $languageList]);
 }
開發者ID:walter-007,項目名稱:yii2-meta-tag-module,代碼行數:15,代碼來源:Widget.php

示例3: run

 public function run($action)
 {
     $this->type = Yii::$app->request->get('type');
     $this->behaviorName = Yii::$app->request->get('behaviorName');
     $this->galleryId = Yii::$app->request->get('galleryId');
     $this->owner = $this->types[$this->type]->andWhere(['id' => $this->galleryId])->one();
     if ($this->owner == null) {
         throw new NotFoundHttpException('Gallery not found.');
     }
     $this->behavior = $this->owner->getBehavior($this->behaviorName);
     switch ($action) {
         case 'delete':
             return $this->actionDelete(Yii::$app->request->post('id'));
         case 'ajaxUpload':
             return $this->actionAjaxUpload();
         case 'changeData':
             return $this->actionChangeData(Yii::$app->request->post('photo'));
         case 'order':
             return $this->actionOrder(Yii::$app->request->post('order'));
         default:
             throw new BadRequestHttpException('Action do not exists');
     }
 }
開發者ID:bupy7,項目名稱:yii2-gallery-manager,代碼行數:23,代碼來源:GalleryManagerAction.php

示例4: copyFiles

 /**
  *
  * @param array $attributes
  * @param ActiveRecord $destination Destination model
  * @return boolean
  */
 public function copyFiles($attributes, $destination)
 {
     foreach ($attributes as $attribute) {
         $behavior = $destination->getBehavior('upload-' . $attribute);
         if ($this->getUploadedFilePath($attribute) != '') {
             $filePath = pathinfo($behavior->getUploadedFilePath($attribute), PATHINFO_DIRNAME);
             if (!FileHelper::createDirectory($filePath, 0775, true)) {
                 return false;
             }
             copy($this->getUploadedFilePath($attribute), $behavior->getUploadedFilePath($attribute));
             foreach ($behavior->thumbs as $profile => $config) {
                 $thumbPath = $behavior->getThumbFilePath($attribute, $profile);
                 FileHelper::createDirectory(pathinfo($thumbPath, PATHINFO_DIRNAME), 0775, true);
                 copy($this->getThumbFilePath($attribute, $profile), $thumbPath);
             }
         }
     }
     return true;
 }
開發者ID:vitalik74,項目名稱:gosman-test-app,代碼行數:25,代碼來源:ExtendedImageUploadBehavior.php

示例5: init

 public function init()
 {
     parent::init();
     $this->behavior = $this->model->getBehavior($this->behaviorName);
     $this->registerTranslations();
 }
開發者ID:tamvodopad,項目名稱:yii2-gallery-manager,代碼行數:6,代碼來源:GalleryManager.php

示例6: init

 public function init()
 {
     parent::init();
     $this->behavior = $this->model->getBehavior($this->behaviorName);
 }
開發者ID:porcelanosa,項目名稱:yii2-seo-attributes,代碼行數:5,代碼來源:SeoWidget.php

示例7: getAttachmentBehavior

 /**
  * @return ImageAttachmentBehavior
  */
 public function getAttachmentBehavior()
 {
     return $this->model->getBehavior($this->behaviorName);
 }
開發者ID:tamvodopad,項目名稱:yii2-image-attachment,代碼行數:7,代碼來源:ImageAttachmentWidget.php


注:本文中的yii\db\ActiveRecord::getBehavior方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。