return $this; | return $this; | ||||
} | } | ||||
/** | |||||
* @deprecated Utiliser setFormTypeOption('choices', $choices) avec $choices issu d'un Store. | |||||
*/ | |||||
public function initQueryBuilder(): self | public function initQueryBuilder(): self | ||||
{ | { | ||||
$param = $this->queryBuilderParameters; | $param = $this->queryBuilderParameters; |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | use Lc\SovBundle\Model\Site\PageModel as SovPageModel; | ||||
*/ | */ | ||||
abstract class PageModel extends SovPageModel implements FilterSectionInterface | abstract class PageModel extends SovPageModel implements FilterSectionInterface | ||||
{ | { | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | ||||
* @ORM\JoinColumn(nullable=false) | |||||
* @ORM\JoinColumn(nullable=true) | |||||
*/ | */ | ||||
protected $section; | protected $section; | ||||
public function getMerchant(): ?MerchantInterface | |||||
{ | |||||
return $this->merchant; | |||||
} | |||||
public function setMerchant(?MerchantInterface $merchant): self | |||||
{ | |||||
$this->merchant = $merchant; | |||||
return $this; | |||||
} | |||||
public function getSection(): SectionInterface | public function getSection(): SectionInterface | ||||
{ | { | ||||
return $this->section; | return $this->section; | ||||
return $this; | return $this; | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Site; | namespace Lc\CaracoleBundle\Repository\Site; | ||||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | use Lc\SovBundle\Repository\Site\PageRepositoryQuery as SovPageRepositoryQuery; | ||||
class PageRepositoryQuery extends SovPageRepositoryQuery | class PageRepositoryQuery extends SovPageRepositoryQuery | ||||
{ | { | ||||
use MerchantRepositoryQueryTrait; | |||||
use SectionRepositoryQueryTrait; | use SectionRepositoryQueryTrait; | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Site; | namespace Lc\CaracoleBundle\Repository\Site; | ||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\SovBundle\Model\Site\PageInterface; | use Lc\SovBundle\Model\Site\PageInterface; | ||||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | use Lc\SovBundle\Repository\RepositoryQueryInterface; | ||||
class PageStore extends SovPageStore | class PageStore extends SovPageStore | ||||
{ | { | ||||
use MerchantStoreTrait; | |||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
public function __construct(PageRepositoryQuery $query) | public function __construct(PageRepositoryQuery $query) | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
$this->addFilterByMerchantOptionnal($query); | |||||
$this->addFilterBySectionOptionnal($query); | |||||
return parent::filtersDefault($query); | return parent::filtersDefault($query); | ||||
} | } | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterByMerchant($this->merchant); | |||||
$this->addFilterByMerchantOptionnal($query); | |||||
return parent::filtersDefault($query); | return parent::filtersDefault($query); | ||||
} | } | ||||
} | } |