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.

AbstractStore.php 2.9KB

3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
3 yıl önce
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. namespace Lc\SovBundle\Repository;
  3. use Lc\SovBundle\Doctrine\EntityInterface;
  4. use Lc\SovBundle\Model\Site\PageInterface;
  5. abstract class AbstractStore implements StoreInterface
  6. {
  7. public function createDefaultQuery(RepositoryQueryInterface $query = null): RepositoryQueryInterface
  8. {
  9. $query = $this->createQuery($query);
  10. $this->filtersDefault($query);
  11. $this->relationsDefault($query);
  12. $this->orderByDefault($query);
  13. return $query;
  14. }
  15. public function createQuery(RepositoryQueryInterface $query = null): RepositoryQueryInterface
  16. {
  17. if (is_null($query)) {
  18. $query = $this->query->create();
  19. }
  20. return $query;
  21. }
  22. /*
  23. public function orderByDefault(RepositoryQueryInterface $query)
  24. {
  25. return $query;
  26. }
  27. public function filtersDefault(RepositoryQueryInterface $query)
  28. {
  29. $query->filterIsOnlineAndOffline();
  30. return $query;
  31. }
  32. public function relationsDefault($query)
  33. {
  34. return $query;
  35. }
  36. */
  37. public function getRepositoryQuery()
  38. {
  39. return $this->query;
  40. }
  41. public function getOneById(int $id)
  42. {
  43. $query = $this->query->create();
  44. $query->filterById($id);
  45. return $query->findOne();
  46. }
  47. public function getOneBySlug(string $slug, bool $isOnline = true, $query = null)
  48. {
  49. $query = $this->createDefaultQuery($query);
  50. $query->filterBySlug($slug);
  51. if ($isOnline) {
  52. $query->filterIsOnline();
  53. }
  54. return $query->findOne();
  55. }
  56. public function getOneByDevAlias(string $devAlias, $query = null)
  57. {
  58. $query = $this->createDefaultQuery($query);
  59. $query->filterByDevAlias($devAlias);
  60. return $query->findOne();
  61. }
  62. public function getOneOnlineByDevAlias(string $devAlias, $query = null)
  63. {
  64. $query = $this->createDefaultQuery($query);
  65. $query
  66. ->filterByDevAlias($devAlias)
  67. ->filterIsOnline();
  68. return $query->findOne();
  69. }
  70. public function getOneByOldUrl(string $oldUrl, $query = null)
  71. {
  72. $query = $this->createDefaultQuery($query);
  73. $query
  74. ->filterByOldUrl($oldUrl)
  75. ->filterIsOnline();
  76. return $query->findOne();
  77. }
  78. public function get($query = null)
  79. {
  80. $query = $this->createDefaultQuery($query);
  81. return $query->find();
  82. }
  83. public function getOnline($query = null)
  84. {
  85. $query = $this->createDefaultQuery($query);
  86. $query->filterIsOnline();
  87. return $query->find();
  88. }
  89. public function getParent(bool $isOnline = true, $query = null)
  90. {
  91. $query = $this->createDefaultQuery($query);
  92. if ($isOnline) {
  93. $query->filterIsOnline();
  94. }
  95. $query->filterIsParent();
  96. return $query->find();
  97. }
  98. }