From b0a635ea3ca77767f6bdb4d8c6fec6afb9d62afa Mon Sep 17 00:00:00 2001 From: Iman Ghasrfakhri Date: Sat, 8 Jan 2022 12:32:45 +0330 Subject: [PATCH] Make Compatible with twig 3.0 --- Resources/views/Form/bootstrap.html.twig | 180 +++++++++++------------ Resources/views/Menu/bootstrap.html.twig | 20 +-- Twig/BootstrapBadgeExtension.php | 9 +- Twig/BootstrapButtonExtension.php | 12 +- Twig/BootstrapFormExtension.php | 39 ++--- Twig/BootstrapIconExtension.php | 12 +- Twig/BootstrapLabelExtension.php | 18 +-- 7 files changed, 146 insertions(+), 144 deletions(-) diff --git a/Resources/views/Form/bootstrap.html.twig b/Resources/views/Form/bootstrap.html.twig index 5fb0d1e2..4d85bc44 100644 --- a/Resources/views/Form/bootstrap.html.twig +++ b/Resources/views/Form/bootstrap.html.twig @@ -3,17 +3,17 @@ {# Widgets #} {% block form_widget %} - {% spaceless %} + {% apply spaceless %} {% if compound %} {{ block('form_widget_compound') }} {% else %} {{ block('form_widget_simple') }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_widget %} {% block form_widget_simple %} - {% spaceless %} + {% apply spaceless %} {% set style = style|default(bootstrap_get_style()) %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} @@ -54,11 +54,11 @@ {% if simple_col is defined %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_widget_simple %} {% block form_widget_compound %} - {% spaceless %} + {% apply spaceless %}
{% if form.parent is empty %} {{ block('global_form_errors') }} @@ -66,20 +66,20 @@ {{ block('form_rows') }} {{ form_rest(form) }}
- {% endspaceless %} + {% endapply %} {% endblock form_widget_compound %} {% block collection_widget %} - {% spaceless %} + {% apply spaceless %} {% if prototype is defined %} {% set attr = attr|merge({'data-prototype': form_row(prototype) }) %} {% endif %} {{ block('form_widget') }} - {% endspaceless %} + {% endapply %} {% endblock collection_widget %} {% block bootstrap_collection_widget %} - {% spaceless %} + {% apply spaceless %} {% set delete_button_text = form.vars.delete_button_text %} {% set add_button_text = form.vars.add_button_text %} {% if translation_domain is not same as (false) %} @@ -122,11 +122,11 @@ {{ add_button_text|parse_icons|raw }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock bootstrap_collection_widget %} {% block textarea_widget %} - {% spaceless %} + {% apply spaceless %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} {% if attr.simple_col is defined and attr.simple_col is not empty %} @@ -147,11 +147,11 @@ {% if simple_col is defined %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock textarea_widget %} {% block file_widget %} - {% spaceless %} + {% apply spaceless %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} {% if attr.simple_col is defined and attr.simple_col is not empty %} @@ -171,21 +171,21 @@ {% if simple_col is defined %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock file_widget %} {% block choice_widget %} - {% spaceless %} + {% apply spaceless %} {% if expanded %} {{ block('choice_widget_expanded') }} {% else %} {{ block('choice_widget_collapsed') }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock choice_widget %} {% block choice_widget_expanded %} - {% spaceless %} + {% apply spaceless %}
{% for child in form %} {% if multiple %} @@ -195,11 +195,11 @@ {% endif %} {% endfor %}
- {% endspaceless %} + {% endapply %} {% endblock choice_widget_expanded %} {% block choice_widget_collapsed %} - {% spaceless %} + {% apply spaceless %} {% set attr = attr|merge({ 'class': (attr.class|default('') ~ ' form-control')|trim }) %} - {% endspaceless %} + {% endapply %} {% endblock choice_widget_collapsed %} {% block choice_widget_options %} - {% spaceless %} + {% apply spaceless %} {% for group_label, choice in options %} {% if choice is iterable %} @@ -237,11 +237,11 @@ {% endif %} {% endfor %} - {% endspaceless %} + {% endapply %} {% endblock choice_widget_options %} {% block checkbox_row %} - {% spaceless %} + {% apply spaceless %} {% set style = style|default(bootstrap_get_style()) %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} @@ -309,11 +309,11 @@ {% endif %} {% if style == 'inline' %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock checkbox_row %} {% block radio_row %} - {% spaceless %} + {% apply spaceless %} {% set class = '' %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} @@ -376,23 +376,23 @@ {% elseif no_form_group is not defined or no_form_group == false %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock radio_row %} {% block checkbox_widget %} - {% spaceless %} + {% apply spaceless %} - {% endspaceless %} + {% endapply %} {% endblock checkbox_widget %} {% block radio_widget %} - {% spaceless %} + {% apply spaceless %} - {% endspaceless %} + {% endapply %} {% endblock radio_widget %} {% block datetime_widget %} - {% spaceless %} + {% apply spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} @@ -404,11 +404,11 @@ {{ form_errors(form.time) }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock datetime_widget %} {% block date_widget %} - {% spaceless %} + {% apply spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} @@ -421,11 +421,11 @@ })|raw }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock date_widget %} {% block time_widget %} - {% spaceless %} + {% apply spaceless %} {% if widget == 'single_text' %} {{ block('form_widget_simple') }} {% else %} @@ -437,26 +437,26 @@ {% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock time_widget %} {% block number_widget %} - {% spaceless %} + {% apply spaceless %} {# type="number" doesn't work with floats #} {% set type = type|default('text') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock number_widget %} {% block integer_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('number') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock integer_widget %} {% block money_widget %} - {% spaceless %} + {% apply spaceless %}
{{ money_pattern|replace({ '{{ widget }}': block('form_widget_simple'), @@ -464,56 +464,56 @@ '{{ tag_end }}': '' })|raw }}
- {% endspaceless %} + {% endapply %} {% endblock money_widget %} {% block url_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('url') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock url_widget %} {% block search_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('search') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock search_widget %} {% block percent_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('text') %}
{{ block('form_widget_simple') }} %
- {% endspaceless %} + {% endapply %} {% endblock percent_widget %} {% block password_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('password') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock password_widget %} {% block hidden_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('hidden') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock hidden_widget %} {% block email_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('email') %} {{ block('form_widget_simple') }} - {% endspaceless %} + {% endapply %} {% endblock email_widget %} {% block button_widget %} - {% spaceless %} + {% apply spaceless %} {% if label is empty and label is not same as (false) %} {% set label = name|humanize %} {% endif %} @@ -530,21 +530,21 @@ {% else %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock button_widget %} {% block submit_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('submit') %} {{ block('button_widget') }} - {% endspaceless %} + {% endapply %} {% endblock submit_widget %} {% block reset_widget %} - {% spaceless %} + {% apply spaceless %} {% set type = type|default('reset') %} {{ block('button_widget') }} - {% endspaceless %} + {% endapply %} {% endblock reset_widget %} {% block form_actions_widget %} @@ -561,7 +561,7 @@ {# Labels #} {% block form_label %} - {% spaceless %} + {% apply spaceless %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} {% if attr.label_col is defined and attr.label_col is not empty %} @@ -603,7 +603,7 @@ {% endif %} {{ label|raw }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_label %} {% block button_label %}{% endblock %} @@ -611,17 +611,17 @@ {# Rows #} {% block repeated_row %} - {% spaceless %} + {% apply spaceless %} {# No need to render the errors here, as all errors are mapped to the first child (see RepeatedTypeValidatorExtension). #} {{ block('form_rows') }} - {% endspaceless %} + {% endapply %} {% endblock repeated_row %} {% block form_row %} - {% spaceless %} + {% apply spaceless %} {% set style = style|default(bootstrap_get_style()) %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} @@ -661,11 +661,11 @@ {% if style == 'inline' %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_row %} {% block form_input_group %} - {% spaceless %} + {% apply spaceless %} {% if attr.input_group is defined and attr.input_group is not empty %} {% set input_group = attr.input_group %} {% endif %} @@ -696,11 +696,11 @@ {% else %} {{ form_widget(form) }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_input_group %} {% block form_help %} - {% spaceless %} + {% apply spaceless %} {% if attr.help_text is defined and attr.help_text is not empty %} {% set help_text = attr.help_text %} {% endif %} @@ -708,11 +708,11 @@ {% if help_text is not empty %} {{ help_text|trans({}, translation_domain) }} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_help %} {% block button_row %} - {% spaceless %} + {% apply spaceless %} {% set style = style|default(bootstrap_get_style()) %} {% set col_size = col_size|default(bootstrap_get_col_size()) %} @@ -743,7 +743,7 @@ {% endif %} - {% endspaceless %} + {% endapply %} {% endblock button_row %} {% block hidden_row %} @@ -757,15 +757,15 @@ {# Misc #} {% block form %} - {% spaceless %} + {% apply spaceless %} {{ form_start(form) }} {{ form_widget(form) }} {{ form_end(form) }} - {% endspaceless %} + {% endapply %} {% endblock form %} {% block form_start %} - {% spaceless %} + {% apply spaceless %} {{ bootstrap_backup_form_settings() }} {% set method = method|upper %} {% if method in ["GET", "POST"] %} @@ -807,11 +807,11 @@ {% if form_method != method %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_start %} {% block form_end %} - {% spaceless %} + {% apply spaceless %} {% if not render_rest is defined or render_rest %} {{ form_rest(form) }} {% endif %} @@ -832,13 +832,13 @@ {{ bootstrap_set_simple_col(false) }} {% endif %} {{ bootstrap_restore_form_settings() }} - {% endspaceless %} + {% endapply %} {% endblock form_end %} {% block form_enctype %} - {% spaceless %} + {% apply spaceless %} {% if multipart %}enctype="multipart/form-data"{% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_enctype %} {% block global_form_errors %} @@ -849,7 +849,7 @@ {% endblock global_form_errors %} {% block form_errors %} - {% spaceless %} + {% apply spaceless %} {% set global_errors = global_errors|default(false) %} {% set style = style|default(bootstrap_get_style()) %} @@ -870,23 +870,23 @@ {% endif %} {% endif %} - {% endspaceless %} + {% endapply %} {% endblock form_errors %} {% block form_rest %} - {% spaceless %} + {% apply spaceless %} {% for child in form %} {% if not child.rendered %} {{ form_row(child) }} {% endif %} {% endfor %} - {% endspaceless %} + {% endapply %} {% endblock form_rest %} {# Support #} {% block form_rows %} - {% spaceless %} + {% apply spaceless %} {% for child in form %} {% set childAttr = {} %} {% if attr.col_size is defined %} @@ -906,25 +906,25 @@ {% endif %} {{ form_row(child, childAttr) }} {% endfor %} - {% endspaceless %} + {% endapply %} {% endblock form_rows %} {% block widget_attributes %} - {% spaceless %} + {% apply spaceless %} id="{{ id }}" name="{{ full_name }}" {% if disabled %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %} {% for attrname, attrvalue in attr %}{% if attrname in ['placeholder', 'title'] %}{{ attrname }}="{{ attrvalue|trans({}, translation_domain) }}" {% elseif attrname in ['input_group'] %}{% else %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} - {% endspaceless %} + {% endapply %} {% endblock widget_attributes %} {% block widget_container_attributes %} - {% spaceless %} + {% apply spaceless %} {% if attr.style is defined and (attr.style == 'inline' or attr.style == 'horizontal') %} {% set attr = attr|merge({ 'class': ('form-'~attr.style~' '~attr.class|default(''))|trim }) %} {% set attr = attr|merge({ 'style': null }) %} {% endif %} {% if id is not empty %}id="{{ id }}" {% endif %} {% for attrname, attrvalue in attr %}{% if attrvalue is not null and (attrvalue is not iterable) %}{{ attrname }}="{{ attrvalue }}" {% endif %}{% endfor %} - {% endspaceless %} + {% endapply %} {% endblock widget_container_attributes %} {% block button_attributes -%} diff --git a/Resources/views/Menu/bootstrap.html.twig b/Resources/views/Menu/bootstrap.html.twig index a2647453..e93ddf13 100644 --- a/Resources/views/Menu/bootstrap.html.twig +++ b/Resources/views/Menu/bootstrap.html.twig @@ -11,9 +11,9 @@ {% from _self import attributes as attributes %} {% block compressed_root %} -{% spaceless %} +{% apply spaceless %} {{ block('root') }} -{% endspaceless %} +{% endapply %} {% endblock %} {% block root %} @@ -72,24 +72,24 @@ {% endblock %} {% block dropdownList %} -{% spaceless %} +{% apply spaceless %} {% if item.hasChildren and options.depth is not same as (0) and ((item.extras.dropdown is not defined and item.displayChildren is same as (true) or item.extras.dropdown is defined and item.extras.dropdown is same as (true) and item.displayChildren is same as (true))) %} {% set listAttributes = listAttributes|merge({'class': (listAttributes.class|default('') ~ ' dropdown-menu')|trim}) %} {{ block('children') }} {% endif %} -{% endspaceless %} +{% endapply %} {% endblock dropdownList %} {% block listList %} -{% spaceless %} +{% apply spaceless %} {% if item.hasChildren and options.depth is not same as (0) and item.displayChildren %} {{ block('children') }} {% endif %} -{% endspaceless %} +{% endapply %} {% endblock listList %} {% block children %} @@ -173,17 +173,17 @@ {% block linkElement %}{{ block('label') }}{% endblock %} {% block dropdownElement %} -{% spaceless %} +{% apply spaceless %} {% set labelAttributes = item.labelAttributes %} {% set labelAttributes = labelAttributes|merge({'class': (labelAttributes.class|default('') ~ ' dropdown-toggle')|trim}) %} {% set labelAttributes = labelAttributes|merge({'data-toggle': 'dropdown'}) %} {{ block('label') }} -{% endspaceless %} +{% endapply %} {% endblock dropdownElement %} {% block dividerElement %} -{% spaceless %} -{% endspaceless %} +{% apply spaceless %} +{% endapply %} {% endblock dividerElement %} {% block spanElement %}{{ block('label') }}{% endblock %} diff --git a/Twig/BootstrapBadgeExtension.php b/Twig/BootstrapBadgeExtension.php index f88a3357..ee58c837 100644 --- a/Twig/BootstrapBadgeExtension.php +++ b/Twig/BootstrapBadgeExtension.php @@ -7,9 +7,8 @@ namespace Braincrafted\Bundle\BootstrapBundle\Twig; -use Twig_Extension; -use Twig_SimpleFunction; - +use Twig\TwigFunction; +use Twig\Extension\AbstractExtension; /** * BootstrapLabelExtension * @@ -21,7 +20,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 */ -class BootstrapBadgeExtension extends Twig_Extension +class BootstrapBadgeExtension extends AbstractExtension { /** * {@inheritDoc} @@ -29,7 +28,7 @@ class BootstrapBadgeExtension extends Twig_Extension public function getFunctions() { return array( - new Twig_SimpleFunction( + new TwigFunction( 'badge', array($this, 'badgeFunction'), array('pre_escape' => 'html', 'is_safe' => array('html')) diff --git a/Twig/BootstrapButtonExtension.php b/Twig/BootstrapButtonExtension.php index f27494da..cf744920 100644 --- a/Twig/BootstrapButtonExtension.php +++ b/Twig/BootstrapButtonExtension.php @@ -6,10 +6,12 @@ namespace Braincrafted\Bundle\BootstrapBundle\Twig; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\TwigFunction; +use Twig\Extension\AbstractExtension; -class BootstrapButtonExtension extends Twig_Extension + + +class BootstrapButtonExtension extends AbstractExtension { /** * @var BootstrapIconExtension @@ -38,8 +40,8 @@ public function __construct(BootstrapIconExtension $iconExtension) public function getFunctions() { return array( - new Twig_SimpleFunction('button', array($this, 'buttonFunction'), array('is_safe' => array('html'))), - new Twig_SimpleFunction('button_link', array($this, 'buttonLinkFunction'), array('is_safe' => array('html'))), + new TwigFunction('button', array($this, 'buttonFunction'), array('is_safe' => array('html'))), + new TwigFunction('button_link', array($this, 'buttonLinkFunction'), array('is_safe' => array('html'))), ); } diff --git a/Twig/BootstrapFormExtension.php b/Twig/BootstrapFormExtension.php index 0fbc3a34..eabf099d 100644 --- a/Twig/BootstrapFormExtension.php +++ b/Twig/BootstrapFormExtension.php @@ -6,8 +6,9 @@ namespace Braincrafted\Bundle\BootstrapBundle\Twig; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\TwigFunction; +use Twig\Extension\AbstractExtension; + /** @@ -20,7 +21,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 */ -class BootstrapFormExtension extends Twig_Extension +class BootstrapFormExtension extends AbstractExtension { /** @var string */ private $style; @@ -46,34 +47,34 @@ class BootstrapFormExtension extends Twig_Extension public function getFunctions() { return array( - new Twig_SimpleFunction('bootstrap_set_style', array($this, 'setStyle')), - new Twig_SimpleFunction('bootstrap_get_style', array($this, 'getStyle')), - new Twig_SimpleFunction('bootstrap_set_col_size', array($this, 'setColSize')), - new Twig_SimpleFunction('bootstrap_get_col_size', array($this, 'getColSize')), - new Twig_SimpleFunction('bootstrap_set_widget_col', array($this, 'setWidgetCol')), - new Twig_SimpleFunction('bootstrap_get_widget_col', array($this, 'getWidgetCol')), - new Twig_SimpleFunction('bootstrap_set_label_col', array($this, 'setLabelCol')), - new Twig_SimpleFunction('bootstrap_get_label_col', array($this, 'getLabelCol')), - new Twig_SimpleFunction('bootstrap_set_simple_col', array($this, 'setSimpleCol')), - new Twig_SimpleFunction('bootstrap_get_simple_col', array($this, 'getSimpleCol')), - new Twig_SimpleFunction('bootstrap_backup_form_settings', array($this, 'backupFormSettings')), - new Twig_SimpleFunction('bootstrap_restore_form_settings', array($this, 'restoreFormSettings')), - new Twig_SimpleFunction( + new TwigFunction('bootstrap_set_style', array($this, 'setStyle')), + new TwigFunction('bootstrap_get_style', array($this, 'getStyle')), + new TwigFunction('bootstrap_set_col_size', array($this, 'setColSize')), + new TwigFunction('bootstrap_get_col_size', array($this, 'getColSize')), + new TwigFunction('bootstrap_set_widget_col', array($this, 'setWidgetCol')), + new TwigFunction('bootstrap_get_widget_col', array($this, 'getWidgetCol')), + new TwigFunction('bootstrap_set_label_col', array($this, 'setLabelCol')), + new TwigFunction('bootstrap_get_label_col', array($this, 'getLabelCol')), + new TwigFunction('bootstrap_set_simple_col', array($this, 'setSimpleCol')), + new TwigFunction('bootstrap_get_simple_col', array($this, 'getSimpleCol')), + new TwigFunction('bootstrap_backup_form_settings', array($this, 'backupFormSettings')), + new TwigFunction('bootstrap_restore_form_settings', array($this, 'restoreFormSettings')), + new TwigFunction( 'checkbox_row', null, array('is_safe' => array('html'), 'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode') ), - new Twig_SimpleFunction( + new TwigFunction( 'radio_row', null, array('is_safe' => array('html'), 'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode') ), - new Twig_SimpleFunction( + new TwigFunction( 'global_form_errors', null, array('is_safe' => array('html'), 'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode') ), - new Twig_SimpleFunction( + new TwigFunction( 'form_control_static', array($this, 'formControlStaticFunction'), array('is_safe' => array('html')) diff --git a/Twig/BootstrapIconExtension.php b/Twig/BootstrapIconExtension.php index c262747d..a7aab746 100644 --- a/Twig/BootstrapIconExtension.php +++ b/Twig/BootstrapIconExtension.php @@ -6,9 +6,9 @@ namespace Braincrafted\Bundle\BootstrapBundle\Twig; -use Twig_Extension; -use Twig_SimpleFilter; -use Twig_SimpleFunction; +use Twig\TwigFunction; +use Twig\TwigFilter; +use Twig\Extension\AbstractExtension; /** * BootstrapIconExtension @@ -20,7 +20,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 */ -class BootstrapIconExtension extends Twig_Extension +class BootstrapIconExtension extends AbstractExtension { /** * @var string @@ -48,7 +48,7 @@ public function __construct($iconPrefix, $iconTag = 'span') public function getFilters() { return array( - new Twig_SimpleFilter( + new TwigFilter( 'parse_icons', array($this, 'parseIconsFilter'), array('pre_escape' => 'html', 'is_safe' => array('html')) @@ -62,7 +62,7 @@ public function getFilters() public function getFunctions() { return array( - new Twig_SimpleFunction( + new TwigFunction( 'icon', array($this, 'iconFunction'), array('pre_escape' => 'html', 'is_safe' => array('html')) diff --git a/Twig/BootstrapLabelExtension.php b/Twig/BootstrapLabelExtension.php index c9737110..c931d06d 100644 --- a/Twig/BootstrapLabelExtension.php +++ b/Twig/BootstrapLabelExtension.php @@ -7,8 +7,8 @@ namespace Braincrafted\Bundle\BootstrapBundle\Twig; -use Twig_Extension; -use Twig_SimpleFunction; +use Twig\TwigFunction; +use Twig\Extension\AbstractExtension; /** * BootstrapLabelExtension @@ -21,7 +21,7 @@ * @license http://opensource.org/licenses/MIT The MIT License * @link http://bootstrap.braincrafted.com Bootstrap for Symfony2 */ -class BootstrapLabelExtension extends Twig_Extension +class BootstrapLabelExtension extends AbstractExtension { /** * {@inheritDoc} @@ -31,12 +31,12 @@ public function getFunctions() $options = array('pre_escape' => 'html', 'is_safe' => array('html')); return array( - new Twig_SimpleFunction('label', array($this, 'labelFunction'), $options), - new Twig_SimpleFunction('label_primary', array($this, 'labelPrimaryFunction'), $options), - new Twig_SimpleFunction('label_success', array($this, 'labelSuccessFunction'), $options), - new Twig_SimpleFunction('label_info', array($this, 'labelInfoFunction'), $options), - new Twig_SimpleFunction('label_warning', array($this, 'labelWarningFunction'), $options), - new Twig_SimpleFunction('label_danger', array($this, 'labelDangerFunction'), $options) + new TwigFunction('label', array($this, 'labelFunction'), $options), + new TwigFunction('label_primary', array($this, 'labelPrimaryFunction'), $options), + new TwigFunction('label_success', array($this, 'labelSuccessFunction'), $options), + new TwigFunction('label_info', array($this, 'labelInfoFunction'), $options), + new TwigFunction('label_warning', array($this, 'labelWarningFunction'), $options), + new TwigFunction('label_danger', array($this, 'labelDangerFunction'), $options) ); }