Пример #1
0
 /**
  * @param Nette\Forms\Container $parent
  * @param string $name
  * @param mixed $values
  */
 protected function setContainerDefaults(Nette\Forms\Container $parent, $name, $values)
 {
     if ($values === NULL) {
         return;
     }
     $component = $parent->getComponent($name);
     $factory = $this->getContainerFactory($name);
     if ($values instanceof IFormEntity) {
         $factory->setDefaultByEntity($component, $values);
     } else {
         $factory->setDefaultByCollection($component, $values);
     }
 }
Пример #2
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();
     }
 }
Пример #3
0
 /**
  * @param $name
  * @param bool $need
  * @return IComponent
  */
 public function getComponent($name, $need = TRUE)
 {
     $this->createCopies();
     return parent::getComponent($name, $need);
 }