![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-customer/Model/Indexer/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Customer\Model\Indexer; use Magento\Customer\Model\ResourceModel\Group\CollectionFactory as CustomerGroupCollectionFactory; use Magento\Framework\Indexer\DimensionFactory; use Magento\Framework\Indexer\DimensionProviderInterface; /** * Class CustomerGroupDimensionProvider */ class CustomerGroupDimensionProvider implements DimensionProviderInterface { /** * Name for customer group dimension for multidimensional indexer * 'cg' - stands for 'customer_group' */ const DIMENSION_NAME = 'cg'; /** * @var CustomerGroupCollectionFactory */ private $collectionFactory; /** * @var \SplFixedArray */ private $customerGroupsDataIterator; /** * @var DimensionFactory */ private $dimensionFactory; /** * @param CustomerGroupCollectionFactory $collectionFactory * @param DimensionFactory $dimensionFactory */ public function __construct(CustomerGroupCollectionFactory $collectionFactory, DimensionFactory $dimensionFactory) { $this->dimensionFactory = $dimensionFactory; $this->collectionFactory = $collectionFactory; } /** * @inheritdoc */ public function getIterator(): \Traversable { foreach ($this->getCustomerGroups() as $customerGroup) { yield $this->dimensionFactory->create(self::DIMENSION_NAME, (string)$customerGroup); } } /** * Get Customer Groups * * @return array */ private function getCustomerGroups(): array { if ($this->customerGroupsDataIterator === null) { $customerGroups = $this->collectionFactory->create()->getAllIds(); $this->customerGroupsDataIterator = is_array($customerGroups) ? $customerGroups : []; } return $this->customerGroupsDataIterator; } }