Esempio n. 1
0
<?php

use humhub\modules\search\engine\Search;
use humhub\modules\user\Events;
use humhub\commands\IntegrityController;
use humhub\modules\content\components\ContentAddonActiveRecord;
use humhub\modules\content\components\ContentActiveRecord;
use humhub\commands\CronController;
return ['id' => 'user', 'class' => \humhub\modules\user\Module::className(), 'isCoreModule' => true, 'urlManagerRules' => [['class' => 'humhub\\modules\\user\\components\\UrlRule']], 'events' => [['class' => Search::className(), 'event' => Search::EVENT_ON_REBUILD, 'callback' => array(Events::className(), 'onSearchRebuild')], ['class' => ContentActiveRecord::className(), 'event' => ContentActiveRecord::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onContentDelete')], ['class' => ContentAddonActiveRecord::className(), 'event' => ContentAddonActiveRecord::EVENT_BEFORE_DELETE, 'callback' => array(Events::className(), 'onContentDelete')], ['class' => IntegrityController::className(), 'event' => IntegrityController::EVENT_ON_RUN, 'callback' => array(Events::className(), 'onIntegrityCheck')], ['class' => CronController::className(), 'event' => CronController::EVENT_ON_HOURLY_RUN, 'callback' => [Events::className(), 'onHourlyCron']]]];
 /**
  * Loads Content Addon
  * We also validates that the content addon corresponds to the loaded content.
  *
  * @param string $className
  * @param int $pk
  */
 public function loadContentAddon($className, $pk)
 {
     if (!\humhub\libs\Helpers::CheckClassType($className, ContentAddonActiveRecord::className())) {
         throw new \yii\base\Exception("Given className is not a content addon model!");
     }
     $target = $className::findOne(['id' => $pk]);
     if ($target === null) {
         throw new HttpException(500, 'Could not find content addon record!');
     }
     if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) {
         throw new HttpException(500, 'Content addon not belongs to given content record!');
     }
     $this->contentAddon = $target;
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }