本文整理汇总了PHP中Nette\Utils\ObjectMixin类的典型用法代码示例。如果您正苦于以下问题:PHP ObjectMixin类的具体用法?PHP ObjectMixin怎么用?PHP ObjectMixin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectMixin类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: __call
/**
* @param string $name
* @param array $args
*
* @return mixed
*/
public function __call($name, $args)
{
if (method_exists('Nette\\Utils\\ObjectMixin', 'callProperty')) {
return ObjectMixin::callProperty($this, $name, $args);
} else {
return ObjectMixin::call($this, $name, $args);
}
}
开发者ID:noikiy,项目名称:Curl,代码行数:14,代码来源:Request.php
示例17: normalizePropertyName
/**
* Převede databázový název sloupce s lomítkama na camelFont.
* @example group_id => groupId
* @param string $name
* @return string
*/
private function normalizePropertyName($name)
{
$propertyName = $name;
if (!\Nette\Utils\ObjectMixin::has($this, $name)) {
$propertyName = '';
$nameParts = explode('_', $name);
foreach ($nameParts as $key => $partName) {
$propertyName .= $key == 0 ? $partName : ucfirst($partName);
}
}
return $propertyName;
}
开发者ID:JZechy,项目名称:ZBox,代码行数:18,代码来源:BaseEntity.php
示例18: processExtensions
/** @internal */
public function processExtensions()
{
$last = $this->getExtensions(Extensions\InjectExtension::class);
$this->extensions = array_merge(array_diff_key($this->extensions, $last), $last);
$this->config = Helpers::expand(array_diff_key($this->config, self::$reserved), $this->builder->parameters) + array_intersect_key($this->config, self::$reserved);
foreach ($first = $this->getExtensions(Extensions\ExtensionsExtension::class) as $name => $extension) {
$extension->setConfig(isset($this->config[$name]) ? $this->config[$name] : []);
$extension->loadConfiguration();
}
$extensions = array_diff_key($this->extensions, $first);
foreach (array_intersect_key($extensions, $this->config) as $name => $extension) {
$extension->setConfig($this->config[$name] ?: []);
}
foreach ($extensions as $extension) {
$extension->loadConfiguration();
}
if ($extra = array_diff_key($this->extensions, $extensions, $first)) {
$extra = implode("', '", array_keys($extra));
throw new Nette\DeprecatedException("Extensions '{$extra}' were added while container was being compiled.");
} elseif ($extra = key(array_diff_key($this->config, self::$reserved, $this->extensions))) {
$hint = Nette\Utils\ObjectMixin::getSuggestion(array_keys(self::$reserved + $this->extensions), $extra);
throw new Nette\InvalidStateException("Found section '{$extra}' in configuration, but corresponding extension is missing" . ($hint ? ", did you mean '{$hint}'?" : '.'));
}
}
开发者ID:Northys,项目名称:di,代码行数:25,代码来源:Compiler.php
示例19: resolveImplement
private function resolveImplement(ServiceDefinition $def, $name)
{
$interface = $def->getImplement();
if (!interface_exists($interface)) {
throw new ServiceCreationException("Interface {$interface} used in service '{$name}' not found.");
}
self::checkCase($interface);
$rc = new ReflectionClass($interface);
$method = $rc->hasMethod('create') ? $rc->getMethod('create') : ($rc->hasMethod('get') ? $rc->getMethod('get') : NULL);
if (count($rc->getMethods()) !== 1 || !$method || $method->isStatic()) {
throw new ServiceCreationException("Interface {$interface} used in service '{$name}' must have just one non-static method create() or get().");
}
$def->setImplementType($methodName = $rc->hasMethod('create') ? 'create' : 'get');
if (!$def->getClass() && !$def->getEntity()) {
$returnType = PhpReflection::getReturnType($method);
if (!$returnType) {
throw new ServiceCreationException("Method {$interface}::{$methodName}() used in service '{$name}' has no @return annotation.");
} elseif (!class_exists($returnType)) {
throw new ServiceCreationException("Check a @return annotation of the {$interface}::{$methodName}() method used in service '{$name}', class '{$returnType}' cannot be found.");
}
$def->setClass($returnType);
}
if ($methodName === 'get') {
if ($method->getParameters()) {
throw new ServiceCreationException("Method {$interface}::get() used in service '{$name}' must have no arguments.");
}
if (!$def->getEntity()) {
$def->setFactory('@\\' . ltrim($def->getClass(), '\\'));
} elseif (!$this->getServiceName($def->getFactory()->getEntity())) {
throw new ServiceCreationException("Invalid factory in service '{$name}' definition.");
}
}
if (!$def->parameters) {
$ctorParams = array();
if (!$def->getEntity()) {
$def->setFactory($def->getClass(), $def->getFactory() ? $def->getFactory()->arguments : array());
}
if (($class = $this->resolveEntityClass($def->getFactory(), array($name => 1))) && ($rc = new ReflectionClass($class)) && ($ctor = $rc->getConstructor())) {
foreach ($ctor->getParameters() as $param) {
$ctorParams[$param->getName()] = $param;
}
}
foreach ($method->getParameters() as $param) {
$hint = PhpReflection::getParameterType($param);
if (isset($ctorParams[$param->getName()])) {
$arg = $ctorParams[$param->getName()];
if ($hint !== PhpReflection::getParameterType($arg)) {
throw new ServiceCreationException("Type hint for \${$param->getName()} in {$interface}::{$methodName}() doesn't match type hint in {$class} constructor.");
}
$def->getFactory()->arguments[$arg->getPosition()] = self::literal('$' . $arg->getName());
} elseif (!$def->getSetup()) {
$hint = Nette\Utils\ObjectMixin::getSuggestion(array_keys($ctorParams), $param->getName());
throw new ServiceCreationException("Unused parameter \${$param->getName()} when implementing method {$interface}::{$methodName}()" . ($hint ? ", did you mean \${$hint}?" : '.'));
}
$paramDef = $hint . ' ' . $param->getName();
if ($param->isOptional()) {
$def->parameters[$paramDef] = $param->getDefaultValue();
} else {
$def->parameters[] = $paramDef;
}
}
}
}
开发者ID:4iz278,项目名称:cviceni,代码行数:63,代码来源:ContainerBuilder.php
示例20: extensionMethod
public static function extensionMethod($name, $callback)
{
Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback);
}
开发者ID:nette,项目名称:finder,代码行数:4,代码来源:Finder.php
注:本文中的Nette\Utils\ObjectMixin类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论