Skip to content

Commit 9e359e6

Browse files
committed
Container: explicit support for extension methods
1 parent fa84d63 commit 9e359e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/Forms/Container.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,27 @@ public function addContainer($name)
438438
}
439439

440440

441+
/********************* extension methods ****************d*g**/
442+
443+
444+
public function __call($name, $args)
445+
{
446+
if ($callback = Nette\Utils\ObjectMixin::getExtensionMethod(__CLASS__, $name)) {
447+
return Nette\Utils\Callback::invoke($callback, $this, ...$args);
448+
}
449+
return parent::__call($name, $args);
450+
}
451+
452+
453+
public static function extensionMethod($name, $callback = NULL)
454+
{
455+
if (strpos($name, '::') !== FALSE) { // back compatibility
456+
list(, $name) = explode('::', $name);
457+
}
458+
Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback);
459+
}
460+
461+
441462
/********************* interface \ArrayAccess ****************d*g**/
442463

443464

0 commit comments

Comments
 (0)