本文整理汇总了PHP中Nette\Utils\ObjectMixin::getExtensionMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin::getExtensionMethod方法的具体用法?PHP ObjectMixin::getExtensionMethod怎么用?PHP ObjectMixin::getExtensionMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\ObjectMixin
的用法示例。
在下文中一共展示了ObjectMixin::getExtensionMethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: extensionMethod
/**
* Adding method to class.
*
* @param $name
* @param null $callback
*
* @throws \Nette\MemberAccessException
* @return callable|null
*/
public static function extensionMethod($name, $callback = NULL)
{
if (strpos($name, '::') === FALSE) {
$class = get_called_class();
} else {
list($class, $name) = explode('::', $name);
}
if ($callback === NULL) {
return ObjectMixin::getExtensionMethod($class, $name);
} else {
ObjectMixin::setExtensionMethod($class, $name, $callback);
}
}
示例2: __call
public function __call($name, $args)
{
if ($callback = Nette\Utils\ObjectMixin::getExtensionMethod(get_class($this), $name)) {
return Nette\Utils\Callback::invoke($callback, $this, ...$args);
}
return parent::__call($name, $args);
}
示例3: extensionMethod
/**
* @return mixed
* @deprecated use Nette\Utils\ObjectMixin::setExtensionMethod()
*/
public static function extensionMethod($name, $callback = NULL)
{
if (strpos($name, '::') === FALSE) {
$class = get_called_class();
} else {
list($class, $name) = explode('::', $name);
$class = (new \ReflectionClass($class))->getName();
}
trigger_error("Extension methods such as {$class}::{$name}() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
if ($callback === NULL) {
return ObjectMixin::getExtensionMethod($class, $name);
} else {
ObjectMixin::setExtensionMethod($class, $name, $callback);
}
}
示例4: registerReplicator
private function registerReplicator()
{
if (!ObjectMixin::getExtensionMethod(SubmitButton::class, 'addCreateOnClick')) {
Replicator::register();
}
}
示例5: __call
public function __call($name, $args)
{
if ($callback = Nette\Utils\ObjectMixin::getExtensionMethod(__CLASS__, $name)) {
return $callback($this, ...$args);
}
Nette\Utils\ObjectMixin::strictCall(__CLASS__, $name);
}
示例6: extensionMethod
/**
* Adding method to class.
* @param string method name
* @param callable
* @return mixed
*/
public static function extensionMethod($name, $callback = NULL)
{
if (strpos($name, '::') === FALSE) {
$class = get_called_class();
} else {
list($class, $name) = explode('::', $name);
$class = (new \ReflectionClass($class))->getName();
}
if ($callback === NULL) {
return Nette\Utils\ObjectMixin::getExtensionMethod($class, $name);
} else {
Nette\Utils\ObjectMixin::setExtensionMethod($class, $name, $callback);
}
}