/**
  * @param string $actionName
  * @return string
  */
 protected function getTemplateSource($actionName = NULL)
 {
     if (NULL !== $this->templateSource) {
         return $this->templateSource;
     }
     return parent::getTemplateSource($actionName);
 }
Esempio n. 2
0
 /**
  * Resolve the template path and filename for the given action. If $actionName
  * is NULL, looks into the current request.
  *
  * @param string $actionName Name of the action. If NULL, will be taken from request.
  * @throws InvalidTemplateResourceException
  * @throws \TYPO3\CMS\Core\Package\Exception
  * @return string Full path to template
  * @author Sebastian Kurfürst <*****@*****.**>
  */
 protected function getTemplateSource($actionName = null)
 {
     /**
      * As in 1.3.0 resolving was part of this method we had to overwrite the complete method
      * This is not longer necessary in Version 1.4.0
      */
     if (substr(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getExtensionVersion('fluid'), 0, 3) == '1.4') {
         return parent::getTemplateSource($actionName);
     }
     if ($this->templatePathAndFilename !== null) {
         $templatePathAndFilename = $this->templatePathAndFilename;
     } else {
         $actionName = $actionName !== null ? $actionName : $this->controllerContext->getRequest()->getControllerActionName();
         $actionName = ucfirst($actionName);
         $paths = $this->expandGenericPathPattern($this->templatePathAndFilenamePattern, false, false);
         $paths[] = $this->getTemplatePathAndFilename($actionName);
         $found = false;
         foreach ($paths as &$templatePathAndFilename) {
             // These tokens are replaced by the Backporter for the graceful fallback in version 4.
             $fallbackPath = str_replace('@action', strtolower($actionName), $templatePathAndFilename);
             $templatePathAndFilename = str_replace('@action', $actionName, $templatePathAndFilename);
             if (file_exists($templatePathAndFilename)) {
                 $found = true;
                 break;
             } elseif (file_exists($fallbackPath)) {
                 $found = true;
                 $templatePathAndFilename = $fallbackPath;
                 GeneralUtility::deprecationLog('the template filename "' . $fallbackPath . '" is lowercase. This is deprecated since TYPO3 4.4. Please rename the template to "' . basename($templatePathAndFilename) . '"');
                 break;
             }
         }
         if (!$found) {
             throw new InvalidTemplateResourceException('Template could not be loaded. I tried "' . implode('", "', $paths) . '"', 1225709595);
         }
     }
     $templateSource = file_get_contents($templatePathAndFilename);
     if ($templateSource === false) {
         throw new InvalidTemplateResourceException('"' . $templatePathAndFilename . '" is not a valid template resource URI.', 1257246929);
     }
     return $templateSource;
 }