webeweb /
bootstrap-bundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 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\Bundle\BootstrapBundle\BootstrapBundle; |
||
| 16 | use WBW\Bundle\CoreBundle\Navigation\NavigationInterface; |
||
| 17 | use WBW\Library\Core\Argument\ArrayHelper; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * Alert Twig extension. |
||
| 21 | * |
||
| 22 | * @author webeweb <https://github.com/webeweb/> |
||
| 23 | * @package WBW\Bundle\BootstrapBundle\Twig\Extension\Component |
||
| 24 | * @link https://getbootstrap.com/docs/3.3/components/#alerts |
||
| 25 | */ |
||
| 26 | class AlertTwigExtension extends AbstractAlertTwigExtension { |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Service name. |
||
| 30 | * |
||
| 31 | * @var string |
||
| 32 | */ |
||
| 33 | const SERVICE_NAME = "webeweb.bootstrap.twig.extension.component.alert"; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Displays a Bootstrap alert "Danger". |
||
| 37 | * |
||
| 38 | * @param array $args The arguments. |
||
| 39 | * @return string Returns the Bootstrap alert "Danger". |
||
| 40 | */ |
||
| 41 | public function bootstrapAlertDangerFunction(array $args = []) { |
||
| 42 | return $this->bootstrapAlert(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "dismissible"), "alert-" . BootstrapBundle::BOOTSTRAP_DANGER); |
||
|
0 ignored issues
–
show
|
|||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Displays a Bootstrap alert "Info". |
||
| 47 | * |
||
| 48 | * @param array $args The arguments. |
||
| 49 | * @return string Returns the Bootstrap alert "Info". |
||
| 50 | */ |
||
| 51 | public function bootstrapAlertInfoFunction(array $args = []) { |
||
| 52 | return $this->bootstrapAlert(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "dismissible"), "alert-" . BootstrapBundle::BOOTSTRAP_INFO); |
||
|
0 ignored issues
–
show
The constant
WBW\Bundle\BootstrapBund...pBundle::BOOTSTRAP_INFO has been deprecated with message: since 2.2.0, use {@see WBW\Bundle\BootstrapBundle\BootstrapInterface} instead.
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * Displays a Bootstrap alert "Link". |
||
| 57 | * |
||
| 58 | * @param array $args The arguments. |
||
| 59 | * @return string Returns the Bootstrap alert "Link". |
||
| 60 | */ |
||
| 61 | public function bootstrapAlertLinkFunction(array $args = []) { |
||
| 62 | |||
| 63 | $attributes = []; |
||
| 64 | |||
| 65 | $attributes["href"] = ArrayHelper::get($args, "href", NavigationInterface::NAVIGATION_HREF_DEFAULT); |
||
| 66 | |||
| 67 | $innerHTML = ArrayHelper::get($args, "content"); |
||
| 68 | |||
| 69 | return static::coreHTMLElement("a", $innerHTML, $attributes); |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Displays a Bootstrap alert "Success". |
||
| 74 | * |
||
| 75 | * @param array $args The arguments. |
||
| 76 | * @return string Returns the Bootstrap alert "Success". |
||
| 77 | */ |
||
| 78 | public function bootstrapAlertSuccessFunction(array $args = []) { |
||
| 79 | return $this->bootstrapAlert(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "dismissible"), "alert-" . BootstrapBundle::BOOTSTRAP_SUCCESS); |
||
|
0 ignored issues
–
show
The constant
WBW\Bundle\BootstrapBund...ndle::BOOTSTRAP_SUCCESS has been deprecated with message: since 2.2.0, use {@see WBW\Bundle\BootstrapBundle\BootstrapInterface} instead.
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * Displays a Bootstrap alert "Warning". |
||
| 84 | * |
||
| 85 | * @param array $args The arguments. |
||
| 86 | * @return string Returns the Bootstrap alert "Warning". |
||
| 87 | */ |
||
| 88 | public function bootstrapAlertWarningFunction(array $args = []) { |
||
| 89 | return $this->bootstrapAlert(ArrayHelper::get($args, "content"), ArrayHelper::get($args, "dismissible"), "alert-" . BootstrapBundle::BOOTSTRAP_WARNING); |
||
|
0 ignored issues
–
show
The constant
WBW\Bundle\BootstrapBund...ndle::BOOTSTRAP_WARNING has been deprecated with message: since 2.2.0, use {@see WBW\Bundle\BootstrapBundle\BootstrapInterface} instead.
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. Loading history...
|
|||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Get the Twig functions. |
||
| 94 | * |
||
| 95 | * @return Twig_SimpleFunction[] Returns the Twig functions. |
||
| 96 | */ |
||
| 97 | public function getFunctions() { |
||
| 98 | return [ |
||
| 99 | new Twig_SimpleFunction("bootstrapAlertDanger", [$this, "bootstrapAlertDangerFunction"], ["is_safe" => ["html"]]), |
||
| 100 | new Twig_SimpleFunction("bsAlertDanger", [$this, "bootstrapAlertDangerFunction"], ["is_safe" => ["html"]]), |
||
| 101 | |||
| 102 | new Twig_SimpleFunction("bootstrapAlertInfo", [$this, "bootstrapAlertInfoFunction"], ["is_safe" => ["html"]]), |
||
| 103 | new Twig_SimpleFunction("bsAlertInfo", [$this, "bootstrapAlertInfoFunction"], ["is_safe" => ["html"]]), |
||
| 104 | |||
| 105 | new Twig_SimpleFunction("bootstrapAlertLink", [$this, "bootstrapAlertLinkFunction"], ["is_safe" => ["html"]]), |
||
| 106 | new Twig_SimpleFunction("bsAlertLink", [$this, "bootstrapAlertLinkFunction"], ["is_safe" => ["html"]]), |
||
| 107 | |||
| 108 | new Twig_SimpleFunction("bootstrapAlertSuccess", [$this, "bootstrapAlertSuccessFunction"], ["is_safe" => ["html"]]), |
||
| 109 | new Twig_SimpleFunction("bsAlertSuccess", [$this, "bootstrapAlertSuccessFunction"], ["is_safe" => ["html"]]), |
||
| 110 | |||
| 111 | new Twig_SimpleFunction("bootstrapAlertWarning", [$this, "bootstrapAlertWarningFunction"], ["is_safe" => ["html"]]), |
||
| 112 | new Twig_SimpleFunction("bsAlertWarning", [$this, "bootstrapAlertWarningFunction"], ["is_safe" => ["html"]]), |
||
| 113 | ]; |
||
| 114 | } |
||
| 115 | } |
||
| 116 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.