本文整理汇总了PHP中Nette\Utils\ObjectMixin::setExtensionMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin::setExtensionMethod方法的具体用法?PHP ObjectMixin::setExtensionMethod怎么用?PHP ObjectMixin::setExtensionMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\ObjectMixin
的用法示例。
在下文中一共展示了ObjectMixin::setExtensionMethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerControls
public static function registerControls()
{
ObjectMixin::setExtensionMethod(Container::class, 'addDatePicker', function (Container $container, $name, $label = null) {
return $container[$name] = new Controls\DatePicker($label);
});
ObjectMixin::setExtensionMethod(Container::class, 'addDateTimePicker', function (Container $container, $name, $label = null) {
return $container[$name] = new Controls\DateTimePicker($label);
});
ObjectMixin::setExtensionMethod(Container::class, 'addTypeahead', function (Container $container, $name, $label = null, $callback = null) {
return $container[$name] = new Controls\Typeahead($label, $callback);
});
}
示例2: 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);
}
}
示例3: extensionMethod
public static function extensionMethod($name, $callback = NULL)
{
if (strpos($name, '::') !== FALSE) {
// back compatibility
list(, $name) = explode('::', $name);
}
Nette\Utils\ObjectMixin::setExtensionMethod(get_called_class(), $name, $callback);
}
示例4: 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);
}
}
示例5: extensionMethod
public static function extensionMethod($name, $callback)
{
Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback);
}
示例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);
}
}