Extension method nefunguje

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
blizz_boz
Člen | 6
+
0
-

chcel som triedu Template rozšíriť metódou assignConstants:

function Template_AssignConstants(Template $template)
{
  $template->documentsLocation = DOC_LOCATION;
  $template->imagesLocation = IMAGES_LOCATION;
  $template->templateCssLocation = TEMPLATE_CSS_LOCATION;
  $template->templateImagesLocation = TEMPLATE_IMAGES_LOCATION;
}

Template::extensionMethod('Template::assignConstants', 'Template_AssignConstants');

$template = new Template;

$template->assignConstants();

ale vyhadzuje mi to výnimku „The helper ‚assignconstants‘ was not registered.“ mám niekde chybu ?

Editoval blizz_boz (4. 8. 2009 18:23)

pmg
Člen | 372
+
0
-

Template přepisuje metodu __call, ale můžeš to zkusit jinak:

$template->registerHelper('assignConstants', 'Template_AssignConstants');

Tento řádek můžeš dát do BasePresenter::createTemplate.

protected function createTemplate()
{
	$template = parent::createTemplate();
	$template->registerHelper('assignConstants', 'Template_AssignConstants');

	return $template;
}