diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index cca38b3..2e7c705 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,8 +17,10 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('admingenerator_form_extensions'); + $treeBuilder = new TreeBuilder('admingenerator_form_extensions'); + $rootNode = method_exists(TreeBuilder::class, 'getRootNode') + ? $treeBuilder->getRootNode() + : $treeBuilder->root('admingenerator_form_extensions'); $rootNode ->children() diff --git a/Resources/config/services.xml b/Resources/config/services.xml index eb5f98a..15cdcf2 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -109,7 +109,7 @@ - + diff --git a/Resources/views/Form/BootstrapCollection/collection_add.html.twig b/Resources/views/Form/BootstrapCollection/collection_add.html.twig index 9f57aa9..02f786e 100644 --- a/Resources/views/Form/BootstrapCollection/collection_add.html.twig +++ b/Resources/views/Form/BootstrapCollection/collection_add.html.twig @@ -1,8 +1,8 @@ {% if allow_add %} -{% spaceless %} +{% apply spaceless %} {{- ' ' ~ 's2a_bootstrap_collection.add'|trans({}, 'AdmingeneratorFormExtensions') -}} -{% endspaceless %} +{% endapply %} {% endif %} \ No newline at end of file diff --git a/Resources/views/Form/BootstrapCollection/collection_batch_delete.html.twig b/Resources/views/Form/BootstrapCollection/collection_batch_delete.html.twig index 252ef43..a8851d1 100644 --- a/Resources/views/Form/BootstrapCollection/collection_batch_delete.html.twig +++ b/Resources/views/Form/BootstrapCollection/collection_batch_delete.html.twig @@ -1,5 +1,5 @@ {% if allow_delete %} -{% spaceless %} +{% apply spaceless %} {{- ' ' ~ 's2a_bootstrap_collection.delete'|trans({}, 'AdmingeneratorFormExtensions') -}} @@ -7,5 +7,5 @@ -{% endspaceless %} +{% endapply %} {% endif %} \ No newline at end of file diff --git a/Resources/views/Form/BootstrapCollection/collection_delete.html.twig b/Resources/views/Form/BootstrapCollection/collection_delete.html.twig index a848a68..d5f1b4b 100644 --- a/Resources/views/Form/BootstrapCollection/collection_delete.html.twig +++ b/Resources/views/Form/BootstrapCollection/collection_delete.html.twig @@ -1,5 +1,5 @@ {% if allow_delete %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endif %} \ No newline at end of file diff --git a/Resources/views/Form/SingleUpload/macros.html.twig b/Resources/views/Form/SingleUpload/macros.html.twig index f9f5216..2e147ce 100644 --- a/Resources/views/Form/SingleUpload/macros.html.twig +++ b/Resources/views/Form/SingleUpload/macros.html.twig @@ -1,5 +1,5 @@ {% macro bytesToSize(bytes) %} -{% spaceless %} +{% apply spaceless %} {% set kilobyte = 1000 %} {% set megabyte = kilobyte * 1000 %} {% set gigabyte = megabyte * 1000 %} @@ -19,5 +19,5 @@ {% else %} {{ (bytes / petabyte)|number_format(2, '.') ~ ' PB' }} {% endif %} -{% endspaceless %} +{% endapply %} {% endmacro %} diff --git a/Resources/views/Form/form_css.html.twig b/Resources/views/Form/form_css.html.twig index c86031e..6adccaa 100644 --- a/Resources/views/Form/form_css.html.twig +++ b/Resources/views/Form/form_css.html.twig @@ -1,24 +1,24 @@ {% block s2a_collection_fieldset_css %} -{% spaceless %} +{% apply spaceless %} {% include "@AdmingeneratorFormExtensions/Form/BootstrapCollection/stylesheet.html.twig" %} -{% endspaceless %} +{% endapply %} {% endblock s2a_collection_fieldset_css %} {% block s2a_collection_table_css %} -{% spaceless %} +{% apply spaceless %} {% include "@AdmingeneratorFormExtensions/Form/BootstrapCollection/stylesheet.html.twig" %} -{% endspaceless %} +{% endapply %} {% endblock s2a_collection_table_css %} {% block s2a_collection_upload_css %} -{% spaceless %} +{% apply spaceless %} {% include "@AdmingeneratorFormExtensions/Form/UploadCollection/stylesheet.html.twig" %} -{% endspaceless %} +{% endapply %} {% endblock s2a_collection_upload_css %} {% block s2a_google_map_css %} -{% spaceless %} +{% apply spaceless %} {% include "@AdmingeneratorFormExtensions/Form/GoogleMap/stylesheet.html.twig" %} -{% endspaceless %} +{% endapply %} {% endblock s2a_google_map_css %} diff --git a/Resources/views/Form/form_html.html.twig b/Resources/views/Form/form_html.html.twig index a1560ea..b5dd286 100644 --- a/Resources/views/Form/form_html.html.twig +++ b/Resources/views/Form/form_html.html.twig @@ -1,26 +1,26 @@ {% block form_row %} -{% spaceless %} +{% apply spaceless %}
{{ form_label(form) }} {{ form_widget(form) }} {{ form_errors(form) }} {{ block('form_help') }}
-{% endspaceless %} +{% endapply %} {% endblock form_row %} {% block form_help %} -{% spaceless %} +{% apply spaceless %} {% if help %}

