Skip to content

Instantly share code, notes, and snippets.

@duskohu
Created November 22, 2013 13:30
Show Gist options
  • Save duskohu/7599876 to your computer and use it in GitHub Desktop.
Save duskohu/7599876 to your computer and use it in GitHub Desktop.
Priklad No-injectTestControl extends BaseControl
<?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;
}
}
<?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;
}
}
<?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