Skip to content

Commit 8484272

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

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/Application/UI/Component.php

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

6868

69-
protected function createComponent(string $name): ?Nette\ComponentModel\IComponent
69+
public function addComponent(Nette\ComponentModel\IComponent $component, ?string $name, string $insertBefore = null): static
7070
{
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);
71+
if (!$component instanceof SignalReceiver && !$component instanceof StatePersistent) {
72+
throw new Nette\InvalidStateException("Component '$name' of type " . gettype($component) . ' is not intended to be used in the Presenter.');
7573
}
76-
return $res;
74+
return parent::addComponent($component, $name, $insertBefore = null);
7775
}
7876

7977

0 commit comments

Comments
 (0)