Skip to content

Commit 59eeaac

Browse files
committed
Component: only UI components can be added to presenter/component (BC break) WIP
1 parent a29c8cc commit 59eeaac

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Application/UI/Component.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,15 @@ public function getUniqueId(): string
6666
}
6767

6868

69-
protected function createComponent(string $name): ?Nette\ComponentModel\IComponent
70-
{
71-
$res = parent::createComponent($name);
72-
if ($res && !$res instanceof SignalReceiver && !$res instanceof StatePersistent) {
73-
$type = $res::class;
74-
trigger_error("It seems that component '$name' of type $type is not intended to be used in the Presenter.", E_USER_NOTICE);
69+
public function addComponent(
70+
Nette\ComponentModel\IComponent $component,
71+
?string $name,
72+
string $insertBefore = null,
73+
): static {
74+
if (!$component instanceof SignalReceiver && !$component instanceof StatePersistent) {
75+
throw new Nette\InvalidStateException("Component '$name' of type " . gettype($component) . ' is not intended to be used in the Presenter.');
7576
}
76-
return $res;
77+
return parent::addComponent($component, $name, $insertBefore = null);
7778
}
7879

7980

0 commit comments

Comments
 (0)