Passed
Push — master ( 2977bf...424b14 )
by Fabio
15:07 queued 10:08
created

TWizardNavigationTemplate::getIncludedFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * TWizard and the relevant class definitions.
4
 *
5
 * @author Qiang Xue <[email protected]>
6
 * @link https://github.com/pradosoft/prado
7
 * @license https://github.com/pradosoft/prado/blob/master/LICENSE
8
 */
9
10
namespace Prado\Web\UI\WebControls;
11
12
use Prado\Exceptions\TInvalidDataValueException;
13
use Prado\Web\UI\ITemplate;
14
15
/**
16
 * TWizardNavigationTemplate class.
17
 * TWizardNavigationTemplate is the base class for various navigation templates.
18
 * @author Qiang Xue <[email protected]>
19
 * @since 3.0
20
 */
21
class TWizardNavigationTemplate extends \Prado\TComponent implements ITemplate
22
{
23
	private $_wizard;
24
25
	/**
26
	 * Constructor.
27
	 * @param TWizard $wizard the wizard owning this template
28
	 */
29
	public function __construct($wizard)
30
	{
31
		$this->_wizard = $wizard;
32
		parent::__construct();
33
	}
34
35
	/**
36
	 * @return TWizard the wizard owning this template
37
	 */
38
	public function getWizard()
39
	{
40
		return $this->_wizard;
41
	}
42
43
	/**
44
	 * Instantiates the template.
45
	 * Derived classes should override this method.
46
	 * @param \Prado\Web\UI\TControl $parent parent to hold the content within the template
47
	 */
48
	public function instantiateIn($parent)
49
	{
50
	}
51
52
	/**
53
	 * TTemplateManager calls this method for caching the included file modification times.
54
	 * @return array list of included external template files
55
	 */
56
	public function getIncludedFiles()
57
	{
58
		return [];
59
	}
60
61
	/**
62
	 * Creates a navigation button.
63
	 * It creates a {@link TButton}, {@link TLinkButton}, or {@link TImageButton},
64
	 * depending on the given parameters.
65
	 * @param TWizardNavigationButtonStyle $buttonStyle button style
66
	 * @param bool $causesValidation whether the button should cause validation
67
	 * @param string $commandName command name for the button's OnCommand event
68
	 * @throws TInvalidDataValueException if the button type is not recognized
69
	 */
70
	protected function createNavigationButton($buttonStyle, $causesValidation, $commandName)
71
	{
72
		switch ($buttonStyle->getButtonType()) {
73
			case TWizardNavigationButtonType::Button:
74
				$button = new TButton();
75
				break;
76
			case TWizardNavigationButtonType::Link:
77
				$button = new TLinkButton();
78
				break;
79
			case TWizardNavigationButtonType::Image:
80
				$button = new TImageButton();
81
				$button->setImageUrl($buttonStyle->getImageUrl());
82
				break;
83
			default:
84
				throw new TInvalidDataValueException('wizard_buttontype_unknown', $buttonStyle->getButtonType());
85
		}
86
		$button->setText($buttonStyle->getButtonText());
87
		$button->setCausesValidation($causesValidation);
88
		$button->setCommandName($commandName);
89
		return $button;
90
	}
91
}
92