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\Argument\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
|
|
|
*/ |
23
|
|
|
class ProgressBarComponentTwigExtension extends AbstractComponentTwigExtension { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Service name. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
*/ |
30
|
|
|
const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.component.progressbar"; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Constructor. |
34
|
|
|
*/ |
35
|
|
|
public function __construct() { |
36
|
|
|
parent::__construct(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Displays a Bootstrap progress bar "Basic". |
41
|
|
|
* |
42
|
|
|
* @param array $args The arguments. |
43
|
|
|
* @return string Returns the Bootstrap progress bar "Basic". |
44
|
|
|
*/ |
45
|
|
|
public function bootstrapProgressBarBasicFunction(array $args = []) { |
46
|
|
|
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)); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Displays a Bootstrap progress bar "Danger". |
51
|
|
|
* |
52
|
|
|
* @param array $args The arguments. |
53
|
|
|
* @return string Returns the Bootstrap progress bar "Danger". |
54
|
|
|
*/ |
55
|
|
|
public function bootstrapProgressBarDangerFunction(array $args = []) { |
56
|
|
|
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"); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Displays a Bootstrap progress bar "Info". |
61
|
|
|
* |
62
|
|
|
* @param array $args The arguments. |
63
|
|
|
* @return string Returns the Bootstrap progress bar "Info". |
64
|
|
|
*/ |
65
|
|
|
public function bootstrapProgressBarInfoFunction(array $args = []) { |
66
|
|
|
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"); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Displays a Bootstrap progress bar "Success". |
71
|
|
|
* |
72
|
|
|
* @param array $args The arguments. |
73
|
|
|
* @return string Returns the Bootstrap progress bar "Success". |
74
|
|
|
*/ |
75
|
|
|
public function bootstrapProgressBarSuccessFunction(array $args = []) { |
76
|
|
|
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"); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Displays a Bootstrap progress bar "Warning". |
81
|
|
|
* |
82
|
|
|
* @param array $args The arguments. |
83
|
|
|
* @return string Returns the Bootstrap progress bar "Warning". |
84
|
|
|
*/ |
85
|
|
|
public function bootstrapProgressBarWarningFunction(array $args = []) { |
86
|
|
|
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"); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Get the Twig functions. |
91
|
|
|
* |
92
|
|
|
* @return Twig_SimpleFunction[] Returns the Twig functions. |
93
|
|
|
*/ |
94
|
|
|
public function getFunctions() { |
95
|
|
|
return [ |
96
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarBasic", [$this, "bootstrapProgressBarBasicFunction"], ["is_safe" => ["html"]]), |
97
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarDanger", [$this, "bootstrapProgressBarDangerFunction"], ["is_safe" => ["html"]]), |
98
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarInfo", [$this, "bootstrapProgressBarInfoFunction"], ["is_safe" => ["html"]]), |
99
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarSuccess", [$this, "bootstrapProgressBarSuccessFunction"], ["is_safe" => ["html"]]), |
100
|
|
|
new Twig_SimpleFunction("bootstrapProgressBarWarning", [$this, "bootstrapProgressBarWarningFunction"], ["is_safe" => ["html"]]), |
101
|
|
|
]; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
} |
105
|
|
|
|