{{ help|trans({}, translation_domain) }}

{% endif %} -{% endspaceless %} +{% endapply %} {% endblock form_help %} {% block s2a_collection_fieldset_widget %} -{% spaceless %} +{% apply spaceless %} {% if prototype is defined %} {% set item = prototype %} {% set attr = attr|merge({'data-prototype': block('s2a_collection_fieldset_item') }) %} @@ -39,7 +39,7 @@
{{ form_rest(form) }} -{% endspaceless %} +{% endapply %} {% endblock s2a_collection_fieldset_widget %} {% block s2a_collection_fieldset_item %} @@ -54,7 +54,7 @@ {% endblock s2a_collection_fieldset_item %} {% block s2a_collection_table_widget %} -{% spaceless %} +{% apply spaceless %} {% if prototype is defined %} {% set item = prototype %} {% set attr = attr|merge({'data-prototype': block('s2a_collection_table_item') }) %} @@ -75,7 +75,7 @@ {% endfor %} -{% endspaceless %} +{% endapply %} {% endblock s2a_collection_table_widget %} {% block s2a_collection_table_item %} @@ -119,7 +119,7 @@ {% endblock s2a_collection_table_item %} {% block s2a_upload_collection_widget %} -{% spaceless %} +{% apply spaceless %} {% set original_full_name = full_name %} {% set full_name = full_name ~ '[uploads][]' %}
@@ -164,11 +164,11 @@ {% include "@AdmingeneratorFormExtensions/Form/UploadCollection/template_upload.html.twig" %} {% endif %}
-{% endspaceless %} +{% endapply %} {% endblock s2a_upload_collection_widget %} {% block s2a_double_list_prototype %} -{% spaceless %} +{% apply spaceless %}
{{ block('choice_widget') }}
-{% endspaceless %} +{% endapply %} {% endblock s2a_double_list_prototype %} {% block s2a_double_list_document_widget %} @@ -197,7 +197,7 @@ {% endblock s2a_double_list_model_widget %} {% block s2a_single_upload_widget %} -{% spaceless %} +{% apply spaceless %}
@@ -210,7 +210,7 @@ {% include "@AdmingeneratorFormExtensions/Form/SingleUpload/preview.html.twig" %}
-{% endspaceless %} +{% endapply %} {% endblock s2a_single_upload_widget %} {% block s2a_select2_choice_widget %} @@ -246,7 +246,7 @@ {% endblock %} {% block s2a_datetime_family_prototype %} -{% spaceless %} +{% apply spaceless %}
@@ -257,7 +257,7 @@
-{% endspaceless %} +{% endapply %} {% endblock s2a_datetime_family_prototype %} {% block s2a_datetime_family_widget_attributes -%} @@ -280,28 +280,28 @@ {%- endblock s2a_datetime_family_widget_attributes %} {% block s2a_datetime_picker_widget %} -{% spaceless %} +{% apply spaceless %} {% set widgetIcon = 'fa fa-calendar' %} {{ block('s2a_datetime_family_prototype') }} -{% endspaceless %} +{% endapply %} {% endblock s2a_datetime_picker_widget %} {% block s2a_date_picker_widget %} -{% spaceless %} +{% apply spaceless %} {% set widgetIcon = 'fa fa-calendar' %} {{ block('s2a_datetime_family_prototype') }} -{% endspaceless %} +{% endapply %} {% endblock s2a_date_picker_widget %} {% block s2a_time_picker_widget %} -{% spaceless %} +{% apply spaceless %} {% set widgetIcon = 'fa fa-clock-o' %} {{ block('s2a_datetime_family_prototype') }} -{% endspaceless %} +{% endapply %} {% endblock s2a_time_picker_widget %} {% block s2a_google_map_widget %} -{% spaceless %} +{% apply spaceless %}
@@ -323,23 +323,23 @@ {{ form_row(child) }} {% endfor %}
-{% endspaceless %} +{% endapply %} {% endblock s2a_google_map_widget %} {% block s2a_money_widget %} -{% spaceless %} +{% apply spaceless %}
{{ money_pattern|replace({ '{{ widget }}': '' })|raw }} {{ block('form_widget_simple')|raw }}
-{% endspaceless %} +{% endapply %} {% endblock %} {% block s2a_daterange_picker_widget %} -{% spaceless %} +{% apply spaceless %}
{{ block('form_widget_simple') }}
-{% endspaceless %} +{% endapply %} {% endblock s2a_daterange_picker_widget %} diff --git a/Resources/views/Form/form_js.html.twig b/Resources/views/Form/form_js.html.twig index 0972fc6..6aacbd5 100644 --- a/Resources/views/Form/form_js.html.twig +++ b/Resources/views/Form/form_js.html.twig @@ -1,6 +1,6 @@ {% block s2a_bootstrap_collection_js_prototype %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} $field.bootstrapCollection({ allow_add: {{ allow_add|e4js }}, allow_delete: {{ allow_delete|e4js }}, @@ -26,13 +26,13 @@ {% endif %} } }); -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_bootstrap_collection_js_prototype %} {% block s2a_collection_fieldset_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_upload_collection_js %} {% block s2a_daterange_picker_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_daterange_picker_js %} {% block s2a_double_list_family_js_prototype_template %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} $field.doubleList(); -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_double_list_family_js_prototype_template %} {% block s2a_double_list_document_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_double_list_document_js %} {% block s2a_double_list_entity_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_double_list_entity_js %} {% block s2a_double_list_model_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_double_list_model_js %} {% block s2a_knob_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_knob_js %} {% block s2a_mini_colors_js %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endblock s2a_mini_colors_js %} {% block s2a_select2_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_select2_js %} {% block s2a_single_upload_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_single_upload_js %} {% block s2a_elastic_textarea_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_elastic_textarea_js %} {% block choice_js %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endblock choice_js %} {% block s2a_datetime_family_js_prototype_template %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} var $widget = $('#'+$field.attr('id')+'_widget'); var config = {{ { 'locale': app.request.locale, @@ -434,13 +434,13 @@ $widget.trigger("dp.change"); }); $field.closest('form').on('submit', copyValue); -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_datetime_family_js_prototype_template %} {% block s2a_datetime_picker_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_datetime_picker_js %} {% block s2a_date_picker_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_date_picker_js %} {% block s2a_time_picker_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_time_picker_js %} {% block s2a_google_map_js %} {% autoescape false %} -{% spaceless %} +{% apply spaceless %} -{% endspaceless %} +{% endapply %} {% endautoescape %} {% endblock s2a_google_map_js %} diff --git a/Twig/Extension/ImageAssetsExtension.php b/Twig/Extension/ImageAssetsExtension.php index 28b24e8..59fa408 100644 --- a/Twig/Extension/ImageAssetsExtension.php +++ b/Twig/Extension/ImageAssetsExtension.php @@ -2,6 +2,10 @@ namespace Admingenerator\FormExtensionsBundle\Twig\Extension; +use Twig\Extension\AbstractExtension; +use Twig\TwigFilter; +use Twig\TwigFunction; + /** * This extension adds common twig function for various upload manager * bundles and common twig filter image manipulation bundles. @@ -14,7 +18,7 @@ * * @author Piotr Gołębiewski */ -class ImageAssetsExtension extends \Twig_Extension +class ImageAssetsExtension extends AbstractExtension { protected $uploaderExtension; @@ -32,7 +36,7 @@ public function __construct($uploaderExtension, $filterExtension) public function getFunctions() { return array( - 'image_asset' => new \Twig_SimpleFunction('image_asset', array($this, 'asset')), + 'image_asset' => new TwigFunction('image_asset', array($this, 'asset')), ); } @@ -42,7 +46,7 @@ public function getFunctions() public function getFilters() { return array( - 'image_filter' => new \Twig_SimpleFilter('image_filter', array($this, 'filter')), + 'image_filter' => new TwigFilter('image_filter', array($this, 'filter')), ); } diff --git a/Twig/Extension/IncludeGlobalsExtension.php b/Twig/Extension/IncludeGlobalsExtension.php index 28098e4..05a21dd 100644 --- a/Twig/Extension/IncludeGlobalsExtension.php +++ b/Twig/Extension/IncludeGlobalsExtension.php @@ -3,13 +3,15 @@ namespace Admingenerator\FormExtensionsBundle\Twig\Extension; use Symfony\Component\DependencyInjection\ContainerInterface; +use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; /** * This extension adds global variables based on bundles configuration. * * @author Piotr Gołębiewski */ -class IncludeGlobalsExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface +class IncludeGlobalsExtension extends AbstractExtension implements GlobalsInterface { protected $container; diff --git a/composer.json b/composer.json index 154a055..776b5da 100644 --- a/composer.json +++ b/composer.json @@ -15,19 +15,19 @@ } ], "require": { - "symfony/config": "~2.8|~3.0|~4.0", - "symfony/dependency-injection": "~2.8|~3.0|~4.0", - "symfony/event-dispatcher": "~2.8|~3.0|~4.0", - "symfony/form": "~2.8|~3.0|~4.0", - "symfony/http-foundation": "~2.8|~3.0|~4.0", - "symfony/http-kernel": "~2.8|~3.0|~4.0", - "symfony/options-resolver": "~2.8|~3.0|~4.0", - "symfony/property-access": "~2.8|~3.0|~4.0", - "symfony/translation": "~2.8|~3.0|~4.0", - "symfony/validator": "~2.8|~3.0|~4.0", - "twig/twig": "~1.26||~2.0", - "twig/extensions": "~1.0", - "symfony2admingenerator/form-bundle": "~1.5" + "symfony/config": "~2.8|~3.0|~4.0|~5.0", + "symfony/dependency-injection": "~2.8|~3.0|~4.0|~5.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0|~5.0", + "symfony/form": "~2.8|~3.0|~4.0|~5.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0|~5.0", + "symfony/http-kernel": "~2.8|~3.0|~4.0|~5.0", + "symfony/options-resolver": "~2.8|~3.0|~4.0|~5.0", + "symfony/property-access": "~2.8|~3.0|~4.0|~5.0", + "symfony/translation": "~2.8|~3.0|~4.0|~5.0", + "symfony/twig-bridge": "~2.8|~3.0|~4.0|~5.0", + "symfony/validator": "~2.8|~3.0|~4.0|~5.0", + "twig/twig": "~1.40|~2.9|~3.0", + "symfony2admingenerator/form-bundle": "~1.7" }, "suggest": { "symfony2admingenerator/generator-bundle": "The missing symfony2 admin generator", @@ -35,14 +35,13 @@ "vich/uploader-bundle": "(>= 0.10.0) Bundle to ease file uploads with ORM entities and ODM documents" }, "autoload": { - "psr-0": { - "Admingenerator\\FormExtensionsBundle": "" + "psr-4": { + "Admingenerator\\FormExtensionsBundle\\": "" } }, - "target-dir": "Admingenerator/FormExtensionsBundle", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.x-dev" } } }