Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->className() == Album::className()) {
         $this->visible = 1;
     }
 }
Esempio n. 2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->isNewRecord && $this->className() == Trip::className()) {
         $this->type = 2;
         $this->vehicle = 2;
     }
 }
Esempio n. 3
0
 public function init()
 {
     parent::init();
     if ($this->isNewRecord && $this->className() == 'yeesoft\\seo\\models\\Seo') {
         $this->index = 1;
         $this->follow = 1;
     }
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->isNewRecord && $this->className() == Post::className()) {
         $this->published_at = time();
     }
     $this->on(self::EVENT_BEFORE_UPDATE, [$this, 'updateRevision']);
     $this->on(self::EVENT_AFTER_UPDATE, [$this, 'saveTags']);
     $this->on(self::EVENT_AFTER_INSERT, [$this, 'saveTags']);
 }
Esempio n. 5
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     if (!$this->model) {
         $this->model = new Media();
     }
     if ($this->ownerModel && !$this->inputContainer) {
         $this->inputContainer = '#' . Html::getInputId($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     if ($this->ownerModel && !$this->inputName) {
         $this->inputName = Html::getInputName($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     $this->clientOptions = ['autoUpload' => true, 'previewMaxWidth' => 120, 'previewMaxHeight' => 120, 'previewCrop' => true];
     $this->gallery = false;
     if ($this->baseUrl) {
         $this->url = $this->baseUrl . '/upload';
     }
     parent::init();
 }
Esempio n. 6
0
 /**
  *
  * @inheritdoc
  */
 public function save($runValidation = true, $attributeNames = null)
 {
     $parent = null;
     if (isset($this->parent_id) && $this->parent_id) {
         $parent = Category::findOne((int) $this->parent_id);
     }
     if (!$parent) {
         $parent = Category::findOne(1);
     }
     if (!$parent) {
         throw new \yii\base\InvalidParamException();
     }
     $this->appendTo($parent);
     try {
         return parent::save($runValidation, $attributeNames);
     } catch (yii\base\Exception $exc) {
         \Yii::$app->session->setFlash('crudMessage', $exc->getMessage());
     }
 }
Esempio n. 7
0
 /**
  * @inheritdoc
  */
 public function scenarios()
 {
     $scenarios = parent::scenarios();
     $scenarios[self::SCENARIO_AUTOGENERATED] = ['title', 'slug'];
     return $scenarios;
 }
Esempio n. 8
0
 /**
  * Invalidate permissions if some item is deleted
  */
 public function afterDelete()
 {
     parent::afterDelete();
     AuthHelper::invalidatePermissions();
 }