4d042bbaceabf609679a9792ff62c284af08951b
[Packages/TYPO3.CMS.git] / typo3 / sysext / belog / Classes / ViewHelpers / IsExtensionLoadedViewHelper.php
1 <?php
2 namespace TYPO3\CMS\Belog\ViewHelpers;
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 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
17 use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface;
18 use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
19 use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface;
20
21 /**
22 * Returns true, if a specific extension is loaded
23 *
24 * @author Christian Kuhn <lolli@schwarzbu.ch>
25 * @internal
26 */
27 class IsExtensionLoadedViewHelper extends AbstractViewHelper implements CompilableInterface {
28
29 /**
30 * Checks whether an extension is loaded.
31 *
32 * @param string $extensionKey The extension's key
33 * @return bool TRUE if extension is loaded, FALSE otherwise
34 */
35 public function render($extensionKey) {
36 return self::renderStatic(
37 array(
38 'extensionKey' => $extensionKey
39 ),
40 $this->buildRenderChildrenClosure(),
41 $this->renderingContext
42 );
43 }
44
45 /**
46 * @param array $arguments
47 * @param callable $renderChildrenClosure
48 * @param RenderingContextInterface $renderingContext
49 *
50 * @return string
51 */
52 static public function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) {
53 return ExtensionManagementUtility::isLoaded($arguments['extensionKey']);
54 }
55 }