-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FEATURE: Allow to have empty uriSegment for host-based default
- Loading branch information
1 parent
7842aab
commit b176aff
Showing
4 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
namespace Flownative\Neos\HostBasedDefaultPreset\Aspects; | ||
|
||
/* | ||
* This file is part of the Flownative.Neos.HostBasedDefaultPreset package. | ||
* | ||
* (c) 2017 Karsten Dambekalns, Flownative GmbH | ||
* | ||
* This package is Open Source Software. For the full copyright and license | ||
* information, please view the LICENSE file which was distributed with this | ||
* source code. | ||
*/ | ||
|
||
use Neos\Flow\Annotations as Flow; | ||
use Neos\Flow\Aop\JoinPointInterface; | ||
use Neos\Flow\Core\Bootstrap; | ||
use Neos\Flow\Http\HttpRequestHandlerInterface; | ||
|
||
/** | ||
* @Flow\Scope("singleton") | ||
* @Flow\Aspect | ||
*/ | ||
class RouteCacheAspect | ||
{ | ||
/** | ||
* @Flow\Inject | ||
* @var Bootstrap | ||
*/ | ||
protected $bootstrap; | ||
|
||
/** | ||
* Add the request host as a tag for the route cache entry | ||
* | ||
* @Flow\Around("method(Neos\Flow\Mvc\Routing\RouterCachingService->buildResolveCacheIdentifier())") | ||
* @param JoinPointInterface $joinPoint The current join point | ||
* @return array | ||
* @throws \Exception | ||
*/ | ||
public function addHostname(JoinPointInterface $joinPoint) | ||
{ | ||
$resolveCacheIdentifier = $joinPoint->getAdviceChain()->proceed($joinPoint); | ||
|
||
$activeRequestHandler = $this->bootstrap->getActiveRequestHandler(); | ||
if ($activeRequestHandler instanceof HttpRequestHandlerInterface) { | ||
$requestedHost = $activeRequestHandler->getHttpRequest()->getUri()->getHost(); | ||
$resolveCacheIdentifier = md5(sprintf( | ||
'%s_%s', | ||
$resolveCacheIdentifier, | ||
$requestedHost | ||
)); | ||
} | ||
|
||
return $resolveCacheIdentifier; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
Flownative: | ||
Neos: | ||
HostBasedDefaultPreset: | ||
forceEmptyUriSegment: false | ||
dimensions: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters