当前位置: 首页>>代码示例>>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;未经允许,请勿转载。