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


PHP Utils\ObjectMixin類代碼示例

本文整理匯總了PHP中Nette\Utils\ObjectMixin的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectMixin類的具體用法?PHP ObjectMixin怎麽用?PHP ObjectMixin使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ObjectMixin類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __call

 /**
  * Simple gate for Nette object events.
  * @param  string method name
  * @param  array arguments
  * @return mixed
  * @throws MemberAccessException
  */
 public function __call($name, $args)
 {
     if ($name >= 'onA' && $name < 'on_') {
         return ObjectMixin::call($this, $name, $args);
     } else {
         throw new MemberAccessException($name);
     }
 }
開發者ID:instante,項目名稱:utils,代碼行數:15,代碼來源:ObjectEvents.php

示例2: 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

示例3: validateConfig

 /**
  * Checks whether $config contains only $expected items and returns combined array.
  * @return array
  * @throws Nette\InvalidStateException
  */
 public function validateConfig(array $expected, array $config = NULL, $name = NULL)
 {
     if (func_num_args() === 1) {
         return $this->config = $this->validateConfig($expected, $this->config);
     }
     if ($extra = array_diff_key((array) $config, $expected)) {
         $name = $name ?: $this->name;
         $hint = Nette\Utils\ObjectMixin::getSuggestion(array_keys($expected), key($extra));
         $extra = $hint ? key($extra) : implode(", {$name}.", array_keys($extra));
         throw new Nette\InvalidStateException("Unknown configuration option {$name}.{$extra}" . ($hint ? ", did you mean {$name}.{$hint}?" : '.'));
     }
     return Config\Helpers::merge($config, $expected);
 }
開發者ID:Northys,項目名稱:di,代碼行數:18,代碼來源:CompilerExtension.php

示例4: fireEvent

 public function fireEvent($method, $args = [])
 {
     if (!method_exists($this, $method)) {
         throw new InvalidArgumentException("Event '{$method}' does not exist.");
     }
     $this->eventCheck = FALSE;
     call_user_func_array([$this, $method], $args);
     if (!$this->eventCheck) {
         throw new InvalidStateException("Event '{$method}' was not correctly propagate to overwritten methods.");
     }
     if (property_exists($this, $method)) {
         ObjectMixin::call($this, $method, $args);
     }
 }
開發者ID:Zarganwar,項目名稱:orm,代碼行數:14,代碼來源:EventEntityFragment.php

示例5: hasProperty

 public function hasProperty(ClassReflection $classReflection, string $propertyName) : bool
 {
     $traitNames = $this->getTraitNames($classReflection->getNativeReflection());
     if (!in_array(\Nette\SmartObject::class, $traitNames, true)) {
         return false;
     }
     $property = \Nette\Utils\ObjectMixin::getMagicProperty($classReflection->getName(), $propertyName);
     if ($property === null) {
         return false;
     }
     $getterMethod = $this->getMethodByProperty($classReflection, $propertyName);
     if ($getterMethod === null) {
         return false;
     }
     return $getterMethod->isPublic();
 }
開發者ID:phpstan,項目名稱:phpstan-nette,代碼行數:16,代碼來源:SmartObjectPropertiesClassReflectionExtension.php

示例6: __unset

 /**
  * Removes property.
  * @param  string  property name
  * @return void
  * @throws Nette\MemberAccessException
  */
 public function __unset($name)
 {
     Nette\Utils\ObjectMixin::remove($this, $name);
 }
開發者ID:KinaMarie,項目名稱:security,代碼行數:10,代碼來源:Identity.php

示例7: __call

 public function __call($name, $args)
 {
     if (method_exists(ClassType::class, $name)) {
         trigger_error("getReflection()->{$name}() is deprecated, use Nette\\Reflection\\ClassType::from(\$presenter)->{$name}()", E_USER_DEPRECATED);
         return call_user_func_array([new ClassType($this->getName()), $name], $args);
     }
     Nette\Utils\ObjectMixin::strictCall(get_class($this), $name);
 }
開發者ID:hrach,項目名稱:nette-application,代碼行數:8,代碼來源:ComponentReflection.php

示例8: __get

 public function __get($name)
 {
     return ObjectMixin::get($this, $name);
 }
開發者ID:WebChemistry,項目名稱:filter,代碼行數:4,代碼來源:DataFacade.php

示例9: __unset

 /**
  * Access to undeclared property.
  *
  * @param string $name
  *
  * @throws \Nette\MemberAccessException
  * @return void
  */
 public function __unset($name)
 {
     if ($name === '_conn') {
         $this->{$name} = NULL;
         return;
     }
     ObjectMixin::remove($this, $name);
 }
開發者ID:LidskaSila,項目名稱:Doctrine,代碼行數:16,代碼來源:Connection.php

示例10: getComponent

 /**
  * Returns component specified by name or path.
  * @param  string
  * @param  bool   throw exception if component doesn't exist?
  * @return IComponent|NULL
  */
 public function getComponent($name, $need = TRUE)
 {
     if (isset($this->components[$name])) {
         return $this->components[$name];
     }
     if (is_int($name)) {
         $name = (string) $name;
     } elseif (!is_string($name)) {
         throw new Nette\InvalidArgumentException(sprintf('Component name must be integer or string, %s given.', gettype($name)));
     } else {
         $a = strpos($name, self::NAME_SEPARATOR);
         if ($a !== FALSE) {
             $ext = (string) substr($name, $a + 1);
             $name = substr($name, 0, $a);
         }
         if ($name === '') {
             if ($need) {
                 throw new Nette\InvalidArgumentException('Component or subcomponent name must not be empty string.');
             }
             return;
         }
     }
     if (!isset($this->components[$name])) {
         $component = $this->createComponent($name);
         if ($component) {
             if (!$component instanceof IComponent) {
                 throw new Nette\UnexpectedValueException('Method createComponent() did not return Nette\\ComponentModel\\IComponent.');
             } elseif (!isset($this->components[$name])) {
                 $this->addComponent($component, $name);
             }
         }
     }
     if (isset($this->components[$name])) {
         if (!isset($ext)) {
             return $this->components[$name];
         } elseif ($this->components[$name] instanceof IContainer) {
             return $this->components[$name]->getComponent($ext, $need);
         } elseif ($need) {
             throw new Nette\InvalidArgumentException("Component with name '{$name}' is not container and cannot have '{$ext}' component.");
         }
     } elseif ($need) {
         $hint = Nette\Utils\ObjectMixin::getSuggestion(array_merge(array_keys($this->components), array_map('lcfirst', preg_filter('#^createComponent([A-Z0-9].*)#', '$1', get_class_methods($this)))), $name);
         throw new Nette\InvalidArgumentException("Component with name '{$name}' does not exist" . ($hint ? ", did you mean '{$hint}'?" : '.'));
     }
 }
開發者ID:nextras,項目名稱:forms,代碼行數:51,代碼來源:ComponentControlTrait.php

示例11: fireEvent

 protected function fireEvent(IEntity $entity, $event)
 {
     if (!property_exists($this, $event)) {
         throw new InvalidArgumentException("Event '{$event}' is not defined.");
     }
     $entity->fireEvent($event);
     ObjectMixin::call($this, $event, [$entity]);
 }
開發者ID:Vyki,項目名稱:orm,代碼行數:8,代碼來源:Repository.php

示例12: __unset

 /**
  * Access to undeclared property.
  *
  * @param string $name
  *
  * @throws \Nette\MemberAccessException
  * @return void
  */
 public function __unset($name)
 {
     ObjectMixin::remove($this, $name);
 }
開發者ID:Richmond77,項目名稱:learning-nette,代碼行數:12,代碼來源:EventManager.php

示例13:

 /**
  * @param  string
  * @return ActiveRow|mixed
  * @throws Nette\MemberAccessException
  */
 public function &__get($key)
 {
     $this->accessColumn($key);
     if (array_key_exists($key, $this->data)) {
         return $this->data[$key];
     }
     $referenced = $this->table->getReferencedTable($this, $key);
     if ($referenced !== FALSE) {
         $this->accessColumn($key, FALSE);
         return $referenced;
     }
     $this->removeAccessColumn($key);
     $hint = Nette\Utils\ObjectMixin::getSuggestion(array_keys($this->data), $key);
     throw new Nette\MemberAccessException("Cannot read an undeclared column '{$key}'" . ($hint ? ", did you mean '{$hint}'?" : '.'));
 }
開發者ID:ricco24,項目名稱:database,代碼行數:20,代碼來源:ActiveRow.php

示例14: __isset

 /**
  * @param $key
  * @return bool
  */
 public function __isset($key)
 {
     return ObjectMixin::has($this, $key) || $this->activeRow->__isset($key);
 }
開發者ID:filsedla,項目名稱:hyperrow,代碼行數:8,代碼來源:HyperRow.php

示例15: registerReplicator

 private function registerReplicator()
 {
     if (!ObjectMixin::getExtensionMethod(SubmitButton::class, 'addCreateOnClick')) {
         Replicator::register();
     }
 }
開發者ID:librette,項目名稱:doctrine-forms,代碼行數:6,代碼來源:ReplicatorBuilder.php


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