[BUGFIX] Do not use Fluid legacy classes
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / Core / ViewHelper / ViewHelperResolver.php
1 <?php
2 namespace TYPO3\CMS\Fluid\Core\ViewHelper;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Core\Utility\GeneralUtility;
18 use TYPO3\CMS\Extbase\Object\ObjectManager;
19 use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
20
21 /**
22 * Class ViewHelperResolver
23 *
24 * Class whose purpose is dedicated to resolving classes which
25 * can be used as ViewHelpers and ExpressionNodes in Fluid.
26 *
27 * This CMS-specific version of the ViewHelperResolver works
28 * almost exactly like the one from Fluid itself, with the main
29 * differences being that this one supports a legacy mode flag
30 * which when toggled on makes the Fluid parser behave exactly
31 * like it did in the legacy CMS Fluid package.
32 *
33 * In addition to modifying the behavior or the parser when
34 * legacy mode is requested, this ViewHelperResolver is also
35 * made capable of "mixing" two different ViewHelper namespaces
36 * to effectively create aliases for the Fluid core ViewHelpers
37 * to be loaded in the TYPO3\CMS\ViewHelpers scope as well.
38 */
39 class ViewHelperResolver extends \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperResolver
40 {
41 /**
42 * Custom merged namespace for CMS Fluid adapter;
43 * will look for classes in both namespaces starting
44 * from the bottom.
45 *
46 * @var array
47 */
48 protected $namespaces = array(
49 'f' => array(
50 'TYPO3Fluid\\Fluid\\ViewHelpers',
51 'TYPO3\\CMS\\Fluid\\ViewHelpers'
52 )
53 );
54
55 /**
56 * @param string $viewHelperClassName
57 * @return \TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperInterface
58 */
59 public function createViewHelperInstanceFromClassName($viewHelperClassName)
60 {
61 return $this->getObjectManager()->get($viewHelperClassName);
62 }
63
64 /**
65 * @return ObjectManagerInterface
66 */
67 protected function getObjectManager()
68 {
69 return GeneralUtility::makeInstance(ObjectManager::class);
70 }
71 }