Skip to content

Instantly share code, notes, and snippets.

@Kcko
Forked from matej21/FooControl.php
Last active August 29, 2015 14:05
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 Kcko/e19a337dc73e4175d2c0 to your computer and use it in GitHub Desktop.
Save Kcko/e19a337dc73e4175d2c0 to your computer and use it in GitHub Desktop.
Ukázková komponenta - attached
<?php
use Nette\Application\UI;
class FooControl extends UI\Control
{
public function __construct(...)
{
//predani parametru a zavislosti
}
public function attached($presenter)
{
parent::attached($presenter); //nezapomenout zavolat
if($presenter instanceof UI\Presenter) { //jelikoz to muze byt i necho jinyho
//tady nejdriv muzes pracovat s presenterem - vytvaret linky, plnit sablonu....
}
}
public function handleFoo($bar) //zpracovani signalu foo s parametrem bar
{
//...
}
public function render()
{
$this->template->...
$this->template->render();
}
/*
jeste existujou pohledy pro komponenty, ale ty nedoporucuju, nefungujou s ajaxem
vykreslujou se pomoci {control foo:view}
v {control} muzes i predavat parametry, {control foo $xx, $yy} ale taky nedoporucuju, stejny problem jako s view
*/
public function renderView()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment