Nette\Forms\Container::addComponent PHP 메소드

addComponent() 공개 메소드

Adds the specified component to the IContainer.
public addComponent ( Nette\ComponentModel\IComponent $component, $name, $insertBefore = NULL ) : self
$component Nette\ComponentModel\IComponent
리턴 self
    public function addComponent(Nette\ComponentModel\IComponent $component, $name, $insertBefore = NULL)
    {
        parent::addComponent($component, $name, $insertBefore);
        if ($this->currentGroup !== NULL) {
            $this->currentGroup->add($component);
        }
        return $this;
    }

Usage Example

예제 #1
0
 /**
  * @param string $name
  * @throws InvalidArgumentException
  * @throws NotImplementedException
  * @return EntityBuilder
  */
 public function relationBuilder($name)
 {
     $class = $this->getMetadata();
     if (!$class->hasAssociation($name)) {
         throw new InvalidArgumentException("Entity {$this->metadata->name} has no association '{$name}'.");
     }
     if (isset($this->relationBuilders[$name])) {
         return $this->relationBuilders[$name];
     }
     if ($class->isSingleValuedAssociation($name)) {
         if (!$this->container->getComponent($name, FALSE)) {
             $this->container->addComponent(new Nette\Forms\Container(), $name);
         }
         $builder = new EntityBuilder($this->container[$name], $this->mapper, $this->controlFactory, $this->em);
         if ($this->entity && ($relation = $class->getFieldValue($this->entity, $name))) {
             $builder->bindEntity($relation);
         } else {
             $builder->bindEntityType($class->getAssociationTargetClass($name));
         }
         return $this->relationBuilders[$name] = $builder;
     } else {
         throw new NotImplementedException();
     }
 }
All Usage Examples Of Nette\Forms\Container::addComponent