Skip to content

Commit

Permalink
Merge branch '6.x' into 7.0
Browse files Browse the repository at this point in the history
* 6.x:
  [DashboardBundle] Fix controller route attribute resolver in DashboardWidget
  • Loading branch information
acrobat committed Dec 23, 2023
2 parents 30b2225 + d5619fd commit f9f0bf2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Kunstmaan/DashboardBundle/Widget/DashboardWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function resolvedController()
{
$annotationReader = new AnnotationReader();
$reflectionMethod = new \ReflectionMethod($this->controller, 'widgetAction');

// NEXT_MAJOR Remove annotation support
$methodAnnotations = $annotationReader->getMethodAnnotations($reflectionMethod);
foreach ($methodAnnotations as $annotation) {
if ($annotation instanceof Route) {
Expand All @@ -39,6 +41,16 @@ public function resolvedController()
}
}

throw new \Exception('There is no route annotation');
$methodRouteAttributes = $reflectionMethod->getAttributes(Route::class, \ReflectionAttribute::IS_INSTANCEOF);
if ($methodRouteAttributes === []) {
throw new \Exception('There is no route annotation or attribute');
}

$attributeInstance = $methodRouteAttributes[0]->newInstance();
if (null === $attributeInstance->getName()) {
throw new \Exception('The name is not configured in the attribute');
}

return $attributeInstance->getName();
}
}

0 comments on commit f9f0bf2

Please sign in to comment.