Skip to content

Commit

Permalink
Container: uses Nette\ComponentModel\ArrayAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Mar 18, 2018
1 parent 518dc1c commit 1f1b97b
Showing 1 changed file with 2 additions and 48 deletions.
50 changes: 2 additions & 48 deletions src/Forms/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
*/
class Container extends Nette\ComponentModel\Container implements \ArrayAccess
{
use Nette\ComponentModel\ArrayAccess;

/** @var callable[] function (Container $sender); Occurs when the form is validated */
public $onValidate;

Expand Down Expand Up @@ -434,54 +436,6 @@ public static function extensionMethod($name, /*callable*/ $callback): void
}


/********************* interface \ArrayAccess ****************d*g**/


/**
* Adds the component to the container.
* @param string|int
* @param Nette\ComponentModel\IComponent
*/
public function offsetSet($name, $component): void
{
$this->addComponent($component, $name);
}


/**
* Returns component specified by name. Throws exception if component doesn't exist.
* @param string|int
* @throws Nette\InvalidArgumentException
*/
public function offsetGet($name): Nette\ComponentModel\IComponent
{
return $this->getComponent($name, true);
}


/**
* Does component specified by name exists?
* @param string|int
*/
public function offsetExists($name): bool
{
return $this->getComponent($name, false) !== null;
}


/**
* Removes component from the container.
* @param string|int
*/
public function offsetUnset($name): void
{
$component = $this->getComponent($name, false);
if ($component !== null) {
$this->removeComponent($component);
}
}


/**
* Prevents cloning.
*/
Expand Down

0 comments on commit 1f1b97b

Please sign in to comment.