protected function cacheBlockResponses()
	{
		$cacheRequests = $this->blockCacheRequests;
		$localization = $this->pageRequest->getLocalization();
		$logger = $this->container->getLogger();
		$cache = $this->container->getCache();

		$this->iterateBlocks(function(Block $block, BlockController $controller) 
				use (&$cacheRequests, $localization, $cache, $logger) {

			$blockId = $block->getId();

			if (! isset($cacheRequests[$blockId])) {
				return;
			}
			
			$cacheConfig = $cacheRequests[$blockId];
			
			$response = $controller->getResponse();
			$context = $response->getContext();
			
			try {
				$cache->store(
						'block_cache',
						$cacheConfig->getCacheKey($localization, $block, $context),
						serialize($response),
						time(),
						$cacheConfig->getLifetime()
				);
			} catch (\Exception $e) {
				$logger->error(sprintf(
						"Failed to store cache for [%s], got exception [%s]",
						get_class($controller),
						$e->getMessage()
				));
			}
		});
	}
protected function cacheBlockResponses()
	{
		$cacheRequests = $this->blockCacheRequests;
		$localization = $this->pageRequest->getLocalization();
		$logger = $this->container->getLogger();
		$cache = $this->container->getCache();

		$this->iterateBlocks(function(Block $block, BlockController $controller) 
				use (&$cacheRequests, $localization, $cache, $logger) {

			$blockId = $block->getId();

			if (! isset($cacheRequests[$blockId])) {
				return;
			}
			
			$cacheConfig = $cacheRequests[$blockId];
			
			$response = $controller->getResponse();
			$context = $response->getContext();
			
			try {
				$cache->store(
						'block_cache',
						$cacheConfig->getCacheKey($localization, $block, $context),
						serialize($response),
						time(),
						$cacheConfig->getLifetime()
				);
			} catch (\Exception $e) {
				$logger->error(sprintf(
						"Failed to store cache for [%s], got exception [%s]",
						get_class($controller),
						$e->getMessage()
				));
			}
		});
	}
protected function cacheBlockResponses ( ) { $ cacheRequests = $ this -> blockCacheRequests ; $ localization = $ this -> pageRequest -> getLocalization ( ) ; $ logger = $ this -> container -> getLogger ( ) ; $ cache = $ this -> container -> getCache ( ) ; $ this -> iterateBlocks ( function ( Block $ block , BlockController $ controller ) use ( & $ cacheRequests , $ localization , $ cache , $ logger ) { $ blockId = $ block -> getId ( ) ; if ( ! isset ( $ cacheRequests [ $ blockId ] ) ) { return ; } $ cacheConfig = $ cacheRequests [ $ blockId ] ; $ response = $ controller -> getResponse ( ) ; $ context = $ response -> getContext ( ) ; try { $ cache -> store ( 'block_cache' , $ cacheConfig -> getCacheKey ( $ localization , $ block , $ context ) , serialize ( $ response ) , time ( ) , $ cacheConfig -> getLifetime ( ) ) ; } catch ( \ Exception $ e ) { $ logger -> error ( sprintf ( "Failed to store cache for [%s], got exception [%s]" , get_class ( $ controller ) , $ e -> getMessage ( ) ) ) ; } } ) ; }
Caches block responses
Caches block responses