コード例 #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;
 }
コード例 #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;
 }
コード例 #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => PolymorphicRelation::className(), 'mustBeInstanceOf' => array(ContentContainerActiveRecord::className()), 'classAttribute' => 'class', 'pkAttribute' => 'pk']];
 }
コード例 #4
0
ファイル: Activity.php プロジェクト: honestgorillas/humhub
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => \humhub\components\behaviors\PolymorphicRelation::className(), 'mustBeInstanceOf' => [ContentActiveRecord::className(), ContentContainerActiveRecord::className(), ContentAddonActiveRecord::className()]]];
 }