Skip to content

Commit 908a0db

Browse files
committed
Component::createComponent() warns on non-presenter components [Closes nette/forms#147]
1 parent 24984e4 commit 908a0db

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Application/UI/Component.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ public function getUniqueId(): string
7373
}
7474

7575

76+
77+
protected function createComponent(string $name): ?Nette\ComponentModel\IComponent
78+
{
79+
$res = parent::createComponent($name);
80+
if (!$res instanceof SignalReceiver && !$res instanceof StatePersistent) {
81+
$type = get_class($res);
82+
trigger_error("It seems that component '$name' of type $type is not intended to for in the Presenter.", E_USER_NOTICE);
83+
}
84+
return $res;
85+
}
86+
87+
7688
protected function validateParent(Nette\ComponentModel\IContainer $parent): void
7789
{
7890
parent::validateParent($parent);

0 commit comments

Comments
 (0)