diff --git a/packages/sonata-extra-bundle/Extension/AutoActionExtension.php b/packages/sonata-extra-bundle/Extension/AutoActionExtension.php index a61af9b8b..9f90da6b3 100644 --- a/packages/sonata-extra-bundle/Extension/AutoActionExtension.php +++ b/packages/sonata-extra-bundle/Extension/AutoActionExtension.php @@ -38,13 +38,23 @@ public function configureListFields(ListMapper $list): void } } - $list->add( - ListMapper::NAME_ACTIONS, - ListMapper::TYPE_ACTIONS, - [ - 'label' => 'Action', - 'actions' => $this->actions, - ] - ); + $routes = $admin->getRoutes(); + + foreach ($this->actions as $action => $options) { + if (!$routes->has($routes->getCode($action))) { + unset($this->actions[$action]); + } + } + + if (!empty($this->actions)) { + $list->add( + ListMapper::NAME_ACTIONS, + ListMapper::TYPE_ACTIONS, + [ + 'label' => 'Action', + 'actions' => $this->actions, + ] + ); + } } }