[Form] Add exception to FormRenderer about non-unique block names

This commit is contained in:
Jáchym Toušek 2016-06-19 11:04:47 +02:00
parent 0854c121c9
commit c6db6f3d50
1 changed files with 5 additions and 4 deletions

View File

@ -253,10 +253,11 @@ class FormRenderer implements FormRendererInterface
// Escape if no resource exists for this block
if (!$resource) {
throw new LogicException(sprintf(
'Unable to render the form as none of the following blocks exist: "%s".',
implode('", "', array_reverse($blockNameHierarchy))
));
if (count($blockNameHierarchy) !== count(array_unique($blockNameHierarchy))) {
throw new LogicException(sprintf('Unable to render the form because the block names array contains duplicates: "%s".', implode('", "', array_reverse($blockNameHierarchy))));
}
throw new LogicException(sprintf('Unable to render the form as none of the following blocks exist: "%s".', implode('", "', array_reverse($blockNameHierarchy))));
}
// Merge the passed with the existing attributes