Created
March 29, 2020 09:04
-
-
Save daniellienert/7ad22f8e337177b257ae9a8f4cfab265 to your computer and use it in GitHub Desktop.
Neos: Adjust Reference Selector Starting Point
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
<?php | |
namespace Your\Vendor\Aop\Aspect; | |
/* | |
* (c) 2018 punkt.de GmbH - Karlsruhe, Germany - http://punkt.de | |
* All rights reserved. | |
*/ | |
use Neos\ContentRepository\Domain\Model\NodeInterface; | |
use Neos\ContentRepository\Domain\Model\NodeType; | |
use Neos\ContentRepository\Domain\Service\NodeTypeManager; | |
use Neos\Flow\Annotations as Flow; | |
use Neos\Flow\Aop\JoinPointInterface; | |
use Neos\Flow\ObjectManagement\Exception\UnknownObjectException; | |
/** | |
* @Flow\Aspect | |
*/ | |
class CompanyStartingPointAspect | |
{ | |
/** | |
* @Flow\Inject | |
* @var NodeTypeManager | |
*/ | |
protected $nodeTypeManager; | |
/** | |
* @param JoinPointInterface $joinPoint | |
* @throws CompanyInformationRetrievalException | |
* @throws QueryBuildingException | |
* @throws UnknownObjectException | |
* @Flow\Around("method(Neos\Neos\Controller\Service\NodesController->indexAction($searchTerm, $nodeIdentifiers, $workspaceName, $dimensions, $nodeTypes, $contextNode))") | |
*/ | |
public function setAutomaticStartingPoint(JoinPointInterface $joinPoint) | |
{ | |
$isCategoryNodeType = false; | |
foreach ($joinPoint->getMethodArgument('nodeTypes') as $nodeTypeName) { | |
$isCategoryNodeType = $this->nodeTypeManager->getNodeType($nodeTypeName)->isOfType('YourVendor.Base:Mixin.Category') || $isCategoryNodeType; | |
} | |
if($isCategoryNodeType === true) { | |
$contextNode = // YOUR CALCULATION HERE; | |
$joinPoint->setMethodArgument('contextNode', $contextNode); | |
} | |
$joinPoint->getAdviceChain()->proceed($joinPoint); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment