|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bootstrap-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 NdC/WBW |
|
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 NdC/WBW <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.progress-bar"; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Displays a Bootstrap basic progress bar. |
|
35
|
|
|
* |
|
36
|
|
|
* @param array $args The arguments. |
|
37
|
|
|
* @return string Returns the Bootstrap basic progress bar. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function bootstrapBasicProgressBarFunction(array $args = []) { |
|
40
|
|
|
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)); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Displays a Bootstrap progress bar "Danger". |
|
45
|
|
|
* |
|
46
|
|
|
* @param array $args The arguments. |
|
47
|
|
|
* @return string Returns the Bootstrap progress bar "Danger". |
|
48
|
|
|
*/ |
|
49
|
|
|
public function bootstrapProgressBarDangerFunction(array $args = []) { |
|
50
|
|
|
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"); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Displays a Bootstrap progress bar "Info". |
|
55
|
|
|
* |
|
56
|
|
|
* @param array $args The arguments. |
|
57
|
|
|
* @return string Returns the Bootstrap progress bar "Info". |
|
58
|
|
|
*/ |
|
59
|
|
|
public function bootstrapProgressBarInfoFunction(array $args = []) { |
|
60
|
|
|
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"); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Displays a Bootstrap progress bar "Success". |
|
65
|
|
|
* |
|
66
|
|
|
* @param array $args The arguments. |
|
67
|
|
|
* @return string Returns the Bootstrap progress bar "Success". |
|
68
|
|
|
*/ |
|
69
|
|
|
public function bootstrapProgressBarSuccessFunction(array $args = []) { |
|
70
|
|
|
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"); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Displays a Bootstrap progress bar "Warning". |
|
75
|
|
|
* |
|
76
|
|
|
* @param array $args The arguments. |
|
77
|
|
|
* @return string Returns the Bootstrap progress bar "Warning". |
|
78
|
|
|
*/ |
|
79
|
|
|
public function bootstrapProgressBarWarningFunction(array $args = []) { |
|
80
|
|
|
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"); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get the Twig functions. |
|
85
|
|
|
* |
|
86
|
|
|
* @return array Returns the Twig functions. |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getFunctions() { |
|
89
|
|
|
return [ |
|
90
|
|
|
new Twig_SimpleFunction("bootstrapBasicProgressBar", [$this, "bootstrapBasicProgressBarFunction"], ["is_safe" => ["html"]]), |
|
91
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]), |
|
92
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]), |
|
93
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]), |
|
94
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]), |
|
95
|
|
|
]; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
} |
|
99
|
|
|
|