Skip to content

Commit c43c1c3

Browse files
committed
Merge pull request #1107 from Soullivaneuh/twig-deprecated
Fix deprecated twig stuff usage. Thanks @soullivaneuh
2 parents df1027b + d9d0903 commit c43c1c3

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

Resources/views/Form/fields.html.twig

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
{% set attr = attr|merge({'class': attr.class|default('') ~ ' not-removable'}) %}
8989
{% endif %}
9090
{% set attr = attr|merge({'class': (attr.class|default('') ~ ' ' ~ widget_form_control_class)|trim}) %}
91-
{% if static_text is sameas(true) %}
91+
{% if static_text is same as(true) %}
9292
<p class="form-control-static">{{ value }}</p>
9393
{% else %}
9494
{{ parent() }}
@@ -237,7 +237,7 @@
237237

238238
{% block checkbox_widget %}
239239
{% spaceless %}
240-
{% if label is not sameas(false) and label is empty %}
240+
{% if label is not same as(false) and label is empty %}
241241
{%- if label_format is defined and label_format is not empty -%}
242242
{% set label = label_format|replace({
243243
'%name%': name,
@@ -432,7 +432,7 @@
432432
{% block form_label %}
433433
{% if 'checkbox' not in block_prefixes or widget_checkbox_label in ['label', 'both'] %}
434434
{% spaceless %}
435-
{% if label is not sameas(false) %}
435+
{% if label is not same as(false) %}
436436
{% if label is empty %}
437437
{%- if label_format is defined and label_format is not empty -%}
438438
{% set label = label_format|replace({
@@ -479,10 +479,10 @@
479479
{% block help_label_tooltip %}
480480
<span class="help-block">
481481
<a href="#" data-toggle="tooltip" data-placement="{{ help_label_tooltip.placement}}" data-title="{{ help_label_tooltip.title|trans({}, translation_domain) }}">
482-
{% if help_label_tooltip.icon is not sameas(false) %}
482+
{% if help_label_tooltip.icon is not same as(false) %}
483483
{{ mopa_bootstrap_icon(help_label_tooltip.icon) }}
484484
{% endif %}
485-
{% if help_label_tooltip.text is not sameas(null) %}
485+
{% if help_label_tooltip.text is not same as(null) %}
486486
{{ help_label_tooltip.text }}
487487
{% endif %}
488488
</a>
@@ -497,10 +497,10 @@
497497
{% block help_label_popover %}
498498
<span class="help-block">
499499
<a href="#" data-toggle="popover" data-trigger="hover" data-placement="{{ help_label_popover.placement}}" data-title="{{ help_label_popover.title|trans({}, translation_domain) }}" data-content="{{ help_label_popover.content|trans({}, translation_domain) }}" data-html="true">
500-
{% if help_label_popover.icon is not sameas(false) %}
500+
{% if help_label_popover.icon is not same as(false) %}
501501
{{ mopa_bootstrap_icon(help_label_popover.icon) }}
502502
{% endif %}
503-
{% if help_label_popover.text is not sameas(null) %}
503+
{% if help_label_popover.text is not same as(null) %}
504504
{{ help_label_popover.text|raw }}
505505
{% endif %}
506506
</a>
@@ -542,12 +542,12 @@
542542
{% spaceless %}
543543
{% if 'tab' in form.vars.block_prefixes %}
544544
{{ block('form_tab') }}
545-
{% elseif embed_form is sameas(true) %}
545+
{% elseif embed_form is same as(true) %}
546546
{{ widget_prefix|trans({}, translation_domain)|raw }} {{ form_widget(form, _context) }} {{ widget_suffix|trans({}, translation_domain)|raw }}
547547
{% else %}
548548
{{ block('widget_form_group_start') }}
549549

550-
{% set show_horizontal_wrapper = horizontal and not (form.parent is not null and 'collection' in form.parent.vars.block_prefixes and form.parent.vars.horizontal_wrap_children is sameas(false)) %}
550+
{% set show_horizontal_wrapper = horizontal and not (form.parent is not null and 'collection' in form.parent.vars.block_prefixes and form.parent.vars.horizontal_wrap_children is same as(false)) %}
551551

552552
{% if horizontal and not label_render %}
553553
{% set horizontal_input_wrapper_class = horizontal_input_wrapper_class ~ ' ' ~ horizontal_label_offset_class %}
@@ -614,21 +614,21 @@
614614

615615
{% block form_widget_remove_btn %}
616616
{% spaceless %}
617-
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not sameas(false) %}
617+
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not same as(false) %}
618618
<div class="{{ widget_remove_btn.wrapper_div.class }}">
619619
{% endif %}
620-
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not sameas(false) %}
620+
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not same as(false) %}
621621
<div class="{{ widget_remove_btn.horizontal_wrapper_div.class }}">
622622
{% endif %}
623623
{% if widget_remove_btn|default(null) %}
624624
{% set button_type = 'remove' %}
625625
{% set button_values = widget_remove_btn %}
626626
{{ block('collection_button') }}
627627
{% endif %}
628-
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not sameas(false) %}
628+
{% if widget_remove_btn.horizontal_wrapper_div is defined and widget_remove_btn.horizontal_wrapper_div is not same as(false) %}
629629
</div>
630630
{% endif %}
631-
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not sameas(false) %}
631+
{% if widget_remove_btn.wrapper_div is defined and widget_remove_btn.wrapper_div is not same as(false) %}
632632
</div>
633633
{% endif %}
634634
{% endspaceless %}
@@ -733,10 +733,10 @@
733733
{# Add Error Class to Widget Wrapper#}
734734
{% set widget_form_group_attr = widget_form_group_attr|merge({'class': widget_form_group_attr.class|default('') ~ ' has-error'}) %}
735735
{% endif %}
736-
{% if help_widget_popover.selector is sameas(null) %}
736+
{% if help_widget_popover.selector is same as(null) %}
737737
{% set help_widget_popover = help_widget_popover|merge({'selector': '#' ~ id }) %}
738738
{% endif %}
739-
<div{% if help_widget_popover.title is not sameas(null) %}{{ block('help_widget_popover') }}{% endif %} {% for attrname,attrvalue in widget_form_group_attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
739+
<div{% if help_widget_popover.title is not same as(null) %}{{ block('help_widget_popover') }}{% endif %} {% for attrname,attrvalue in widget_form_group_attr %} {{attrname}}="{{attrvalue}}"{% endfor %}>
740740
{# a form item containing the field in block_prefixes is a near subform or a field directly #}
741741
{% if (form|length > 0 and form.parent != null)
742742
and 'field' not in form.vars.block_prefixes

Twig/FormExtension.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@ class FormExtension extends \Twig_Extension
2929
public function getFunctions()
3030
{
3131
return array(
32-
'form_help' => new \Twig_Function_Node('Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', array('is_safe' => array('html'))),
33-
'form_tabs' => new \Twig_Function_Node('Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', array('is_safe' => array('html'))),
32+
new \Twig_SimpleFunction('form_help', null, array(
33+
'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode',
34+
'is_safe' => array('html'),
35+
)),
36+
new \Twig_SimpleFunction('form_tabs', null, array(
37+
'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode',
38+
'is_safe' => array('html'),
39+
)),
3440
);
3541
}
3642

Twig/InitializrTwigExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ public function getGlobals()
6666
public function getFunctions()
6767
{
6868
return array(
69-
'form_help' => new \Twig_Function_Node('Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode', array('is_safe' => array('html'))),
69+
new \Twig_SimpleFunction('form_help', null, array(
70+
'node_class' => 'Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode',
71+
'is_safe' => array('html'),
72+
)),
7073
);
7174
}
7275

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/twig-bundle": "~2.3|~3.0",
2626
"symfony/form": "~2.3|~3.0",
2727
"symfony/console": "~2.3",
28-
"twig/twig": ">=1.12",
28+
"twig/twig": "^1.14.2",
2929
"mopa/composer-bridge": "~1.3"
3030
},
3131
"require-dev": {

0 commit comments

Comments
 (0)