1: <?php
2: /**
3: * This file is part of the Autarky package.
4: *
5: * (c) Andreas Lutro <anlutro@gmail.com>
6: *
7: * For the full copyright and license information, please view the LICENSE
8: * file that was distributed with this source code.
9: */
10:
11: namespace Autarky\TwigTemplating;
12:
13: use Symfony\Component\EventDispatcher\Event;
14:
15: class TemplateEvent extends Event
16: {
17: /**
18: * @var Template
19: */
20: protected $template;
21:
22: /**
23: * @var TemplateContext
24: */
25: protected $context;
26:
27: /**
28: * @param Template $template
29: * @param TemplateContext $context
30: */
31: public function __construct(Template $template, TemplateContext $context = null)
32: {
33: $this->template = $template;
34: $this->context = $context ?: $template->getContext();
35: }
36:
37: /**
38: * Get the template instance.
39: *
40: * @return Template
41: */
42: public function getTemplate()
43: {
44: return $this->template;
45: }
46:
47: /**
48: * Get the template's context instance.
49: *
50: * @return \Autarky\TwigTemplating\TemplateContext
51: */
52: public function getContext()
53: {
54: return $this->context;
55: }
56: }
57: