TemplateFactory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setTemplateManager() 0 4 1
A createTemplate() 0 14 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SixtyEightPublishers\Application\Components;
6
7
use Nette\Application\UI\Control;
8
9
class TemplateFactory extends \Nette\Bridges\ApplicationLatte\TemplateFactory
10
{
11
	/** @var TemplateManager */
12
	private $templateManager;
13
14
	/**
15
	 * @param \SixtyEightPublishers\Application\Components\TemplateManager $templateManager
16
	 *
17
	 * @return void
18
	 */
19
	public function setTemplateManager(TemplateManager $templateManager)
20
	{
21
		$this->templateManager = $templateManager;
22
	}
23
24
	/**
25
	 * @param \Nette\Application\UI\Control|null $control
26
	 *
27
	 * @throws \SixtyEightPublishers\Application\Components\ConfigurationException
28
	 * @return \SixtyEightPublishers\Application\Components\Template
29
	 */
30
	public function createTemplate(Control $control = NULL)
31
	{
32
		if (!$this->templateManager) {
33
			$class = self::class;
34
			throw new ConfigurationException("You must set template manager object via {$class}::setTemplateManager() method.");
35
		}
36
		$template = parent::createTemplate($control);
37
38
		if ($template instanceof Template) {
39
			$template->setTemplateManager($this->templateManager);
40
		}
41
42
		return $template;
43
	}
44
}
45