Processor.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Mview;
  7. class Processor implements ProcessorInterface
  8. {
  9. /**
  10. * @var View\CollectionFactory
  11. */
  12. protected $viewsFactory;
  13. /**
  14. * @param View\CollectionFactory $viewsFactory
  15. */
  16. public function __construct(View\CollectionFactory $viewsFactory)
  17. {
  18. $this->viewsFactory = $viewsFactory;
  19. }
  20. /**
  21. * Return list of views by group
  22. *
  23. * @param string $group
  24. * @return ViewInterface[]
  25. */
  26. protected function getViewsByGroup($group = '')
  27. {
  28. $collection = $this->viewsFactory->create();
  29. return $group ? $collection->getItemsByColumnValue('group', $group) : $collection->getItems();
  30. }
  31. /**
  32. * Materialize all views by group (all views if empty)
  33. *
  34. * @param string $group
  35. * @return void
  36. */
  37. public function update($group = '')
  38. {
  39. foreach ($this->getViewsByGroup($group) as $view) {
  40. $view->update();
  41. }
  42. }
  43. /**
  44. * Clear all views' changelogs by group (all views if empty)
  45. *
  46. * @param string $group
  47. * @return void
  48. */
  49. public function clearChangelog($group = '')
  50. {
  51. foreach ($this->getViewsByGroup($group) as $view) {
  52. $view->clearChangelog();
  53. }
  54. }
  55. }