/** * @param Forms\Container $container * @param IContainerConfig $config * @param IContainerBuilder $builder * @return void */ public function afterCreateContainer(Forms\Container $container, IContainerConfig $config, IContainerBuilder $builder) { /* * If container is toOne then build inside components. * Else do nothing, because toMany container use factory given by constructor. */ if (!$config->isToMany()) { $builder->build($config, $container); } }
/** * @param IContainerConfig $containerConfig * @throws FieldNotFoundException */ protected function setupContainerConfig(IContainerConfig $containerConfig) { $name = $containerConfig->getFieldName(); $metadata = $this->getClassMetadata(); if (!$metadata->hasAssociation($name)) { throw new FieldNotFoundException("Association '{$name}' was not found in '{$this->targetClass}' class."); } $containerConfig->setTargetClass($metadata->getAssociationTargetClass($name)); $containerConfig->setMapping($metadata->getAssociationMapping($name)); $containerConfig->setToMany(!$metadata->isSingleValuedAssociation($name)); $constraintMetadata = $this->getConstraintMetadata(); if ($constraintMetadata) { $containerConfig->setConstraints($constraintMetadata->getConstraintsForField($name)); } }