1<?php 2namespace TYPO3Fluid\Fluid\Core\Cache; 3 4/* 5 * This file belongs to the package "TYPO3 Fluid". 6 * See LICENSE.txt that was shipped with this package. 7 */ 8 9use TYPO3Fluid\Fluid\Core\Compiler\FailedCompilingState; 10use TYPO3Fluid\Fluid\Core\Parser\ParsedTemplateInterface; 11 12/** 13 * Class FluidCacheWarmupResult 14 */ 15class FluidCacheWarmupResult 16{ 17 18 const RESULT_COMPILABLE = 'compilable'; 19 const RESULT_COMPILED = 'compiled'; 20 const RESULT_HASLAYOUT = 'hasLayout'; 21 const RESULT_COMPILEDCLASS = 'compiledClassName'; 22 const RESULT_FAILURE = 'failure'; 23 const RESULT_MITIGATIONS = 'mitigations'; 24 25 /** 26 * @var array 27 */ 28 protected $results = []; 29 30 /** 31 * @return self 32 */ 33 public function merge() 34 { 35 /* @var FluidCacheWarmupResult[] $results */ 36 $results = func_get_args(); 37 foreach ($results as $result) { 38 $this->results += $result->getResults(); 39 } 40 return $this; 41 } 42 43 /** 44 * @return array 45 */ 46 public function getResults() 47 { 48 return $this->results; 49 } 50 51 /** 52 * @param ParsedTemplateInterface $state 53 * @param string $templatePathAndFilename 54 * @return self 55 */ 56 public function add(ParsedTemplateInterface $state, $templatePathAndFilename) 57 { 58 $currentlyCompiled = $state->isCompiled(); 59 $this->results[$templatePathAndFilename] = [ 60 static::RESULT_COMPILABLE => $currentlyCompiled || $state->isCompilable(), 61 static::RESULT_COMPILED => $currentlyCompiled, 62 static::RESULT_HASLAYOUT => $state->hasLayout(), 63 static::RESULT_COMPILEDCLASS => $state->getIdentifier() 64 ]; 65 if ($state instanceof FailedCompilingState) { 66 $this->results[$templatePathAndFilename][static::RESULT_FAILURE] = $state->getFailureReason(); 67 $this->results[$templatePathAndFilename][static::RESULT_MITIGATIONS] = $state->getMitigations(); 68 } 69 return $this; 70 } 71} 72