You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- <?php
-
- namespace common\logic;
-
- abstract class AbstractRepository extends AbstractService implements RepositoryInterface
- {
- const WITH = 'with';
- const JOIN_WITH = 'join_with';
- const ORDER_BY = 'orderby';
- const ATTRIBUTE_ID_PRODUCER = 'attribute_id_producer';
-
- public function loadQuery(string $serviceClass)
- {
- $this->query = $this->loadService($serviceClass);
- }
-
- public function createQuery()
- {
- $this->query->createQuery();
-
- return $this->query;
- }
-
- public function createDefaultQuery(): RepositoryQueryInterface
- {
- $this->createQuery();
-
- $defaultOptions = $this->getDefaultOptionsSearch();
-
- // with
- if (is_array($defaultOptions['with']) && count($defaultOptions['with'])) {
- $this->query->with($defaultOptions['with']);
- }
-
- // join with
- if (is_array($defaultOptions['join_with']) && count($defaultOptions['join_with'])) {
- $this->query->joinWith($defaultOptions['join_with']);
- }
-
- // id producer contexte
- if(isset($defaultOptions['attribute_id_producer']) && $defaultOptions['attribute_id_producer']) {
- $this->query->andWhere([$defaultOptions['attribute_id_producer'] => $this->getProducerContextId()]);
- }
-
- // order by
- if(isset($defaultOptions['orderby']) && $defaultOptions['orderby']) {
- $this->query->orderBy($defaultOptions['orderby']);
- }
-
- return $this->query;
- }
- }
|