php Nette-Object类(方法)实例源码

下面列出了php Nette-Object 类(方法)源码代码实例,从而了解它的用法。

作者:vbuilde    项目:framewor   
/**
  * Registers all object's events to matching methods
  * 
  * @param vBuilder\Object $object 
  */
 public function register(Nette\Object $object)
 {
     $rc = $object->getReflection();
     $rc2 = $this->getReflection();
     $publicProperties = $rc->getProperties(\ReflectionProperty::IS_PUBLIC);
     foreach ($publicProperties as $property) {
         $eventName = $property->getName();
         if (!preg_match('#^on[A-Z]#', $eventName)) {
             continue;
         }
         if ($rc2->hasMethod($eventName)) {
             array_push($object->{$eventName}, array($this, $eventName));
         }
     }
 }

作者:ublabo    项目:control   
/**
  * Register TextInputCustomLabel
  * @param  string $control_name string
  * @return void
  */
 public static function register($control_name = 'addTextCustomLabel')
 {
     Nette\Object::extensionMethod('Nette\\Forms\\Container::' . $control_name, function ($form, $name, $label = NULL, array $items = NULL) {
         $control = new self($label, $items);
         return $form[$name] = $control;
     });
 }

作者:vojtabiberl    项目:MediaStorag   
public static function register($controlName = 'addMultiSelectFileChoicer')
 {
     if (!is_string($controlName)) {
         throw new Exception(sprintf('Control name must be string, %s given', gettype($controlName)));
     }
     Nette\Object::extensionMethod('Nette\\Forms\\Container::' . $controlName, function ($form, $name, IManager $mediaManager, $namespace, $label = null, $withPrimary = true) {
         return $form[$name] = new \vojtabiberle\MediaStorage\Bridges\Nette\Forms\Controls\MultiSelectFileChoicer($mediaManager, $namespace, $label, $withPrimary);
     });
 }

作者:ublabo    项目:control   
/**
  * Register NotTranslatableSelectBox
  * @param  string $control_name string
  * @return void
  */
 public static function register($control_name = 'addNotTranslatableSelect')
 {
     Nette\Object::extensionMethod('Nette\\Forms\\Container::' . $control_name, function ($form, $name, $label = NULL, array $items = NULL, $size = NULL) {
         $control = new self($label, $items);
         if ($size > 1) {
             $control->setAttribute('size', (int) $size);
         }
         return $form[$name] = $control;
     });
 }

作者:webchemistr    项目:image   
/**
  * @param string $controlName
  * @throws ImageStorageException
  */
 public static function register($controlName = 'addMultiImageUpload')
 {
     if (!is_string($controlName)) {
         throw new ImageStorageException(sprintf('Control name must be a string, %s given', gettype($controlName)));
     }
     Object::extensionMethod(Container::class . '::' . $controlName, function ($form, $name, $label = NULL, $namespace = NULL) {
         $control = new self($label);
         $control->setNamespace($namespace);
         return $form[$name] = $control;
     });
 }

作者:zaxcm    项目:framewor   
public function __call($name, $args = [])
 {
     if (method_exists($this->acl, $name)) {
         return call_user_func_array([$this->acl, $name], $args);
     }
     return parent::__call($name, $args);
 }

作者:JakubKontr    项目:datagri   
/**
  * Allows calling $column->icon() instead of $column->setIcon (Same for title, class, ...)
  * @param  string $name
  * @param  array  $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $method_setter = 'set' . ucfirst($name);
     if (method_exists($this, $method_setter)) {
         return Nette\Utils\Callback::invokeArgs([$this, $method_setter], $args);
     }
     parent::__call($name, $args);
 }

作者:mil    项目:github-api-nett   
/**
  * @param  string
  * @return string|NULL
  */
 public function &__get($name)
 {
     if (strtolower($name) === 'info') {
         return $this->info;
     } elseif (array_key_exists($name, $this->info)) {
         return $this->info[$name];
     }
     return parent::__get($name);
 }

作者:pipaslo    项目:res   
public function &__get($name)
 {
     $service = $this->getService($name, false);
     if ($service) {
         return $service;
     }
     $object = parent::__get($name);
     return $object;
 }

作者:rokerkon    项目:Exchang   
public function &__get($name)
 {
     $val = \strtoupper($name);
     if (\defined(self::INFO . $val)) {
         $a = $this->getInfo(constant(self::INFO . $val));
         return $a;
     }
     return parent::__get($name);
 }

