public function getMenuAction(MenuItemConfiguration $configuration, ViewInterface $view = null): string
    {
        if ($configuration->getParameter('url')) {
            return $configuration->getParameter('url');
        }
        $routeName = $configuration->getParameter('route');

        if ($configuration->getParameter('admin')) {
            $routeName = RoutingLoader::generateRouteName(
                $configuration->getParameter('admin'),
                $configuration->getParameter('action'),
                $this
                    ->applicationConfigurationStorage
                    ->getConfiguration()
                    ->getParameter('routing_name_pattern')
            );
        }
        // Map the potential parameters to the entity
        $routeParameters = [];
        $configuredParameters = $configuration->getParameter('parameters');

        if (0 !== count($configuredParameters)) {
            if (null === $view) {
                throw new Exception('A view should be provided if the menu item route requires parameters');
            }

            if (!$view->getEntities() instanceof Collection) {
                throw new Exception(
                    'Entities returned by the view should be a instance of "'.Collection::class.'" to be used in menu action'
                );
            }

            if (1 !== $view->getEntities()->count()) {
                throw new Exception('You can not map route parameters if multiple entities are loaded');
            }
            $entity = $view->getEntities()->first();
            $accessor = PropertyAccess::createPropertyAccessor();

            foreach ($configuredParameters as $name => $requirements) {
                $routeParameters[$name] = $accessor->getValue($entity, $name);
            }
        }

        return $this->router->generate($routeName, $routeParameters);
    }