/** * Advice for a disabled content cache (e.g. because an exception was handled) * * @Flow\AfterReturning("method(TYPO3\TypoScript\Core\Cache\RuntimeContentCache->setEnableContentCache())") * @param JoinPointInterface $joinPoint */ public function registerDisableContentCache(JoinPointInterface $joinPoint) { $enableContentCache = $joinPoint->getMethodArgument('enableContentCache'); if ($enableContentCache !== TRUE) { $this->evaluatedUncached = TRUE; } }
/** * @Flow\Before("method(TYPO3\Neos\Controller\Backend\ContentController->uploadAssetAction())") * @param JoinPointInterface $joinPoint The current join point * @return void */ public function rewriteSiteAssetCollection(JoinPointInterface $joinPoint) { if ($this->lookupNodeFilter === NULL || $this->lookupPropertyName === NULL) { return; } /** @var ContentController $contentController */ $contentController = $joinPoint->getProxy(); /** @var ActionRequest $actionRequest */ $actionRequest = ObjectAccess::getProperty($contentController, 'request', TRUE); $nodeContextPath = $actionRequest->getInternalArgument('__node'); if ($nodeContextPath === NULL) { return; } $node = $this->propertyMapper->convert($nodeContextPath, NodeInterface::class); $flowQuery = new FlowQuery(array($node)); /** @var NodeInterface $documentNode */ $documentNode = $flowQuery->closest($this->lookupNodeFilter)->get(0); if (!$documentNode->hasProperty($this->lookupPropertyName)) { return; } /** @var AssetCollection $assetCollection */ $assetCollection = $this->assetCollectionRepository->findByIdentifier($documentNode->getProperty($this->lookupPropertyName)); if ($assetCollection === NULL) { return; } /** @var Asset $asset */ $asset = $joinPoint->getMethodArgument('asset'); $assetCollection->addAsset($asset); $this->assetCollectionRepository->update($assetCollection); }
/** * @Flow\Around("method(TYPO3\Neos\Routing\FrontendNodeRoutePartHandler->convertRequestPathToNode())") * * @param \TYPO3\FLOW\AOP\JoinPointInterface $joinPoint the join point * * @return mixed */ public function aroundConvertRequestPathToNodeAspect($joinPoint) { if ($this->nodeNotFoundService->isEnabled()) { /** @var NodeInterface $node */ $requestPath = $joinPoint->getMethodArgument('requestPath'); try { return $joinPoint->getAdviceChain()->proceed($joinPoint); } catch (InvalidRequestPathException $e) { $defaultUriSegment = $this->nodeNotFoundService->getDefaultUriSegment(); $requestPath = $defaultUriSegment . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($defaultUriSegment); $joinPoint->setMethodArgument("requestPath", $requestPath); return $joinPoint->getAdviceChain()->proceed($joinPoint); } catch (NoSuchDimensionValueException $e) { $defaultUriSegment = $this->nodeNotFoundService->getDefaultUriSegment(); $requestPath = $defaultUriSegment . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($defaultUriSegment); $joinPoint->setMethodArgument("requestPath", $requestPath); return $joinPoint->getAdviceChain()->proceed($joinPoint); } catch (NoSuchNodeException $e) { $dimensionUriSegment = strstr($requestPath, "/", true); if (count($this->contentDimensionPresetSource->getAllPresets()) > 0) { $requestPath = $dimensionUriSegment . "/" . $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment($dimensionUriSegment); } else { $requestPath = $this->nodeNotFoundService->get404NodeUriForDimensionUriSegment(''); } $joinPoint->setMethodArgument("requestPath", $requestPath); return $joinPoint->getAdviceChain()->proceed($joinPoint); } } else { // execute the original code return $joinPoint->getAdviceChain()->proceed($joinPoint); } }
/** * @Flow\Around("method(TYPO3\TYPO3CR\Domain\Model\Workspace->replaceNodeData())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return string The result of the target method if it has not been intercepted */ public function replaceNodeData(JoinPointInterface $joinPoint) { /** @var Node $node */ $node = $joinPoint->getMethodArgument('node'); if ($node->isRemoved()) { // If the node is supposed to be removed, we do not need to do anything as the node will be gone anyways afterwards return $joinPoint->getAdviceChain()->proceed($joinPoint); } /** @var NodeData $targetNodeData */ $targetNodeData = $joinPoint->getMethodArgument('targetNodeData'); $commentsForToBePublishedNode = $this->extractComments($node); $commentsInTargetWorkspace = $this->extractComments($targetNodeData); // Call original Method $result = $joinPoint->getAdviceChain()->proceed($joinPoint); if (count($commentsForToBePublishedNode) == 0 && count($commentsInTargetWorkspace) == 0) { return $result; } // After publishing the node, we update the published node with the merged comments. We cannot do this // before publishing, as otherwise the NodeData which is underneath the to-be-published Node will be "dirty" // and marked as "removed" at the same time, leading to a CR crash. This also is a CR bug which only occurs in // very rare occasions. $mergedComments = $this->mergeComments($commentsForToBePublishedNode, $commentsInTargetWorkspace); $this->writeComments($node, $mergedComments); return $result; }
/** * Add the current node and all parent identifiers to be used for cache entry tagging * * @Flow\Before("method(TYPO3\Flow\Mvc\Routing\RouterCachingService->extractUuids())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return void */ public function addCurrentNodeIdentifier(JoinPointInterface $joinPoint) { $values = $joinPoint->getMethodArgument('values'); if (!isset($values['node']) || strpos($values['node'], '@') === false) { return; } // Build context explicitly without authorization checks because the security context isn't available yet // anyway and any Entity Privilege targeted on Workspace would fail at this point: $this->securityContext->withoutAuthorizationChecks(function () use($joinPoint, $values) { $contextPathPieces = NodePaths::explodeContextPath($values['node']); $context = $this->contextFactory->create(['workspaceName' => $contextPathPieces['workspaceName'], 'dimensions' => $contextPathPieces['dimensions'], 'invisibleContentShown' => true]); $node = $context->getNode($contextPathPieces['nodePath']); if (!$node instanceof NodeInterface) { return; } $values['node-identifier'] = $node->getIdentifier(); $node = $node->getParent(); $values['node-parent-identifier'] = array(); while ($node !== null) { $values['node-parent-identifier'][] = $node->getIdentifier(); $node = $node->getParent(); } $joinPoint->setMethodArgument('values', $values); }); }
/** * Before advice, making sure we initialize before use. * * This expects $proxy->Flow_Persistence_LazyLoadingObject_thawProperties * to be a Closure that populates the object. That variable is unset after * initializing the object! * * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return void * @Flow\Before("TYPO3\Flow\Persistence\Generic\Aspect\LazyLoadingObjectAspect->needsLazyLoadingObjectAspect && !method(.*->__construct())") */ public function initialize(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $proxy = $joinPoint->getProxy(); if (property_exists($proxy, 'Flow_Persistence_LazyLoadingObject_thawProperties') && $proxy->Flow_Persistence_LazyLoadingObject_thawProperties instanceof \Closure) { $proxy->Flow_Persistence_LazyLoadingObject_thawProperties->__invoke($proxy); unset($proxy->Flow_Persistence_LazyLoadingObject_thawProperties); } }
/** * @Flow\Around("within(TYPO3\Flow\Property\TypeConverter\MediaTypeConverterInterface) && method(.*->convertMediaType())") * @param JoinPointInterface $joinPoint The current joinpoint * @return mixed */ public function rewriteJsonApiOrgMediaTypeToJson(JoinPointInterface $joinPoint) { $mediaType = $joinPoint->getMethodArgument('mediaType'); if (strpos($mediaType, 'application/vnd.api+json') !== false) { $joinPoint->setMethodArgument('mediaType', 'application/json'); } return $joinPoint->getAdviceChain()->proceed($joinPoint); }
/** * Advice for a disabled content cache (e.g. because an exception was handled) * * @Flow\AfterReturning("method(TYPO3\TypoScript\Core\Cache\RuntimeContentCache->setEnableContentCache())") * @param JoinPointInterface $joinPoint */ public function registerDisableContentCache(JoinPointInterface $joinPoint) { $enableContentCache = $joinPoint->getMethodArgument('enableContentCache'); if ($enableContentCache !== TRUE) { $this->logger->log('Varnish cache disabled due content cache being disabled (e.g. because an exception was handled)', LOG_DEBUG); $this->evaluatedUncached = TRUE; } }
/** * Check if nodetype is in allowed sites (apply node context by filtering out not allowed node types) * * @param \TYPO3\Flow\AOP\JoinPointInterface $joinPoint * @Flow\Around("method(TYPO3\TYPO3CR\Domain\Factory\NodeFactory->filterNodeByContext(.*))") * @return \TYPO3\TYPO3CR\Domain\Model\NodeInterface|NULL */ public function filterNodeByAllowedSites($joinPoint) { if ($this->isNodeTypeInAllowedSite($joinPoint->getMethodArgument('node')->getNodeType()) == FALSE) { return null; } $result = $joinPoint->getAdviceChain()->proceed($joinPoint); return $result; }
/** * Add DQL function * * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @Flow\Before("method(TYPO3\Flow\Persistence\Doctrine\Service->runDql())") * @return void */ public function addDqlFunction(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $entityManager = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($joinPoint->getProxy(), 'entityManager', TRUE); $configuration = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($entityManager, 'config', TRUE); $configuration->addCustomStringFunction('DAY', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Day'); $configuration->addCustomStringFunction('MONTH', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Month'); $configuration->addCustomStringFunction('YEAR', 'Lelesys\\Plugin\\News\\Doctrine\\Query\\Mysql\\Year'); }
/** * Makes sure that XML content (such as the RSS feed) is not wrapped with divs. * * @param JoinPointInterface $joinPoint * @return string * @Flow\Around("method(TYPO3\Neos\Service\ContentElementWrappingService->wrapContentObject())") */ public function preventContentElementWraps(JoinPointInterface $joinPoint) { $content = $joinPoint->getMethodArgument('content'); if (substr($content, 0, 5) === '<?xml') { return $content; } return $joinPoint->getAdviceChain()->proceed($joinPoint); }
/** * @param JoinPointInterface $joinPoint * @return mixed Result of the target method * @Flow\Around("class(TYPO3\Flow\Cli\Request) && method(.*->getCommand())") */ public function replaceCommandWithDomainCommand(JoinPointInterface $joinPoint) { /** @var Request $proxy */ $proxy = $joinPoint->getProxy(); if ($proxy->getControllerObjectName() === DomainCommandController::class) { ObjectAccess::setProperty($proxy, 'command', $this->buildDomainCommand($proxy->getControllerCommandName()), TRUE); } return $joinPoint->getAdviceChain()->proceed($joinPoint); }
/** * @Flow\Around("method(TYPO3\TYPO3CR\Domain\Model\NodeType->__construct())") * @return void */ public function enrichNodeTypeConfiguration(JoinPointInterface $joinPoint) { $configuration = $joinPoint->getMethodArgument('configuration'); $nodeTypeName = $joinPoint->getMethodArgument('name'); $this->addEditorDefaultsToNodeTypeConfiguration($nodeTypeName, $configuration); $this->addLabelsToNodeTypeConfiguration($nodeTypeName, $configuration); $joinPoint->setMethodArgument('configuration', $configuration); $joinPoint->getAdviceChain()->proceed($joinPoint); }
/** * Convert the object to its context path, if we deal with TYPO3CR nodes. * * @Flow\Around("method(TYPO3\Flow\Persistence\AbstractPersistenceManager->convertObjectToIdentityArray())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint the joinpoint * @return string|array the context path to be used for routing */ public function convertNodeToContextPathForRouting(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $objectArgument = $joinPoint->getMethodArgument('object'); if ($objectArgument instanceof NodeInterface) { return $objectArgument->getContextPath(); } else { return $joinPoint->getAdviceChain()->proceed($joinPoint); } }
/** * @Flow\Around("method(TYPO3\Neos\Controller\Frontend\NodeController->handleShortcutNode())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return void */ public function dontResolveShortcutsInFrontend(JoinPointInterface $joinPoint) { $node = $joinPoint->getMethodArgument('node'); if ($node instanceof NodeInterface) { if (in_array($node->getProperty('targetMode'), $this->legitShortcutTargets)) { $joinPoint->getAdviceChain()->proceed($joinPoint); } } }
/** * * @Flow\Around("methodAnnotatedWith(Sandstorm\PhpProfiler\Annotations\Profile)") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return array Result of the target method */ public function profileAround(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $run = \Sandstorm\PhpProfiler\Profiler::getInstance()->getRun(); $tag = str_replace('\\', '_', $joinPoint->getClassName()) . ':' . $joinPoint->getMethodName(); $run->startTimer($tag); $result = $joinPoint->getAdviceChain()->proceed($joinPoint); $run->stopTimer($tag); return $result; }
/** * Invokes a given join point * * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint * @return mixed */ public function Flow_Aop_Proxy_invokeJoinPoint(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { if (__CLASS__ !== $joinPoint->getClassName()) { return parent::Flow_Aop_Proxy_invokeJoinPoint($joinPoint); } if (isset($this->Flow_Aop_Proxy_methodIsInAdviceMode[$joinPoint->getMethodName()])) { return call_user_func_array(['self', $joinPoint->getMethodName()], $joinPoint->getMethodArguments()); } }
/** * @test * @return void */ public function generateUuidGeneratesUuidAndRegistersProxyAsNewObject() { $className = 'Class' . md5(uniqid(mt_rand(), TRUE)); eval('class ' . $className . ' implements \\TYPO3\\Flow\\Persistence\\Aspect\\PersistenceMagicInterface { public $Persistence_Object_Identifier = NULL; }'); $object = new $className(); $this->mockJoinPoint->expects($this->atLeastOnce())->method('getProxy')->will($this->returnValue($object)); $this->mockPersistenceManager->expects($this->atLeastOnce())->method('registerNewObject')->with($object); $this->persistenceMagicAspect->generateUuid($this->mockJoinPoint); $this->assertEquals(36, strlen($object->Persistence_Object_Identifier)); }
/** * Check if department of logged in User match with department property of page node and hide this node if true * * @param \TYPO3\Flow\AOP\JoinPointInterface $joinPoint * @Flow\After("method(TYPO3\Neos\EventLog\Integrations\TYPO3CRIntegrationService->afterNodePublishing(NodeInterface $node, $propertyName, $oldValue, $newValue))") * @return boolean */ public function departmentNameChanged($joinPoint) { if ($joinPoint->getMethodArgument('node')->hasProperty("departmentName")) { // flush node caches after department change foreach ($joinPoint->getMethodArgument('node')->getChildNodes() as $childnode) { $childnode->getContext()->getFirstLevelNodeCache()->flush(); } $joinPoint->getMethodArgument('node')->getContext()->getFirstLevelNodeCache()->flush(); } }
/** * @Flow\Around("method(Flowpack\Neos\FrontendLogin\Security\NeosRequestPattern->matchRequest())") * @param JoinPointInterface $joinPoint * @return boolean */ public function enhanceMatchRequest(JoinPointInterface $joinPoint) { $request = $joinPoint->getMethodArgument('request'); $requestPath = $request->getHttpRequest()->getUri()->getPath(); if ($joinPoint->getProxy()->getPattern() === NeosRequestPattern::PATTERN_BACKEND) { if (strpos($requestPath, '/che!') === 0) { return true; } } return $joinPoint->getAdviceChain()->proceed($joinPoint); }
/** * @Flow\Before("method(TYPO3\Neos\Routing\FrontendNodeRoutePartHandler->matchValue())") * @return void */ public function convertRoutePartToLowerCase(\TYPO3\Flow\AOP\JoinPointInterface $joinPoint) { $requestPath = $joinPoint->getMethodArgument('requestPath'); if (strpos($requestPath, 'user')) { $parts = explode("user", $requestPath); $lowerCaseRequestPath = strtolower($parts[0]) . "user" . $parts[1]; } else { $lowerCaseRequestPath = strtolower($requestPath); } $joinPoint->setMethodArgument('requestPath', $lowerCaseRequestPath); }
/** * @Flow\Around("setting(TYPO3.Neos.typoScript.enableObjectTreeCache) && method(TYPO3\Neos\Domain\Service\TypoScriptService->getMergedTypoScriptObjectTree())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return mixed */ public function cacheGetMergedTypoScriptObjectTree(JoinPointInterface $joinPoint) { $currentSiteNode = $joinPoint->getMethodArgument('startNode'); $cacheIdentifier = str_replace('.', '_', $currentSiteNode->getContext()->getCurrentSite()->getSiteResourcesPackageKey()); if ($this->typoScriptCache->has($cacheIdentifier)) { $typoScriptObjectTree = $this->typoScriptCache->get($cacheIdentifier); } else { $typoScriptObjectTree = $joinPoint->getAdviceChain()->proceed($joinPoint); $this->typoScriptCache->set($cacheIdentifier, $typoScriptObjectTree); } return $typoScriptObjectTree; }
/** * @Flow\After("method(TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository->remove())") * @return void */ public function indexNodeBeforeRemovingNodeData(JoinPointInterface $joinPoint) { $object = $joinPoint->getMethodArgument('object'); if ($object instanceof NodeData) { $nodeData = $object; } if ($object instanceof Node) { $nodeData = $object->getNodeData(); } if ($nodeData instanceof NodeData) { $this->indexService->removeIndex($nodeData); } }
/** * Add the current node identifier to be used for cache entry tagging * * @Flow\Before("method(TYPO3\Flow\Mvc\Routing\RouterCachingService->extractUuids())") * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return void */ public function addCurrentNodeIdentifier(JoinPointInterface $joinPoint) { $values = $joinPoint->getMethodArgument('values'); if (!isset($values['node']) || strpos($values['node'], '@') === false) { return; } list($nodePath, $contextArguments) = explode('@', $values['node']); $context = $this->getContext($contextArguments); $node = $context->getNode($nodePath); if ($node instanceof NodeInterface) { $values['node-identifier'] = $node->getIdentifier(); $joinPoint->setMethodArgument('values', $values); } }
/** * @Flow\AfterReturning("method(TYPO3\Flow\Security\Account->authenticationAttempted())") * @param JoinPointInterface $joinPoint * @return void */ public function bruteForceAccountLocking(JoinPointInterface $joinPoint) { $failedAttemptsThreshold = intval($this->settings['failedAttemptsThreshold']); if ($failedAttemptsThreshold === 0) { return; } /** @var \TYPO3\Flow\Security\Account $account */ $account = $joinPoint->getProxy(); // Deactivate account if failed attempts exceed threshold if ($account->getFailedAuthenticationCount() >= $failedAttemptsThreshold) { $account->setExpirationDate(new \DateTime()); $this->sendNotificationMail($account); } }
/** * @param JoinPointInterface $joinPoint * @Flow\After("method(TYPO3\TypoScript\Core\Runtime->pushContextArray())") * @return void */ public function extendContextWithMetaDataRootNode(JoinPointInterface $joinPoint) { /** @var \TYPO3\TypoScript\Core\Runtime $runtime */ $runtime = $joinPoint->getProxy(); $currentContext = $runtime->getCurrentContext(); if (isset($currentContext['node'])) { /** @var \TYPO3\TYPO3CR\Domain\Model\NodeInterface $node */ $node = $currentContext['node']; $metaDataRootNode = $this->nodeService->findOrCreateMetaDataRootNode($node->getContext()); $currentContext = $runtime->popContext(); $currentContext[MetaDataRepository::METADATA_ROOT_NODE_NAME] = $metaDataRootNode; $runtime->pushContextArray($currentContext); } }
/** * Around advice, wrapping every method of a scope session object. It redirects * all method calls to the session object once there is one. * * @param \TYPO3\Flow\Aop\JoinPointInterface $joinPoint The current join point * @return mixed * @Flow\Around("filter(TYPO3\Flow\Session\Aspect\SessionObjectMethodsPointcutFilter)") */ public function callMethodOnOriginalSessionObject(\TYPO3\Flow\Aop\JoinPointInterface $joinPoint) { $objectName = $this->objectManager->getObjectNameByClassName(get_class($joinPoint->getProxy())); $methodName = $joinPoint->getMethodName(); $proxy = $joinPoint->getProxy(); if (!isset($this->sessionOriginalInstances[$objectName])) { $this->sessionOriginalInstances[$objectName] = $this->objectManager->get($objectName); } if ($this->sessionOriginalInstances[$objectName] === $proxy) { return $joinPoint->getAdviceChain()->proceed($joinPoint); } else { return call_user_func_array(array($this->sessionOriginalInstances[$objectName], $methodName), $joinPoint->getMethodArguments()); } }
/** * This aspect will block loadNodeTypes from being called and will instead * call overrideNodeTypes with a modified configuration. * * @Flow\Around("method(TYPO3\TYPO3CR\Domain\Service\NodeTypeManager->loadNodeTypes())") * @param JoinPointInterface $joinPoint The current join point * @return void */ public function addDynamicNodeConfiguration(JoinPointInterface $joinPoint) { $completeNodeTypeConfiguration = $this->configurationManager->getConfiguration('NodeTypes'); $dynamicNodeTypes = $this->dynamicNodeTypeRepository->findAll(); /* @var $dynamicNodeType DynamicNodeType */ foreach ($dynamicNodeTypes as $dynamicNodeType) { $dynamicNodeName = $dynamicNodeType->getValidNodeTypeName($this->settings['nodeNamespace']); if (!array_key_exists($dynamicNodeName, $completeNodeTypeConfiguration)) { $dynamicProperties = array(); /* @var $dynamicProperty DynamicProperty */ foreach ($dynamicNodeType->getDynamicProperties() as $dynamicProperty) { $dynamicPropertyName = $dynamicProperty->getValidPropertyName($this->settings['propertyPrefix']); $dynamicProperties[$dynamicPropertyName] = array('type' => 'string', 'defaultValue' => $dynamicProperty->getDefaultValue(), 'ui' => array('label' => $dynamicProperty->getLabel(), 'reloadIfChanged' => TRUE, 'inlineEditable' => TRUE, 'aloha' => array('placeholder' => $dynamicProperty->getPlaceholder()), 'inspector' => array('group' => 'dynamicProperties', 'editorOptions' => array('placeholder' => $dynamicProperty->getPlaceholder())))); } $newNodeConfiguration = array('superTypes' => $this->settings['superTypes'], 'abstract' => FALSE, 'ui' => array('label' => $dynamicNodeType->getLabel())); // Only set properties if there are any. // If properties is set to an empty array a bug in Neos will break the node configuration. // This leads to an empty inspector and strange error messages. if (count($dynamicProperties)) { $newNodeConfiguration['properties'] = $dynamicProperties; } $completeNodeTypeConfiguration[$dynamicNodeName] = $newNodeConfiguration; } } /* @var $nodeTypeManager NodeTypeManager */ $nodeTypeManager = $joinPoint->getProxy(); $nodeTypeManager->overrideNodeTypes($completeNodeTypeConfiguration); }
/** * @test * @todo adjust when AfterInvocationInterceptor is used again */ public function enforcePolicyDoesNotInvokeInterceptorIfAuthorizationChecksAreDisabled() { $this->mockAdviceChain->expects($this->once())->method('proceed')->with($this->mockJoinPoint); $this->mockJoinPoint->expects($this->once())->method('getAdviceChain')->will($this->returnValue($this->mockAdviceChain)); $this->mockSecurityContext->expects($this->atLeastOnce())->method('areAuthorizationChecksDisabled')->will($this->returnValue(true)); $this->mockPolicyEnforcementInterceptor->expects($this->never())->method('invoke'); $this->policyEnforcementAspect->enforcePolicy($this->mockJoinPoint); }
/** * Returns a string message, giving insights what happened during privilege evaluation. * * @param string $privilegeReasonMessage * @return string */ protected function renderDecisionReasonMessage($privilegeReasonMessage) { if (count($this->securityContext->getRoles()) === 0) { $rolesMessage = 'No authenticated roles'; } else { $rolesMessage = 'Authenticated roles: ' . implode(', ', array_keys($this->securityContext->getRoles())); } return sprintf('Access denied for method' . chr(10) . 'Method: %s::%s()' . chr(10) . chr(10) . '%s' . chr(10) . chr(10) . '%s', $this->joinPoint->getClassName(), $this->joinPoint->getMethodName(), $privilegeReasonMessage, $rolesMessage); }