当前位置: 首页>>代码示例>>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;未经允许,请勿转载。