isJoinUsers) { $this->isJoinUsers = true; return $this ->leftJoin('.users', 'pf_users') ->addSelect('pf_users') ; } return $this; } public function joinGroupUsers() { if (!$this->isJoinGroupUsers) { $this->isJoinGroupUsers = true; return $this ->leftJoin('.groupUsers', 'pf_groupusers') ->addSelect('pf_groupusers') ; } return $this; } public function joinProductFamilies() { if (!$this->isJoinProductFamilies) { $this->isJoinProductFamilies = true; return $this ->leftJoin('.productFamilies', 'pfs') ->addSelect('pfs') ; } return $this; } public function joinProductFamily() { if (!$this->isJoinProductFamily) { $this->isJoinProductFamily = true; return $this ->leftJoin('.productFamily', 'pf') ->addSelect('pf') ; } return $this; } public function joinProductCategories() { if (!$this->isJoinProductCategories) { $this->isJoinProductCategories = true; return $this ->leftJoin('.productCategories', 'pcs') ->addSelect('pcs') ; } return $this; } public function filterProductFamily(ProductFamilyInterface $productFamily) { return $this ->andWhere('.productFamily = :productFamily') ->setParameter(':productFamily', $productFamily); } public function filterConditionDate() { return $this ->andWhere('.permanent = 1 OR ( .dateStart <= :now AND .dateEnd >= :now)') ->setParameter(':now', new \DateTime()); } public function filterConditionUser(UserInterface $user = null) { $this->joinUsers(); if ($user) { return $this ->andWhere(':user MEMBER OF .users OR .users is empty') ->setParameter('user', $user); } else { return $this ->andWhere('.users is empty'); } } public function filterConditionGroupUser(UserInterface $user = null) { $this->joinGroupUsers(); if ($user) { return $this ->andWhere(':groupUser MEMBER OF .groupUsers OR .groupUsers is empty') ->setParameter('groupUser', $user->getGroupUsers()); } else { return $this ->andWhere('.groupUsers is empty'); } } public function filterConditionProductFamilies(array $productFamilies) { $this->joinProductFamilies(); $this->joinProductFamily(); return $this ->andWhere(':productFamilies MEMBER OF .productFamilies OR .productFamilies is empty') ->setParameter('productFamilies', $productFamilies); } public function filterConditionProductFamily(ProductFamilyInterface $productFamily) { $this->joinProductFamilies(); $this->joinProductFamily(); return $this ->andWhere(':productFamily MEMBER OF .productFamilies OR .productFamilies is empty') ->setParameter('productFamily', $productFamily); } public function filterConditionProductCategories(array $productCategories) { $this->joinProductCategories(); return $this ->andWhere(':productCategory MEMBER OF .productCategories OR .productCategories is empty') ->setParameter('productCategory', $productCategories); } }