2 namespace TYPO3\CMS\Fluid\View;
34 use TYPO3\CMS\Fluid\View\Exception\InvalidTemplateResourceException;
91 $configurationManager = $this->objectManager->get(ConfigurationManagerInterface::class);
92 if ($contentObject === null) {
96 $configurationManager->setContentObject($contentObject);
97 $this->templateParser = $this->objectManager->get(TemplateParser::class);
100 $request = $this->objectManager->get(WebRequest::class);
104 $uriBuilder = $this->objectManager->get(UriBuilder::class);
105 $uriBuilder->setRequest($request);
111 $this->templateCompiler = $this->objectManager->get(TemplateCompiler::class);
146 return $this->controllerContext->getRequest();
207 if ($this->templateRootPaths === null) {
213 foreach ($possibleTemplatePaths as $possibleTemplatePath) {
222 throw new InvalidTemplateResourceException(
'Could not load template file. Tried following paths: "' . implode(
'", "', $possibleTemplatePaths) .
'".', 1430635896);
277 if ($this->layoutRootPaths === null && $this->templatePathAndFilename === null) {
280 if ($this->layoutRootPaths === null) {
281 $this->layoutRootPaths = array(dirname($this->templatePathAndFilename) .
'/Layouts');
339 if ($this->partialRootPaths === null && $this->templatePathAndFilename === null) {
342 if ($this->partialRootPaths === null) {
343 $this->partialRootPaths = array(dirname($this->templatePathAndFilename) .
'/Partials');
374 if ($this->templateSource === null) {
377 $templateFilenameWithoutExtension = basename(
$templatePathAndFilename,
'.' . $templatePathAndFilenameInfo[
'extension']);
378 $prefix = sprintf(
'template_file_%s', $templateFilenameWithoutExtension);
382 $prefix =
'template_source';
383 $templateIdentifier = sprintf(
'Standalone_%s_%s', $prefix, sha1(
$templateSource));
384 return $templateIdentifier;
397 if ($this->templateSource === null && $this->templatePathAndFilename === null) {
400 if ($this->templateSource === null) {
404 $this->templateSource = file_get_contents($this->templatePathAndFilename);
420 $prefix =
'layout_' . $layoutName;
435 $layoutSource = file_get_contents($layoutPathAndFilename);
436 if ($layoutSource ===
false) {
439 return $layoutSource;
457 foreach ($possibleLayoutPaths as $layoutPathAndFilename) {
459 return $layoutPathAndFilename;
463 throw new InvalidTemplateResourceException(
'Could not load layout file. Tried following paths: "' . implode(
'", "', $possibleLayoutPaths) .
'".', 1288092555);
477 $prefix =
'partial_' . $partialName;
492 $partialSource = file_get_contents($partialPathAndFilename);
493 if ($partialSource ===
false) {
496 return $partialSource;
509 foreach ($possiblePartialPaths as $partialPathAndFilename) {
511 return $partialPathAndFilename;
514 throw new InvalidTemplateResourceException(
'Could not load partial file. Tried following paths: "' . implode(
'", "', $possiblePartialPaths) .
'".', 1288092556);
528 $possibleTemplatePaths = array();
530 $paths = array_reverse($paths,
true);
531 foreach ($paths as $layoutRootPath) {
532 $possibleTemplatePaths[] = $this->
resolveFileNamePath($layoutRootPath .
'/' . $upperCasedTemplateName .
'.' . $format);
533 $possibleTemplatePaths[] = $this->
resolveFileNamePath($layoutRootPath .
'/' . $upperCasedTemplateName);
534 if ($upperCasedTemplateName !== $templateName) {
535 $possibleTemplatePaths[] = $this->
resolveFileNamePath($layoutRootPath .
'/' . $templateName .
'.' . $format);
536 $possibleTemplatePaths[] = $this->
resolveFileNamePath($layoutRootPath .
'/' . $templateName);
539 return $possibleTemplatePaths;
553 $templateModifiedTimestamp = filemtime($pathAndFilename);
554 $templateIdentifier = sprintf(
'Standalone_%s_%s', $prefix, sha1($pathAndFilename .
'|' . $templateModifiedTimestamp));
555 $templateIdentifier = str_replace(
'/',
'_', str_replace(
'.',
'_', $templateIdentifier));
556 return $templateIdentifier;