getExtensionMethod() public static method

Returns extension method.
public static getExtensionMethod ( $class, $name ) : mixed
return mixed
Ejemplo n.º 1
0
 /**
  * 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);
     }
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 /**
  * @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);
     }
 }
Ejemplo n.º 4
0
 private function registerReplicator()
 {
     if (!ObjectMixin::getExtensionMethod(SubmitButton::class, 'addCreateOnClick')) {
         Replicator::register();
     }
 }
Ejemplo n.º 5
0
 public function __call($name, $args)
 {
     if ($callback = Nette\Utils\ObjectMixin::getExtensionMethod(__CLASS__, $name)) {
         return $callback($this, ...$args);
     }
     Nette\Utils\ObjectMixin::strictCall(__CLASS__, $name);
 }
Ejemplo n.º 6
0
 /**
  * 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);
     }
 }