Skip to content

Commit

Permalink
FormElements: Correctly load decorators by name
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Jun 23, 2023
1 parent 413480e commit 914f083
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/FormElement/FormElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,15 @@ public function setDefaultElementDecorator($decorator)
} else {
$this->ensureDefaultElementDecoratorLoaderRegistered();

$d = $this->loadPlugin('decorator', $decorator);
$class = $this->loadPlugin('decorator', $decorator);
if (! $class) {
throw new InvalidArgumentException(sprintf(
"Can't create decorator of unknown type '%s",
$decorator
));
}

$d = new $class();
if (! $d instanceof FormElementDecorator && ! $d instanceof DecoratorInterface) {
throw new InvalidArgumentException(sprintf(
"Expected instance of %s for decorator '%s',"
Expand Down

0 comments on commit 914f083

Please sign in to comment.