Skip to content

Instantly share code, notes, and snippets.

@fprochazka
Created October 8, 2010 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fprochazka/616552 to your computer and use it in GitHub Desktop.
Save fprochazka/616552 to your computer and use it in GitHub Desktop.
Automatické načítání formulářů
<?php
namespace Kdyby\Presenter;
abstract class Base extends \Nette\Application\Presenter
{
// ...
/*=========================== Standalone Forms initialization =============================*/
public function createComponent($name)
{
$component = parent::createComponent($name);
if ($component !== Null) {
return $component;
}
if ($m = String::match($name, "~^(?P<form>.+)Form$~")) {
$ns = $this->reflection->getNamespaceName();
if (String::match($ns, "~^[^\\\\]+Module$~")) {
$formClass = $ns . "\\Form\\" . ucfirst($m['form']);
if (class_exists($formClass)) {
return $component = new $formClass($this, $name);
}
}
$formClass = "\\Kdyby\\Form\\" . ucfirst($m['form']);
if (class_exists($formClass)) {
return $component = new $formClass($this, $name);
}
}
}
/*=========================== Common Components =============================*/
public function createComponentNavigation($name)
{
return $navigation = new Kdyby\Addons\Navigation($this, $name);
}
public function createComponentTwitter($name)
{
return $twitter = new Kdyby\Addons\Twitter($this, $name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment