HEX
Server: Apache
System: Linux srv13.cpanelhost.cl 3.10.0-962.3.2.lve1.5.38.el7.x86_64 #1 SMP Thu Jun 18 05:28:41 EDT 2020 x86_64
User: cca63905 (4205)
PHP: 7.3.20
Disabled: NONE
Upload Files
File: /home4/cca63905/www/nueva/modules/ps_eventbus/src/Provider/StoreDataProvider.php
<?php

namespace PrestaShop\Module\PsEventbus\Provider;

use PrestaShop\Module\PsEventbus\Config\Config;
use PrestaShop\Module\PsEventbus\Decorator\StoreDecorator;
use PrestaShop\Module\PsEventbus\Repository\StoreRepository;

class StoreDataProvider implements PaginatedApiDataProviderInterface
{
    /**
     * @var StoreRepository
     */
    private $storeRepository;
    /**
     * @var StoreDecorator
     */
    private $storeDecorator;

    public function __construct(StoreRepository $storeRepository, StoreDecorator $storeDecorator)
    {
        $this->storeRepository = $storeRepository;
        $this->storeDecorator = $storeDecorator;
    }

    /**
     * @param int $offset
     * @param int $limit
     * @param string $langIso
     *
     * @return array<mixed>
     *
     * @@throws \PrestaShopDatabaseException
     */
    public function getFormattedData($offset, $limit, $langIso)
    {
        $stores = $this->storeRepository->getStores($offset, $limit, $langIso);

        if (!is_array($stores)) {
            return [];
        }

        $this->storeDecorator->decorateStores($stores);

        return array_map(function ($store) {
            return [
                'id' => $store['id_store'],
                'collection' => Config::COLLECTION_STORES,
                'properties' => $store,
            ];
        }, $stores);
    }

    /**
     * @param int $offset
     * @param string $langIso
     *
     * @return int
     */
    public function getRemainingObjectsCount($offset, $langIso)
    {
        return (int) $this->storeRepository->getRemainingStoreCount($offset, $langIso);
    }

    /**
     * @param int $limit
     * @param string $langIso
     * @param array<mixed> $objectIds
     *
     * @return array<mixed>
     *
     * @@throws \PrestaShopDatabaseException
     */
    public function getFormattedDataIncremental($limit, $langIso, $objectIds)
    {
        $stores = $this->storeRepository->getStoresIncremental($limit, $langIso, $objectIds);

        if (!is_array($stores)) {
            return [];
        }

        $this->storeDecorator->decorateStores($stores);

        return array_map(function ($store) {
            return [
                'id' => $store['id_store'],
                'collection' => Config::COLLECTION_STORES,
                'properties' => $store,
            ];
        }, $stores);
    }

    /**
     * @param int $offset
     * @param int $limit
     * @param string $langIso
     *
     * @return array<mixed>
     *
     * @@throws \PrestaShopDatabaseException
     */
    public function getQueryForDebug($offset, $limit, $langIso)
    {
        return $this->storeRepository->getQueryForDebug($offset, $limit, $langIso);
    }
}