diff --git a/Admin/DynamicListAdmin.php b/Admin/DynamicListAdmin.php index 7bab1d0f..60cfb4a2 100644 --- a/Admin/DynamicListAdmin.php +++ b/Admin/DynamicListAdmin.php @@ -45,13 +45,21 @@ public function __construct(ViewBuilderFactoryInterface $viewBuilderFactory, arr public function configureViews(ViewCollection $viewCollection): void { - $action = 'form-list'; - // TODO handle multipage views - + /** @var array $sections */ foreach ($this->config as $parent => $sections) { + if (!$viewCollection->has($parent)) { + continue; + } + + $counter = 0; + + /** @var mixed[] $config */ foreach ($sections as $key => $config) { - if (!$viewCollection->has($parent)) { - continue; + ++$counter; + + $action = 'form-list'; + if ($counter > 1) { + $action .= '-' . str_replace('_', '-', $key); } $name = $parent . '.' . $action . '-key'; @@ -59,6 +67,10 @@ public function configureViews(ViewCollection $viewCollection): void $name = $config['name']; } + if ($viewCollection->has($name)) { + throw new \RuntimeException(\sprintf('View "%s" does already exist.', $name)); + } + $requestParameters = [ 'type' => $config['type'], ]; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 6eb1ff03..7beaa7da 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,53 +1,23 @@ parameters: ignoreErrors: - - message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#" - count: 1 - path: Admin/DynamicListAdmin.php - - - - message: "#^Cannot access offset 'name' on mixed\\.$#" - count: 2 - path: Admin/DynamicListAdmin.php - - - - message: "#^Cannot access offset 'position' on mixed\\.$#" - count: 2 - path: Admin/DynamicListAdmin.php - - - - message: "#^Cannot access offset 'property' on mixed\\.$#" - count: 2 - path: Admin/DynamicListAdmin.php - - - - message: "#^Cannot access offset 'template' on mixed\\.$#" - count: 2 - path: Admin/DynamicListAdmin.php - - - - message: "#^Cannot access offset 'type' on mixed\\.$#" + message: "#^Parameter \\#1 \\$name of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewBuilderFactoryInterface\\:\\:createListViewBuilder\\(\\) expects string, mixed given\\.$#" count: 1 path: Admin/DynamicListAdmin.php - - message: "#^Cannot access offset 'view' on mixed\\.$#" - count: 2 - path: Admin/DynamicListAdmin.php - - - - message: "#^Parameter \\#1 \\$name of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewBuilderFactoryInterface\\:\\:createListViewBuilder\\(\\) expects string, mixed given\\.$#" + message: "#^Parameter \\#1 \\$tabOrder of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ListViewBuilderInterface\\:\\:setTabOrder\\(\\) expects int, mixed given\\.$#" count: 1 path: Admin/DynamicListAdmin.php - - message: "#^Parameter \\#1 \\$tabOrder of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ListViewBuilderInterface\\:\\:setTabOrder\\(\\) expects int, mixed given\\.$#" + message: "#^Parameter \\#1 \\$viewName of method Sulu\\\\Bundle\\\\AdminBundle\\\\Admin\\\\View\\\\ViewCollection\\:\\:has\\(\\) expects string, mixed given\\.$#" count: 1 path: Admin/DynamicListAdmin.php - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" - count: 1 + count: 2 path: Admin/DynamicListAdmin.php - @@ -330,11 +300,6 @@ parameters: count: 1 path: Controller/FormTokenController.php - - - message: "#^Call to an undefined method Symfony\\\\Component\\\\Form\\\\FormError\\|Symfony\\\\Component\\\\Form\\\\FormErrorIterator\\:\\:getMessage\\(\\)\\.$#" - count: 2 - path: Controller/FormWebsiteController.php - - message: "#^Cannot call method all\\(\\) on Symfony\\\\Component\\\\Form\\\\FormInterface\\|null\\.$#" count: 1