TYPO3  7.6
ResourceViewHelper.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Fluid\ViewHelpers\Uri;
3 
4 /* *
5  * This script is part of the TYPO3 project - inspiring people to share! *
6  * *
7  * TYPO3 is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU General Public License version 2 as published by *
9  * the Free Software Foundation. *
10  * *
11  * This script is distributed in the hope that it will be useful, but *
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
14  * Public License for more details. *
15  * */
16 
20 
35 {
45  public function render($path, $extensionName = null, $absolute = false)
46  {
47  return static::renderStatic(
48  array(
49  'path' => $path,
50  'extensionName' => $extensionName,
51  'absolute' => $absolute
52  ),
54  $this->renderingContext
55  );
56  }
57 
65  {
66  $path = $arguments['path'];
67  $extensionName = $arguments['extensionName'];
68  $absolute = $arguments['absolute'];
69 
70  if ($extensionName === null) {
71  $extensionName = $renderingContext->getControllerContext()->getRequest()->getControllerExtensionName();
72  }
73  $uri = 'EXT:' . GeneralUtility::camelCaseToLowerCaseUnderscored($extensionName) . '/Resources/Public/' . $path;
75  $uri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($uri);
76  if (TYPO3_MODE === 'BE' && $absolute === false && $uri !== false) {
77  $uri = '../' . $uri;
78  }
79  if ($absolute === true) {
80  $uri = $renderingContext->getControllerContext()->getRequest()->getBaseUri() . $uri;
81  }
82  return $uri;
83  }
84 }