1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the bootstrap-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2018 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Twig\Extension\Component; |
13
|
|
|
|
14
|
|
|
use Twig_SimpleFunction; |
15
|
|
|
use WBW\Library\Core\Utility\ArrayUtility; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Progress bar component Twig extension. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
22
|
|
|
* @final |
23
|
|
|
*/ |
24
|
|
|
final class ProgressBarComponentTwigExtension extends AbstractComponentTwigExtension { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Service name. |
28
|
|
|
* |
29
|
|
|
* @var string |
30
|
|
|
*/ |
31
|
|
|
const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.component.progressbar"; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Constructor. |
35
|
|
|
*/ |
36
|
|
|
public function __construct() { |
37
|
|
|
parent::__construct(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Displays a Bootstrap basic progress bar. |
42
|
|
|
* |
43
|
|
|
* @param array $args The arguments. |
44
|
|
|
* @return string Returns the Bootstrap basic progress bar. |
45
|
|
|
*/ |
46
|
|
|
public function bootstrapBasicProgressBarFunction(array $args = []) { |
47
|
|
|
return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false)); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Displays a Bootstrap progress bar "Danger". |
52
|
|
|
* |
53
|
|
|
* @param array $args The arguments. |
54
|
|
|
* @return string Returns the Bootstrap progress bar "Danger". |
55
|
|
|
*/ |
56
|
|
|
public function bootstrapProgressBarDangerFunction(array $args = []) { |
57
|
|
|
return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false), "progress-bar-danger"); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Displays a Bootstrap progress bar "Info". |
62
|
|
|
* |
63
|
|
|
* @param array $args The arguments. |
64
|
|
|
* @return string Returns the Bootstrap progress bar "Info". |
65
|
|
|
*/ |
66
|
|
|
public function bootstrapProgressBarInfoFunction(array $args = []) { |
67
|
|
|
return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false), "progress-bar-info"); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Displays a Bootstrap progress bar "Success". |
72
|
|
|
* |
73
|
|
|
* @param array $args The arguments. |
74
|
|
|
* @return string Returns the Bootstrap progress bar "Success". |
75
|
|
|
*/ |
76
|
|
|
public function bootstrapProgressBarSuccessFunction(array $args = []) { |
77
|
|
|
return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false), "progress-bar-success"); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Displays a Bootstrap progress bar "Warning". |
82
|
|
|
* |
83
|
|
|
* @param array $args The arguments. |
84
|
|
|
* @return string Returns the Bootstrap progress bar "Warning". |
85
|
|
|
*/ |
86
|
|
|
public function bootstrapProgressBarWarningFunction(array $args = []) { |
87
|
|
|
return $this->bootstrapProgressBar(ArrayUtility::get($args, "content"), ArrayUtility::get($args, "value", 50), ArrayUtility::get($args, "min", 0), ArrayUtility::get($args, "max", 100), ArrayUtility::get($args, "striped", false), ArrayUtility::get($args, "animated", false), "progress-bar-warning"); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Get the Twig functions. |
92
|
|
|
* |
93
|
|
|
* @return Twig_SimpleFunction[] Returns the Twig functions. |
94
|
|
|
*/ |
95
|
|
|
public function getFunctions() { |
96
|
|
|
return [ |
97
|
|
|
new Twig_SimpleFunction("bootstrapBasicProgressBar", [$this, "bootstrapBasicProgressBarFunction"], ["is_safe" => ["html"]]), |
98
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]), |
99
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]), |
100
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]), |
101
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]), |
102
|
|
|
]; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
} |
106
|
|
|
|