[TYPO3-german] CHash Problem Typo3 8.7 in Extbase-Ext in CLI (Scheduler)

Philipp Gampe philipp.gampe at typo3.org
Mon May 15 22:48:58 CEST 2017


Hi Jürgen,

Jürgen Pfusterschmied wrote:

> Ich habe mir die newsletter und die news Extensions angesehen, konnte aber
> keinen Lösungsansatz für dieses Problem finden. Kann mir jemand einen
> Hinweis geben ? Kennt jemand eine Ext. an die man sich orientieren kann?

1. realurl deaktiviert sich im Backend Kontext (also auch in CLI) komplett, 
d.h. du must zumindest realurl an der Stelle überschreiben.

Als xclass:

ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']
[\DmitryDulepov\Realurl\Encoder\UrlEncoder::class] = array(
    'className' => \my\foo\Xclass\UrlEncoder::class
);

typo3conf/ext/foo/Classes/Xclass/UrlEncoder.php
<?php
namespace my\foo\Xclass;

class UrlEncoder extends \DmitryDulepov\Realurl\Encoder\UrlEncoder
{

    protected function canEncoderExecute()
    {
        return $this->isRealURLEnabled()
            && !$this->isSimulateStaticEnabled()
            && !$this->isInWorkspace()
            && $this->isTypo3Url()
            && $this->isProperTsfe();
    }
}

2. Die Links-erzeugenden Viewhelper von Fluid nutzen einen 
EnvironmentService um festzustellen, ob sie im Frontend oder Backend laufen.

typo3conf/ext/foo/Classes/Service/FrontendEnvironmentService.php
<?php
namespace my\foo\Service;

/**
 * Service for determining environment params
 */
class FrontendEnvironmentService extends 
\TYPO3\CMS\Extbase\Service\EnvironmentService implements 
\TYPO3\CMS\Core\SingletonInterface
{
    /**
     * Detects if TYPO3_MODE is defined and its value is "FE"
     *
     * @return bool
     */
    public function isEnvironmentInFrontendMode()
    {
        return true;
    }

    /**
     * Detects if TYPO3_MODE is defined and its value is "BE"
     *
     * @return bool
     */
    public function isEnvironmentInBackendMode()
    {
        return false;
    }

    /**
     * Detects if we are running a script from the command line.
     *
     * @return bool
     */
    public function isEnvironmentInCliMode()
    {
        return false;
    }

    /**
     * @return string
     */
    public function getServerRequestMethod()
    {
        return 'GET';
    }
}

3. Nun entweder den Service mittels Extbase Config in den Viewhelper 
injecten oder einfach den Viewhelper überschreiben:

<?php
namespace my\foo\ViewHelpers\Uri;

use my\foo\Service\FrontendEnvironmentService;

/**
 * Class ActionViewHelper
 *
 */
class ActionViewHelper extends 
\TYPO3\CMS\Fluid\ViewHelpers\Uri\ActionViewHelper
{

    public function initialize()
    {
        parent::initialize();
        /** @var FrontendEnvironmentService $environment */
        $environment = $this->objectManager-
>get(FrontendEnvironmentService::class);
        $uriBuilder = $this->controllerContext->getUriBuilder();
        $uriBuilder->injectEnvironmentService($environment);
        $this->controllerContext->setUriBuilder($uriBuilder);
    }
}


Alles ohne Garantie.

Grüße
-- 
Philipp Gampe – PGP-Key 0AD96065 – LFCS
TYPO3 CMS Certified Integrator – Certified Developer – Active contributor
TYPO3 ... inspiring people to share!



More information about the TYPO3-german mailing list