作者:lucien14    项目:Restfu   
/**
  * @param string $name
  * @return bool
  */
 public function __isset($name)
 {
     $isset = parent::__isset($name);
     if ($isset) {
         return TRUE;
     }
     $data = $this->getData();
     return isset($data[$name]);
 }

作者:angelca    项目:angelcam-sdk-ph   
/**
  * Returns user data value.
  * @param string property name
  * @return mixed
  */
 public function &__get($key)
 {
     if (parent::__isset($key)) {
         return parent::__get($key);
     } else {
         $data = $this->data->toArray();
         return $data[$key];
     }
 }

作者:jurasm    项目:bub   
public function __call($methodName, $args)
 {
     if (preg_match('|.*getModel([a-zA-Z0-9]+).*|', $methodName, $mtch)) {
         if (class_exists('Model\\' . $mtch[1] . 'Model')) {
             return $this->modelLoader->loadModel($mtch[1] . 'Model');
         }
     } else {
         return parent::__call($methodName, $args);
     }
 }

作者:damejidl    项目:newreli   
/**
  * @param string $name
  * @param array $args
  * @return mixed
  */
 public function __call($name, $args)
 {
     $function = 'newrelic_' . self::convertCamelCaseToUnderscore($name);
     if (!extension_loaded('newrelic')) {
         return FALSE;
     }
     if (!function_exists($function)) {
         return parent::__call($name, $args);
     }
     return call_user_func_array($function, $args);
 }

作者:icain    项目:flunorett   
public function __call($name, $args)
 {
     if (preg_match('~^create(Select|Update|Delete|Insert)$~', $name, $m)) {
         #query object factory
         $class = "Flunorette\\Queries\\{$m[1]}Query";
         $queryContext = new QueryContext(reset($args), $this);
         return new $class($queryContext);
     }
     return parent::__call($name, $args);
 }

作者:VasekPurchar    项目:khanovaskola-v   
/**
  * Call to undefined method.
  *
  * @param  string  method name
  * @param  array   arguments
  * @return mixed
  * @throws Nette\MemberAccessException
  */
 public function __call($name, $args)
 {
     $function = 'image' . $name;
     if (function_exists($function)) {
         foreach ($args as $key => $value) {
             if ($value instanceof self) {
                 $args[$key] = $value->getImageResource();
             } elseif (is_array($value) && isset($value['red'])) {
                 // rgb
                 $args[$key] = imagecolorallocatealpha($this->image, $value['red'], $value['green'], $value['blue'], $value['alpha']);
             }
         }
         array_unshift($args, $this->image);
         $res = call_user_func_array($function, $args);
         return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res;
     }
     return parent::__call($name, $args);
 }

作者:eduardobenito1    项目:jenkins-php-quickstar   
/**
  * Is property defined?
  * @param  string  property name
  * @return bool
  */
 public function __isset($key)
 {
     return isset($this->data[$key]) || parent::__isset($key);
 }

作者:redwormi    项目:fakeor   
public function __unset($name)
 {
     if (parent::__isset($name)) {
         parent::__unset($name);
     } else {
         unset($this->data->{$name});
     }
 }

作者:nett    项目:deprecate   
/**
  * Call a template run-time helper. Do not call directly.
  * @param  string  helper name
  * @param  array   arguments
  * @return mixed
  */
 public function __call($name, $args)
 {
     $lname = strtolower($name);
     if (!isset($this->helpers[$lname])) {
         foreach ($this->helperLoaders as $loader) {
             $helper = Callback::invoke($loader, $lname);
             if ($helper) {
                 $this->registerHelper($lname, $helper);
                 return Callback::invokeArgs($this->helpers[$lname], $args);
             }
         }
         return parent::__call($name, $args);
     }
     return Callback::invokeArgs($this->helpers[$lname], $args);
 }

作者:Vyk    项目:or   
public function __call($method, $args)
 {
     if (isset($this->proxyMethods[strtolower($method)])) {
         if (FindByParserHelper::parse($method, $args)) {
             return call_user_func([$this, $method], $args);
         }
         $result = call_user_func_array([$this->mapper, $method], $args);
         if (!($result instanceof ICollection || $result instanceof IEntity || $result === NULL)) {
             $result = $this->mapper->toCollection($result);
         }
         return $result;
     } else {
         return parent::__call($method, $args);
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号