private function loadCache($serviceLocator, $config)
{
// check if the cache is configured
if (!isset($config['view_helper']['cache']) || $config['view_helper']['cache'] === null) {
return null;
}
// get the cache, if it's a string, search it among services
$cache = $config['view_helper']['cache'];
if (is_string($cache)) {
$cache = $serviceLocator->get($cache);
}
// exception in case cache is not an Adapter that extend the AbstractAdapter of Zend\Cache\Storage
if ($cache !== null && !$cache instanceof AbstractCacheAdapter) {
throw new InvalidArgumentException('Invalid cache provided, you must pass a Cache Adapter that extend
Zend\\Cache\\Storage\\Adapter\\AbstractAdapter');
}
return $cache;
}