1: <?php
2:
3: namespace Mapbender\CoreBundle\Component;
4:
5: use Symfony\Component\DependencyInjection\ContainerInterface;
6:
7: /**
8: * Base class for all application templates.
9: *
10: * @author Christian Wygoda
11: */
12: abstract class Template
13: {
14:
15: protected $container;
16: protected $application;
17:
18: public function __construct(ContainerInterface $container, Application $application)
19: {
20: $this->container = $container;
21: $this->application = $application;
22: }
23:
24: /**
25: * Get the template title.
26: *
27: * This title is mainly used in the backend manager when creating a new
28: * application.
29: *
30: * @return string
31: */
32: static public function getTitle()
33: {
34: throw new \RuntimeException('getTitle must be implemented in subclasses');
35: }
36:
37: /**
38: * Get the element assets.
39: *
40: * Returns an array of references to asset files of the given type.
41: * References can either be filenames/path which are searched for in the
42: * Resources/public directory of the element's bundle or assetic references
43: * indicating the bundle to search in:
44: *
45: * array(
46: * 'foo.css'),
47: * '@MapbenderCoreBundle/Resources/public/foo.css'));
48: *
49: * @param string $type Asset type to list, can be 'css' or 'js'
50: * @return array
51: */
52: public function getAssets($type)
53: {
54: if($type !== 'css' && $type !== 'js')
55: {
56: throw new \RuntimeException('The asset type \'' . $type .
57: '\' is not supported.');
58: }
59:
60: return array();
61: }
62:
63: /**
64: * Get the template regions available in the Twig template.
65: *
66: * @return array
67: */
68: static public function getRegions()
69: {
70: throw new \RuntimeException('getTitle must be implemented in subclasses');
71: }
72:
73: /**
74: * Render the application
75: *
76: * @param string $format Output format, defaults to HTML
77: * @param boolean $html Whether to render the HTML itself
78: * @param boolean $css Whether to include the CSS links
79: * @param boolean $js Whether to include the JavaScript
80: * @return string $html The rendered HTML
81: */
82: abstract public function render($format = 'html', $html = true, $css = true, $js = true);
83: }
84:
85: