Esempio n. 1
0
 /**
  * Limits the returned records to the given ContentContainer.
  * 
  * @param ContentContainerActiveRecord $container
  * @return \humhub\modules\content\components\ActiveQueryContent
  * @throws \yii\base\Exception
  */
 public function contentContainer($container)
 {
     $this->joinWith(['content', 'content.user', 'content.space']);
     if ($container->className() == Space::className()) {
         $this->andWhere(['content.space_id' => $container->id]);
     } elseif ($container->className() == User::className()) {
         $this->andWhere(['content.user_id' => $container->id]);
         $this->andWhere('content.space_id IS NULL OR content.space_id = ""');
     } else {
         throw new \yii\base\Exception("Invalid container given!");
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Limits the returned records to the given ContentContainer.
  * 
  * @param ContentContainerActiveRecord $container
  * @return \humhub\modules\content\components\ActiveQueryContent
  * @throws \yii\base\Exception
  */
 public function contentContainer($container)
 {
     $this->joinWith(['content', 'content.contentContainer', 'content.createdBy']);
     $this->andWhere(['contentcontainer.pk' => $container->id, 'contentcontainer.class' => $container->className()]);
     return $this;
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => PolymorphicRelation::className(), 'mustBeInstanceOf' => array(ContentContainerActiveRecord::className()), 'classAttribute' => 'class', 'pkAttribute' => 'pk']];
 }
Esempio n. 4
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentContainerActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }