コード例 #1
0
 /**
  * Checks if cHash is required for the current request and calls
  * TypoScriptFrontendController::reqCHash() if so.
  * This call will trigger a PageNotFoundException if arguments are required and cHash is not present.
  *
  * @param Request $request
  * @param string $pluginNamespace
  */
 public function enforceForRequest(Request $request, string $pluginNamespace)
 {
     $arguments = $request->getArguments();
     if (is_array($arguments) && count($arguments) > 0) {
         $parameters = [$pluginNamespace => $arguments];
         $parameters['id'] = $this->typoScriptFrontendController->id;
         $relevantParameters = $this->cacheHashCalculator->getRelevantParameters(http_build_query($parameters));
         if (count($relevantParameters) > 0) {
             $this->typoScriptFrontendController->reqCHash();
         }
     }
 }
コード例 #2
0
ファイル: AbstractPlugin.php プロジェクト: plan2net/TYPO3.CMS
 /**
  * Class Constructor (true constructor)
  * Initializes $this->piVars if $this->prefixId is set to any value
  * Will also set $this->LLkey based on the config.language setting.
  *
  * @param DatabaseConnection $databaseConnection
  * @param TypoScriptFrontendController $frontendController
  */
 public function __construct(DatabaseConnection $databaseConnection = NULL, TypoScriptFrontendController $frontendController = NULL)
 {
     $this->databaseConnection = $databaseConnection ?: $GLOBALS['TYPO3_DB'];
     $this->frontendController = $frontendController ?: $GLOBALS['TSFE'];
     // Setting piVars:
     if ($this->prefixId) {
         $this->piVars = GeneralUtility::_GPmerged($this->prefixId);
         // cHash mode check
         // IMPORTANT FOR CACHED PLUGINS (USER cObject): As soon as you generate cached plugin output which depends on parameters (eg. seeing the details of a news item) you MUST check if a cHash value is set.
         // Background: The function call will check if a cHash parameter was sent with the URL because only if it was the page may be cached. If no cHash was found the function will simply disable caching to avoid unpredictable caching behaviour. In any case your plugin can generate the expected output and the only risk is that the content may not be cached. A missing cHash value is considered a mistake in the URL resulting from either URL manipulation, "realurl" "grayzones" etc. The problem is rare (more frequent with "realurl") but when it occurs it is very puzzling!
         if ($this->pi_checkCHash && !empty($this->piVars)) {
             $this->frontendController->reqCHash();
         }
     }
     if (!empty($this->frontendController->config['config']['language'])) {
         $this->LLkey = $this->frontendController->config['config']['language'];
         if (empty($this->frontendController->config['config']['language_alt'])) {
             /** @var $locales Locales */
             $locales = GeneralUtility::makeInstance(Locales::class);
             if (in_array($this->LLkey, $locales->getLocales())) {
                 $this->altLLkey = '';
                 foreach ($locales->getLocaleDependencies($this->LLkey) as $language) {
                     $this->altLLkey .= $language . ',';
                 }
                 $this->altLLkey = rtrim($this->altLLkey, ',');
             }
         } else {
             $this->altLLkey = $this->frontendController->config['config']['language_alt'];
         }
     }
 }