本文整理汇总了PHP中Nette\Forms\Container::addComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::addComponent方法的具体用法?PHP Container::addComponent怎么用?PHP Container::addComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Container
的用法示例。
在下文中一共展示了Container::addComponent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: relationBuilder
/**
* @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();
}
}
示例2: createControl
/**
* @param IControlConfig $config
* @param \Nette\Forms\Container $container
* @throws \NForms\Exceptions\UnexpectedValueException
* @return Forms\Controls\BaseControl
*/
protected function createControl(IControlConfig $config, Forms\Container $container)
{
// Before
if ($this->beforeControlCreateOp) {
$this->beforeControlCreateOp->beforeCreateControl($config);
}
// Create
$control = $this->controlFactory->createControl($config);
if (!$control instanceof Forms\Controls\BaseControl) {
throw new UnexpectedValueException("Control created by factory has to be subclass of Nette\\Forms\\Controls\\BaseControl, given " . (is_object($control) ? get_class($control) : gettype($control)) . ".");
}
$container->addComponent($control, $config->getComponentName());
// Set attributes
if (($placeholder = $config->getPlaceholder()) !== NULL) {
$placeholder = $control->translate($placeholder);
$control->controlPrototype->addAttributes(array('placeholder' => $placeholder));
}
if (($description = $config->getDescription()) !== NULL) {
$control->setOption('description', $description);
}
$control->controlPrototype->addAttributes($config->getAttributes());
$control->setRequired($config->getRequired());
// After
if ($this->afterControlCreateOp) {
$this->afterControlCreateOp->afterCreateControl($control, $config);
}
// Add control to groups
foreach ($config->getGroups() as $groupConfig) {
$group = self::getControlGroup($container, $groupConfig);
$group->add($control);
}
return $control;
}
示例3: addComponent
/**
* @param \Nette\ComponentModel\IComponent $component
* @param $name
* @param null $insertBefore
* @return \Nette\ComponentModel\Container|\Nette\Forms\Container
*/
public function addComponent(Nette\ComponentModel\IComponent $component, $name, $insertBefore = NULL)
{
$group = $this->currentGroup;
$this->currentGroup = NULL;
parent::addComponent($component, $name, $insertBefore);
$this->currentGroup = $group;
return $this;
}
示例4: addEditorSelector
/**
* @param Forms\Container $container
* @param string $name
* @param RepositoryContainer $orm
* @param NULL|bool $editable
*/
public static function addEditorSelector(Forms\Container $container, $name, RepositoryContainer $orm, $editable = FALSE)
{
$container->addComponent(new self($orm, $editable), $name);
}
示例5: addContainer
/**
* @param Nette\Forms\Container $parent
* @param string $name
* @param IFormEntity|NULL $entity
* @return Container
*/
protected function addContainer(Nette\Forms\Container $parent, $name, IFormEntity $entity = NULL)
{
$container = $this->getContainerFactory($name)->create($entity);
$parent->addComponent($container, $name);
return $container;
}