Created
October 8, 2010 09:30
-
-
Save fprochazka/616552 to your computer and use it in GitHub Desktop.
Automatické načítání formulářů
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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