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