Skip to content

Commit

Permalink
BUGFIX: Use method reflection from parent class in case a flow proxy …
Browse files Browse the repository at this point in the history
…class is detected

this avoids problems with attributes that are not transferred to the generated proxy and ensures that path attributes are actually effective
  • Loading branch information
mficzel committed Apr 9, 2024
1 parent 5e2e04e commit 4dae7e9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Classes/Domain/OpenApiDocumentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Neos\Flow\Mvc\Routing\Dto\ResolveContext;
use Neos\Flow\Mvc\Routing\Dto\RouteParameters;
use Neos\Flow\ObjectManagement\ObjectManager;
use Neos\Flow\ObjectManagement\Proxy\ProxyInterface;
use Neos\Flow\Reflection\ClassReflection;
use Neos\Flow\Reflection\MethodReflection;
use Neos\Flow\Reflection\ReflectionService;
Expand Down Expand Up @@ -64,8 +65,17 @@ public function createOpenApiDocumentFromNameAndClassNamePattern(
continue;
}

// in case of flow proxies we use the method reflections of the parent class to
// get the correct attributes for the method parameters
$classReflection = new ClassReflection($className);
foreach ($classReflection->getMethods() as $methodReflection) {
$parentClassReflection = $classReflection->getParentClass();
if ($classReflection->implementsInterface(ProxyInterface::class) && $parentClassReflection && str_ends_with($parentClassReflection->name, '_Original')) {
$methodReflections = $parentClassReflection->getMethods();
} else {
$methodReflections = $classReflection->getMethods();
}

foreach ($methodReflections as $methodReflection) {
if (!str_ends_with($methodReflection->getName(), 'Action')) {
continue;
}
Expand Down Expand Up @@ -123,7 +133,7 @@ private function createPathsFromPathAndMethodReflection(ClassReflection $classRe

$controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($className);
if (!$controllerObjectName) {
throw new \DomainException('Class ' . $className . ' is unknown to the objet manager and thus cannot be processed');
throw new \DomainException('Class ' . $className . ' is unknown to the object manager and thus cannot be processed');
}
$controllerPackageKey = $this->objectManager->getPackageKeyByObjectName($controllerObjectName);
$controllerPackageNamespace = str_replace('.', '\\', $controllerPackageKey);
Expand Down

0 comments on commit 4dae7e9

Please sign in to comment.