Guest User

Untitled

a guest
Jun 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. <?php
  2.  
  3. class A extends Nette\Object {
  4.  
  5. // callbacks
  6. public $beforeRender;
  7.  
  8. public $template;
  9.  
  10. public function __construct() {
  11. $this->template = (object) NULL;
  12. }
  13.  
  14. public function render() {
  15. $this->beforeRender($this);
  16. print_r($this->template);
  17. }
  18. }
  19.  
  20. $a = new A;
  21.  
  22. $a->beforeRender[] = function($self) {
  23. $self->template->a = 'a';
  24. };
  25.  
  26. $a->beforeRender[] = function($self) {
  27. $self->template->b = 'b';
  28. };
  29.  
  30. $a->render();
Add Comment
Please, Sign In to add comment