本文整理汇总了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);
}
}
示例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);
});
}
示例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);
}
示例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);
}
}
示例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();
}
示例6: __unset
/**
* Removes property.
* @param string property name
* @return void
* @throws Nette\MemberAccessException
*/
public function __unset($name)
{
Nette\Utils\ObjectMixin::remove($this, $name);
}
示例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);
}
示例8: __get
public function __get($name)
{
return ObjectMixin::get($this, $name);
}
示例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);
}
示例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}'?" : '.'));
}
}
示例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]);
}
示例12: __unset
/**
* Access to undeclared property.
*
* @param string $name
*
* @throws \Nette\MemberAccessException
* @return void
*/
public function __unset($name)
{
ObjectMixin::remove($this, $name);
}
示例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}'?" : '.'));
}
示例14: __isset
/**
* @param $key
* @return bool
*/
public function __isset($key)
{
return ObjectMixin::has($this, $key) || $this->activeRow->__isset($key);
}
示例15: registerReplicator
private function registerReplicator()
{
if (!ObjectMixin::getExtensionMethod(SubmitButton::class, 'addCreateOnClick')) {
Replicator::register();
}
}