lib/composer/ProductBundle/src/VisualMedia/ProductBundle/Manager/BaseProductManager.php line 61

Open in your IDE?
  1. <?php
  2. /**
  3. * Base Product Manager
  4. *
  5. * @author Vincent van Waasbergen <v.vanwaasbergen@visualmedia.nl>
  6. */
  7. namespace VisualMedia\ProductBundle\Manager;
  8. use VisualMedia\LisaBundle\Component\ManagerData;
  9. use VisualMedia\ProductBundle\Repository\BaseProductRepository;
  10. use VisualMedia\ProductBundle\Entity\BaseProduct;
  11. use VisualMedia\ProductBundle\Entity\BaseProductCategory;
  12. /**
  13. * Base Product Manager
  14. */
  15. class BaseProductManager extends BaseProductRepository
  16. {
  17. public const SERVICE_ALIAS_ID = 'manager.product';
  18. /**
  19. * {@inheritdoc}
  20. */
  21. public static function getEntityName(): string
  22. {
  23. return BaseProduct::class;
  24. }
  25. /**
  26. * Get Filtered Count
  27. *
  28. * @param BaseProductCategory $category
  29. * @param array $attributes
  30. * @param ManagerData $data
  31. *
  32. * @return int
  33. */
  34. public function getFilteredCount(BaseProductCategory $category, array $attributes, ManagerData $data = null): int
  35. {
  36. $data = $data ?? new ManagerData();
  37. $qb = $this->initializeQueryBuilder(static::QUERYTYPE_COUNT);
  38. $this->getFilteredQueryBuilder($qb, $category, $attributes, $data);
  39. $query = $this->getQuery($qb);
  40. $result = $query->getSingleScalarResult();
  41. return $result;
  42. }
  43. /**
  44. * Get Filtered Index
  45. *
  46. * @param BaseProductCategory $category
  47. * @param array $attributes
  48. * @param ManagerData $data
  49. *
  50. * @return array
  51. */
  52. public function getFilteredIndex(BaseProductCategory $category, array $attributes, ManagerData $data = null): array
  53. {
  54. $data = $data ?? new ManagerData();
  55. $qb = $this->initializeQueryBuilder(static::QUERYTYPE_MULTIPLE);
  56. $this->getFilteredQueryBuilder($qb, $category, $attributes, $data);
  57. $query = $this->getQuery($qb);
  58. if (null !== $limit = $data->getLimit()) {
  59. $query->setMaxResults($limit);
  60. $query->setFirstResult($data->getOffset());
  61. }
  62. $result = $this->getResults($query);
  63. return $result;
  64. }
  65. }