예제 #1
0
 /**
  * @inheritdoc
  */
 public function bootstrap($app)
 {
     parent::bootstrap($app);
     // Subscribe on model changes
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_INSERT, function ($event) {
         CometModule::getInstance()->neat->server->broadcastEvent(get_class($event->sender), 'sendAdd', $event->sender->attributes);
     });
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_UPDATE, function ($event) {
         CometModule::getInstance()->neat->server->broadcastEvent(get_class($event->sender), 'sendUpdate', $event->sender->attributes, $event->changedAttributes + $event->sender->oldAttributes);
     });
     Event::on(ActiveRecord::className(), ActiveRecord::EVENT_AFTER_DELETE, function ($event) {
         CometModule::getInstance()->neat->server->broadcastEvent(get_class($event->sender), 'sendRemove', $event->sender->attributes);
     });
 }
예제 #2
0
 public function init()
 {
     parent::init();
     // Default processors
     $this->processors = ArrayHelper::merge([self::PROCESSOR_NAME_ORIGINAL => ['class' => '\\app\\file\\processors\\ImageResize', 'width' => 1920, 'height' => 1200], self::PROCESSOR_NAME_DEFAULT => ['class' => '\\app\\file\\processors\\ImageResize', 'width' => 100, 'height' => 100]], $this->processors);
     // Normalize and set default dir
     if ($this->filesRootPath === null) {
         $this->filesRootPath = dirname(\Yii::$app->getRequest()->getScriptFile()) . '/assets/';
     } else {
         $this->filesRootPath = rtrim($this->filesRootPath, '/') . '/';
     }
     if ($this->filesRootUrl === null) {
         $this->filesRootUrl = \Yii::getAlias('@web', false) . '/assets/';
     } else {
         $this->filesRootUrl = rtrim($this->filesRootUrl, '/') . '/';
     }
 }