georgringer / news

TYPO3 Extension news
GNU General Public License v2.0
265 stars 356 forks source link

ExtensionLoadedViewHelper seems to be broken #2572

Closed gf-luka closed 3 days ago

gf-luka commented 4 days ago

Bug Report

Current Behavior The ViewHelper ExtensionLoadedViewHelper does not work anymore. It seems that the method evaluateCondition has been removed (https://docs.typo3.org/other/typo3fluid/fluid/main/en-us/Changelog/4.x.html).

Expected behavior/output If settings.detail.showSocialShareButtons = 1 and Shariff extension is installed, the social share icons should be appear on news detail view.

Environment

Possible Solution Following changes seems to work:

<?php

/*
 * This file is part of the "news" Extension for TYPO3 CMS.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 */

namespace GeorgRinger\News\ViewHelpers;

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper;

class ExtensionLoadedViewHelper extends AbstractConditionViewHelper
{
    /**
     * Initialize additional argument
     */
    public function initializeArguments()
    {
        $this->registerArgument('extensionKey', 'string', 'Extension which must be checked', true);
        parent::initializeArguments();
    }

    /**
     * @return bool
     */
    public static function verdict(array $arguments, RenderingContextInterface $renderingContext)
    {
        return ExtensionManagementUtility::isLoaded($arguments['extensionKey']);
    }
}

Instead of using the method evaluateCondition, i used the method verdict.

georgringer commented 3 days ago

thanks, provided also a test