Exemple #1
0
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'nombre', 'immutable' => true, 'ensureUnique' => true], 'sitemap' => ['class' => SitemapBehavior::className(), 'scope' => function ($model) {
         /** @var \yii\db\ActiveQuery $model */
         $model->select(['municipios.slug']);
     }, 'dataClosure' => function ($model) {
         /** @var self $model */
         return ['loc' => Url::to($model->slug, true), 'changefreq' => SitemapBehavior::CHANGEFREQ_NEVER, 'priority' => 0.5];
     }]];
 }
Exemple #2
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['timestamp' => TimestampBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'name'], 'tree' => ['class' => NestedSetsBehavior::className(), 'treeAttribute' => 'tree'], 'files' => ['class' => FilesBehavior::className(), 'attributes' => ['uploadedImage' => ['filesystem' => 'local', 'path' => '/categories', 'fileName' => '{model.slug}.{file.extension}', 'relation' => 'image', 'deleteOnUnlink' => true, 'on beforeSave' => function (FileInterface $file) {
         $image = ImageManagerStatic::make($file->getPath());
         $image->resize(400, null, function (Constraint $constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         $image->save($file->getPath(), 100);
     }]]], 'relations' => ['class' => RelationsBehavior::className(), 'settings' => ['image' => ['deleteOnUnlink' => true]], 'relations' => ['imageRelation' => $this->hasOne(CategoryFile::className(), ['id' => 'image_id'])]]];
 }
 public function behaviors()
 {
     $behaviors = ['sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true, "immutable" => true], SetMaxSortableModel::className()];
     $behaviors['timestamp'] = TimestampBehavior::className();
     $behaviors['published_at'] = ['class' => \hass\base\behaviors\StrToTimeBehavior::className(), "attribute" => "published_at"];
     $behaviors["meta"] = MetaBehavior::className();
     $behaviors["thumbnailFile"] = ['class' => \hass\attachment\behaviors\UploadBehavior::className(), 'attribute' => 'thumbnail'];
     $behaviors["textEditor"] = ['class' => \hass\base\misc\editor\EditorBehavior::className(), 'attribute' => 'content'];
     $behaviors["TimestampFormatter"] = TimestampFormatter::className();
     $behaviors["commentEnabled"] = ['class' => CommentBehavior::className(), 'defaultStatus' => CommentEnabledEnum::STATUS_ON];
     return $behaviors;
 }
Exemple #4
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'timestamp' => TimestampBehavior::className(), 'files' => ['class' => FilesBehavior::className(), 'attributes' => ['uploadedImages' => ['filesystem' => 'local', 'path' => '/products/{model.id}', 'fileName' => '{model.slug}.{file.extension}', 'multiple' => true, 'relation' => 'images', 'on beforeSave' => function (FileInterface $file) {
         $image = ImageManagerStatic::make($file->getPath());
         $image->resize(1000, null, function (Constraint $constraint) {
             $constraint->aspectRatio();
             $constraint->upsize();
         });
         $image->save($file->getPath(), 100);
     }, 'on afterDeleteAll' => function (StorageConfig $config, FilesystemComponent $filesystemComponent) {
         $path = $config->resolvePath($this);
         $filesystemComponent->deleteDirectory($path, $config->filesystem);
     }]]], 'relations' => ['class' => RelationsBehavior::className(), 'settings' => ['relatedEAttributes' => ['deleteOnUnlink' => true], 'images' => ['deleteOnUnlink' => true, 'extraColumns' => ['attribute' => 'images']]], 'relations' => ['imagesRelation' => $this->hasMany(ProductFile::className(), ['product_id' => 'id'])->where(['attribute' => 'images'])]]];
 }
Exemple #5
0
 public function behaviors()
 {
     $behaviors = ['sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true, "immutable" => true]];
     $behaviors['author_id'] = ['class' => BlameableBehavior::className(), 'attributes' => [static::EVENT_BEFORE_INSERT => 'author_id']];
     $behaviors['timestamp'] = TimestampBehavior::className();
     $behaviors['published_at'] = ['class' => StrToTimeBehavior::className(), 'attribute' => 'published_at'];
     $behaviors['taggabble'] = Taggable::className();
     $behaviors['meta'] = MetaBehavior::className();
     $behaviors['thumbnailFile'] = ['class' => \hass\attachment\behaviors\UploadBehavior::className(), 'attribute' => 'thumbnail'];
     $behaviors['taxonomy'] = ['class' => TaxonomyBehavior::className()];
     $behaviors['textEditor'] = ['class' => \hass\base\misc\editor\EditorBehavior::className(), 'attribute' => 'content'];
     $behaviors['TimestampFormatter'] = TimestampFormatter::className();
     $behaviors['commentEnabled'] = ['class' => CommentBehavior::className(), 'defaultStatus' => CommentEnabledEnum::STATUS_ON];
     return $behaviors;
 }
Exemple #6
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [BlameableBehavior::className(), TimestampBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title'], 'multilingual' => ['class' => MultilingualBehavior::className(), 'langForeignKey' => 'post_category_id', 'tableName' => "{{%post_category_lang}}", 'attributes' => ['title', 'description']], 'nestedInterval' => ['class' => NestedIntervalsBehavior::className(), 'leftAttribute' => 'left_border', 'rightAttribute' => 'right_border', 'amountOptimize' => '25', 'noPrepend' => true]];
 }
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'name'], 'timestamp' => ['class' => TimestampBehavior::className()], ['class' => BlameableBehavior::className()]];
 }
