Created
November 22, 2013 13:30
-
-
Save duskohu/7599876 to your computer and use it in GitHub Desktop.
Priklad No-injectTestControl extends BaseControl
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 App; | |
use NasExt\Templating\ITemplateFilesFormatter; | |
use Nette\Application\UI\Control; | |
use Nette\Templating\ITemplate; | |
class BaseControl extends Control | |
{ | |
/** | |
* Nejaka sluzba ktora najde sablonu pre control | |
* @var ITemplateFilesFormatter | |
*/ | |
protected $templateFilesFormatter; | |
/** | |
* INJECT TemplateFilesFormatter | |
* @param ITemplateFilesFormatter $templateFilesFormatter | |
*/ | |
public function injectTemplateFilesFormatter(ITemplateFilesFormatter $templateFilesFormatter) | |
{ | |
$this->templateFilesFormatter = $templateFilesFormatter; | |
} | |
/** | |
* @param string|NULL | |
* @return ITemplate | |
*/ | |
protected function createTemplate($class = NULL) | |
{ | |
$template = parent::createTemplate($class); | |
$template->setFile($this->templateFilesFormatter(....)); | |
return $template; | |
} | |
} |
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 App; | |
class TestPresenter extends Presenter | |
{ | |
/** | |
* Nejaka sluzba ktora najde sablonu pre control | |
* @var ITemplateFilesFormatter | |
*/ | |
protected $templateFilesFormatter; | |
/** | |
* INJECT TemplateFilesFormatter | |
* @param ITemplateFilesFormatter $templateFilesFormatter | |
*/ | |
public function injectTemplateFilesFormatter(ITemplateFilesFormatter $templateFilesFormatter) | |
{ | |
$this->templateFilesFormatter = $templateFilesFormatter; | |
} | |
/** | |
* @return TestControl | |
*/ | |
protected function createComponentTest() | |
{ | |
$control = new TestBControl(); | |
$control->injectTemplateFilesFormatter($this->templateFilesFormatter); | |
return $control; | |
} | |
} |
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 App; | |
class TestBControl extends BaseControl | |
{ | |
public function render() | |
{ | |
$this->template->data = $array(.....); | |
$this->template->render(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment