Skip to content

Instantly share code, notes, and snippets.

@bwaidelich
Created May 6, 2016 09:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwaidelich/5bb5663c3001a7ab4bef2dd683b6458f to your computer and use it in GitHub Desktop.
Save bwaidelich/5bb5663c3001a7ab4bef2dd683b6458f to your computer and use it in GitHub Desktop.
Tamper Routing MatchResults from a Flow HTTP Component
<?php
namespace Your\Package;
use TYPO3\Flow\Annotations as Flow;
use TYPO3\Flow\Http\Component\ComponentContext;
use TYPO3\Flow\Http\Component\ComponentInterface;
use TYPO3\Flow\Mvc\Routing\RoutingComponent;
use TYPO3\Flow\Utility\Arrays;
class DetectSubdomainComponent implements ComponentInterface
{
/**
* @param ComponentContext $componentContext
* @return void
*/
public function handle(ComponentContext $componentContext)
{
$originalMatchResults = $componentContext->getParameter(RoutingComponent::class, 'matchResults');
// detect subdomain...
$newMatchResults = Arrays::arrayMergeRecursiveOverrule($originalMatchResults, ['shop' => 123]);
$componentContext->setParameter(RoutingComponent::class, 'matchResults', $newMatchResults);
}
}
TYPO3:
Flow:
http:
chain:
process:
chain:
'detectSubdomain':
position: 'after routing'
component: 'Your\Package\DetectSubdomainComponent'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment