當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectMixin::setExtensionMethod方法代碼示例

本文整理匯總了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);
     });
 }
開發者ID:nextras,項目名稱:forms,代碼行數:12,代碼來源:FormsExtension.php

示例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);
     }
 }
開發者ID:Richmond77,項目名稱:learning-nette,代碼行數:22,代碼來源:EventManager.php

示例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);
 }
開發者ID:nette,項目名稱:forms,代碼行數:8,代碼來源:BaseControl.php

示例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);
     }
 }
開發者ID:nette,項目名稱:utils,代碼行數:19,代碼來源:SmartObject.php

示例5: extensionMethod

 public static function extensionMethod($name, $callback)
 {
     Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback);
 }
開發者ID:nette,項目名稱:finder,代碼行數:4,代碼來源:Finder.php

示例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);
     }
 }
開發者ID:manGoweb,項目名稱:mnamGo,代碼行數:20,代碼來源:Object.php


注:本文中的Nette\Utils\ObjectMixin::setExtensionMethod方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。