本文整理汇总了PHP中Nette\Application\UI\Presenter::createComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP Presenter::createComponent方法的具体用法?PHP Presenter::createComponent怎么用?PHP Presenter::createComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Application\UI\Presenter
的用法示例。
在下文中一共展示了Presenter::createComponent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createComponent
/**
* @param $name
* @return Nette\ComponentModel\IComponent
* to have translated even forms add this method too
*/
protected function createComponent($name)
{
$component = parent::createComponent($name);
if ($component instanceof Form) {
}
return $component;
}
示例2: createComponent
/**
* @param string $name
* @return \Nette\ComponentModel\IComponent
*/
protected function createComponent($name = NULL)
{
$method = 'createComponent' . ucfirst($name);
$rc = $this->getReflection()->getMethod($method);
$this->checkRequirements($rc);
return parent::createComponent($name);
}
示例3: createComponent
/**
* @param string $name
* @return IComponent
*/
protected function createComponent($name)
{
$component = parent::createComponent($name);
if ($component instanceof \Nette\Forms\Form) {
$component->setTranslator($this->translator);
}
return $component;
}
示例4: createComponent
public function createComponent($name)
{
$ucname = ucfirst($name);
$method = 'createComponent' . $ucname;
$presenterReflection = $this->getReflection();
if ($presenterReflection->hasMethod($method)) {
$reflection = $presenterReflection->getMethod($method);
$this->checkRequirements($reflection);
$annotations = (array) $reflection->getAnnotation('Action');
if (!empty($annotations) && !in_array($this->getAction(), $annotations)) {
throw new ForbiddenRequestException("Creation of component '{$name}' is forbidden for action '" . $this->getAction() . "'.");
}
}
return parent::createComponent($name);
}
示例5: createComponent
protected function createComponent($name)
{
if (substr($name, -4) === 'Form') {
$formClass = 'App\\Controls\\Forms\\' . ucFirst(substr($name, 0, -4));
if (class_exists($formClass)) {
return $this->context->createInstance(FormControl::class, [$formClass]);
}
} else {
$controlClass = 'App\\Controls\\' . ucFirst($name);
if (class_exists($controlClass)) {
return $this->context->createInstance($controlClass);
}
}
return parent::createComponent($name);
}
示例6: createComponent
/**
* @author Jiří Šifalda
* @param string
* @return \Nette\Application\UI\Multiplier|\Nette\ComponentModel\IComponent
*/
protected function createComponent($name)
{
$method = 'createComponent' . ucfirst($name);
if (method_exists($this, $method)) {
$this->checkRequirements($this->getReflection()->getMethod($method));
if (\Nette\Reflection\Method::from($this, $method)->hasAnnotation('multiple')) {
$presenter = $this;
return new \Nette\Application\UI\Multiplier(function ($id) use($presenter, $method) {
$defaultArgs = array($presenter, $id);
return call_user_func_array(array($presenter, $method), $defaultArgs);
});
# in PHP 5.4 factory for multiplied component can be protected
# return new UI\Multiplier(function ($id) use ($name) {
# return $this->$method($this, $id, $this->getDataset($name));
# });
}
}
return parent::createComponent($name);
}
示例7: createComponent
protected function createComponent($name)
{
$ucname = ucfirst($name);
$method = 'createComponent' . $ucname;
$presenterReflection = $this->getReflection();
if ($presenterReflection->hasMethod($method)) {
$methodReflection = $presenterReflection->getMethod($method);
$this->checkRequirements($methodReflection);
if ($methodReflection->hasAnnotation('Actions')) {
$actions = explode(',', $methodReflection->getAnnotation('Actions'));
foreach ($actions as $key => $action) {
$actions[$key] = trim($action);
}
if (!empty($actions) and !in_array($this->getAction(), $actions)) {
throw new Nette\Application\ForbiddenRequestException("Creation of component '{$name}' is forbidden for action '{$this->action}'.");
}
}
}
return parent::createComponent($name);
}
示例8: createComponent
/**
* Component factory. Delegates the creation of components to a createComponent<Name> method.
*
* @param string component name
* @return IComponent the created component (optionally)
*/
protected function createComponent($name)
{
// parent
if (($control = parent::createComponent($name)) == TRUE) {
return $control;
}
// widget from widgetManager
if ($this->widgetManager->hasWidget($name)) {
return $this->widgetManager->getWidget($name)->invoke();
}
throw new \Nette\InvalidArgumentException("Component or widget with name '{$name}' does not exist.");
}
示例9: createComponent
/**
* Component factory. Delegates the creation of components to a createComponent<Name> method.
* @param string
* @return \Nette\ComponentModel\IComponent
*/
protected function createComponent($name)
{
$container = $this->getContext()->components;
if ($container->hasComponent($name)) {
return $container->getComponent($name, $this);
}
return parent::createComponent($name);
}