本文整理汇总了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;
}
}
示例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]);
}
示例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');
}
}
示例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;
}
示例5: init
public function init()
{
parent::init();
$this->behavior = $this->model->getBehavior($this->behaviorName);
$this->registerTranslations();
}
示例6: init
public function init()
{
parent::init();
$this->behavior = $this->model->getBehavior($this->behaviorName);
}
示例7: getAttachmentBehavior
/**
* @return ImageAttachmentBehavior
*/
public function getAttachmentBehavior()
{
return $this->model->getBehavior($this->behaviorName);
}