Skip to content

Commit

Permalink
[TASK] Support TYPO3 9 LTS (Related to #62)
Browse files Browse the repository at this point in the history
Updated ViewHelpers
  • Loading branch information
jonathanheilmann committed Dec 1, 2018
1 parent a3c6b6d commit dc1b0ec
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 22 deletions.
4 changes: 3 additions & 1 deletion Classes/ViewHelpers/Format/UcfirstViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
* LICENSE.md file that was distributed with this source code.
*/

use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

/**
* Class AddJsInlineCodeViewHelper
* @package JonathanHeilmann\JhMagnificpopup\ViewHelpers\PageRenderer
*/
class UcfirstViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
class UcfirstViewHelper extends AbstractViewHelper
{

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;


class UnderscoredToUpperCamelCaseViewHelper extends AbstractViewHelper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/

use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

/**
* Base class: InlineContent ViewHelpers
Expand Down
52 changes: 33 additions & 19 deletions Classes/ViewHelpers/PageRenderer/AddJsInlineCodeViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
namespace JonathanHeilmann\JhMagnificpopup\ViewHelpers\PageRenderer;

use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

/*
* This file is part of the JonathanHeilmann\JhMagnificpopup extension under GPLv2 or later.
Expand All @@ -14,28 +17,39 @@
* Class AddJsInlineCodeViewHelper
* @package JonathanHeilmann\JhMagnificpopup\ViewHelpers\PageRenderer
*/
class AddJsInlineCodeViewHelper extends \TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper
class AddJsInlineCodeViewHelper extends AbstractViewHelper
{

/**
* @param string $name
* @param string|null $block
* @param bool $compress
* @param bool $forceOnTop
* @param bool $addToFooter
*/
public function render($name, $block = null, $compress = true, $forceOnTop = false, $addToFooter = false)
/** @var ObjectManager */
protected $objectManager;

/** @var PageRenderer */
protected $pageRenderer;

public function initialize()
{
if ($block === null) $block = $this->renderChildren();

/** @var PageRenderer $pageRenderer */
$pageRenderer = $this->objectManager->get(PageRenderer::class);
if ($addToFooter === false)
{
$pageRenderer->addJsInlineCode($name, $block, $compress, $forceOnTop);
} else{
$pageRenderer->addJsFooterInlineCode($name, $block, $compress, $forceOnTop);
}
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->pageRenderer = $this->objectManager->get(PageRenderer::class);
}

public function initializeArguments()
{
$this->registerArgument('name', 'string', 'The name of the file', true, null);
$this->registerArgument('block', 'string', 'The JS content', false, null);
$this->registerArgument('compress', 'boolean', 'Compress output', false, false);
$this->registerArgument('forceOnTop', 'boolean', 'Force to top?', false, false);
$this->registerArgument('addToFooter', 'boolean', 'Add to footer?', false, false);
}

public function render()
{
if ($this->arguments['block'] === null) $this->arguments['block'] = htmlspecialchars_decode($this->renderChildren(), ENT_QUOTES);

if ($this->arguments['addToFooter'] === false) {
$this->pageRenderer->addJsInlineCode($this->arguments['name'], $this->arguments['block'], $this->arguments['compress'], $this->arguments['forceOnTop']);
} else {
$this->pageRenderer->addJsFooterInlineCode($this->arguments['name'], $this->arguments['block'], $this->arguments['compress'], $this->arguments['forceOnTop']);
}
return '';
}
}

0 comments on commit dc1b0ec

Please sign in to comment.