1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace App\Components;
13:
14: use Nette\Application\UI\Control,
15: Nette\ComponentModel\IContainer,
16: App\Interfaces as I,
17: App\Model\Action;
18: 19: 20:
21: abstract class Component extends Control implements I\IComponent, I\Iparams {
22:
23:
24: protected $action;
25:
26: protected $data;
27:
28: protected $name;
29:
30: protected $params;
31:
32: protected $buttons = array();
33:
34: protected $class = '';
35:
36: protected $controlTemplate;
37:
38: 39: 40: 41: 42: 43:
44: public function __construct(Action $action, IContainer $parent = NULL, $name = NULL) {
45: parent::__construct($parent, $name);
46: $this->action = $action;
47: $this->controlTemplate = __DIR__ . '/templates/Component.latte';
48: }
49:
50: 51: 52:
53: public function render() {
54: $template = $this->template;
55: $template->setFile($this->controlTemplate);
56: $template->name = $this->action->table->name;
57: $template->desc = $this->action->table->desc;
58: $template->source = $this->action->source;
59: $template->buttons = $this->buttons;
60: $template->class = $this->class;
61: $template->data = $this->create();
62: $template->render();
63: }
64:
65: 66: 67:
68: abstract function create();
69:
70: 71: 72: 73:
74: public function setParams($params) {
75: $this->params = $params;
76: $this->action->params = $this->params;
77: }
78: }
79: