<?php
namespace ModulesAbstract\ImportedOrdersFileManager\Model\Utils; class FilesystemPaginatorAndSorterCached extends FilesystemPaginatorAndSorter { protected $CACHE = null; public function __construct() { $this->CACHE = \Engine\Cache\General::getInstance('disk'); } protected function sortList($elements, $orderColumn, $orderAscending=true) { $firstElement = $elements[0]; if ($firstElement) { $cacheKey = sprintf("%s:%s:%s:%s:%s:%s", __METHOD__, $firstElement->getFullPath(), count($elements), implode(",", $firstElement->getExtractedData()), $this->orderColumn, $this->orderDirection); $cachedData = $this->CACHE->get($cacheKey); if ($cachedData) { return $cachedData; } $elements = parent::sortList($elements, $orderColumn, $orderAscending); $this->CACHE->set($cacheKey, $elements, 60*60*24*7); } return $elements; } } 