Exemple #8
0
 public function behaviors()
 {
     return ['timestamp' => ['class' => 'yii\\behaviors\\TimestampBehavior', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']], 'value' => new Expression('NOW()')], 'blameable' => ['class' => \yii\behaviors\BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by'], ['class' => SluggableBehavior::className(), 'attribute' => 'titulo', 'slugAttribute' => 'seo_slug']];
 }
Exemple #9
0
 public function behaviors()
 {
     return ['timestamp' => ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created', 'updated'], ActiveRecord::EVENT_BEFORE_UPDATE => 'updated'], 'value' => function () {
         return date('U');
     }], 'alias' => ['class' => SluggableBehavior::className(), 'attribute' => 'name', 'slugAttribute' => 'alias'], 'image' => ['class' => 'app\\behaviors\\ImageBehavior']];
 }
Exemple #10
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['tree' => ['class' => NestedSetsBehavior::className(), 'treeAttribute' => 'tree'], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'alias', 'immutable' => true]];
 }
Exemple #11
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'post_title', 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['post_slug']]]];
 }
Exemple #12
0
 public function behaviors()
 {
     return [SortableModel::className(), 'seo' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by']];
 }
Exemple #13
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'author_id', 'updatedByAttribute' => 'updater_id'], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'financeAttachments'], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url'], ['class' => ChangeLogBehavior::className()]];
 }
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true]];
 }
Exemple #15
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true, 'ensureUnique' => true], ['class' => TimestampBehavior::className(), 'value' => new Expression('UTC_TIMESTAMP()')], ['class' => FileBehavior::className(), 'folderName' => 'common']];
 }
Exemple #16
0
 public function behaviors()
 {
     return array_merge(parent::behaviors(), ['sluggable' => ['class' => \yii\behaviors\SluggableBehavior::className(), 'slugAttribute' => 'alias', 'attribute' => 'title'], 'linkable' => ['class' => \app\components\models\LinkableBehavior::className(), 'urlPath' => '/' . \Yii::$app->lang->get() . '/news/']]);
 }
Exemple #17
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), BlameableBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => ['title', 'alias'], 'slugAttribute' => 'alias', 'ensureUnique' => true], ['class' => EditorBehavior::className(), 'introAttribute' => 'intro_content', 'contentAttribute' => 'content', 'purifyContent' => true]];
 }
Exemple #18
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [BlameableBehavior::className(), TimestampBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => 'name', 'ensureUnique' => true], 'builderField' => ['class' => JsonToArrayBehavior::className(), 'jsonFieldName' => 'builder']];
 }
Exemple #19
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['authorBehavior' => ['class' => AuthorBehavior::className()], 'sluggableBehavior' => ['class' => SluggableBehavior::className(), 'attribute' => 'name', 'slugAttribute' => 'slug', 'ensureUnique' => true], 'timestampBehavior' => ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'createdAt', 'updatedAtAttribute' => 'modifiedAt', 'value' => new Expression('NOW()')]];
 }
Exemple #20
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'slug', 'slugAttribute' => 'slug', 'ensureUnique' => true], ['class' => TimestampBehavior::className()], ['class' => BlameableBehavior::className()]];
 }
Exemple #21
0
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className()], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true, 'ensureUnique' => true], ['class' => FileBehavior::className(), 'attribute' => 'image']];
 }
Exemple #22
0
 public function behaviors()
 {
     return ['cacheflush' => ['class' => CacheFlush::className(), 'key' => [static::tableName() . '_tree', static::tableName() . '_flat']], 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'tree' => ['class' => NestedSetsBehavior::className(), 'treeAttribute' => 'tree'], 'timestamp' => ['class' => TimestampBehavior::className()], 'blame' => ['class' => BlameableBehavior::className()], 'audit' => ['class' => ARLogBehavior::className()]];
 }
Exemple #23
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [BlameableBehavior::className(), TimestampBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title'], 'multilingual' => ['class' => MultilingualBehavior::className(), 'langForeignKey' => 'media_album_id', 'tableName' => "{{%media_album_lang}}", 'attributes' => ['title', 'description']]];
 }
Exemple #24
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => 'name']];
 }
Exemple #25
0
 public function behaviors()
 {
     return ['cacheflush' => ['class' => CacheFlush::className(), 'key' => [static::tableName() . '_tree', static::tableName() . '_flat']], 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'tree' => ['class' => NestedSetsBehavior::className(), 'treeAttribute' => 'tree']];
 }
Exemple #26
0
 public function behaviors()
 {
     return [SortableModel::className(), 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true]];
 }
Exemple #27
0
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'title'], TimestampBehavior::className()];
 }
Exemple #28
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'author_id', 'updatedByAttribute' => 'updater_id'], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'articleAttachments', 'pathAttribute' => 'path', 'baseUrlAttribute' => 'base_url', 'orderAttribute' => 'order', 'typeAttribute' => 'type', 'sizeAttribute' => 'size', 'nameAttribute' => 'name'], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url']];
 }
Exemple #29
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'name', 'ensureUnique' => true, 'immutable' => true]];
 }
Exemple #30
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [BlameableBehavior::className(), TimestampBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => 'name', 'ensureUnique' => true]];
 }