Skip to content

Commit

Permalink
feat: Add ExtraProvider for Fusion rendering paths
Browse files Browse the repository at this point in the history
  • Loading branch information
paxuclus committed Aug 20, 2024
1 parent 54931f4 commit 5d3d580
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
69 changes: 69 additions & 0 deletions Classes/Scope/Extra/FusionPathProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

declare(strict_types=1);

namespace Netlogix\Sentry\Scope\Extra;

use Neos\Flow\Aop\Exception\InvalidPointcutExpressionException;
use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Fusion\Exception\RuntimeException as FusionRuntimeException;

/**
* @Flow\Scope("singleton")
* @Flow\Aspect
*/
final class FusionPathProvider implements ExtraProvider
{
private array $fusionPaths = [];

/**
* @Flow\Before("setting(Neos.Fusion.rendering.exceptionHandler) && within(Neos\Fusion\Core\ExceptionHandlers\AbstractRenderingExceptionHandler) && method(.*->handleRenderingException())")
*/
public function beforeFusionExceptionHandling(JoinPointInterface $joinPoint): void
{
if (!$joinPoint->isMethodArgument('fusionPath')) {
return;
}

$fusionPath = $joinPoint->getMethodArgument('fusionPath');
if ($joinPoint->isMethodArgument('exception')) {
$exception = $joinPoint->getMethodArgument('exception');
if ($exception instanceof FusionRuntimeException) {
$fusionPath = $exception->getFusionPath();
}
}

$this->fusionPaths[] = $fusionPath;
}

/**
* @Flow\Around("method(protected Neos\Flow\Aop\Pointcut\PointcutSettingFilter->parseConfigurationOptionPath())")
*/
public function catchPointcutSettingException(JoinPointInterface $joinPoint): void
{
try {
$joinPoint->getAdviceChain()->proceed($joinPoint);
} catch (InvalidPointcutExpressionException $exception) {
if ($joinPoint->isMethodArgument('settingComparisonExpression')) {
$settingComparisonExpression = $joinPoint->getMethodArgument('settingComparisonExpression');
if ($settingComparisonExpression === 'Neos.Fusion.rendering.exceptionHandler' && $exception->getCode() === 1230035614) {
return;
}
}

throw $exception;
}
}

public function getExtra(): array
{
if (empty($this->fusionPaths)) {
return [];
}

return [
'fusionPaths' => array_values(array_unique($this->fusionPaths)),
];
}
}
1 change: 1 addition & 0 deletions Configuration/Settings.Providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Netlogix:
'Netlogix\Sentry\Scope\Environment\FlowSettings': true

extra:
'Netlogix\Sentry\Scope\Extra\FusionPathProvider': true
'Netlogix\Sentry\Scope\Extra\ReferenceCodeProvider': true

release:
Expand Down

0 comments on commit 5d3d580

Please sign in to comment.