From 1cb3ac919c6839119d66f1508403c3169a6266c5 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Tue, 3 Aug 2021 10:05:57 +0200 Subject: [PATCH 1/9] Add enable option in the service configuration --- .php-cs-fixer.cache | 2 +- CHANGELOG.md | 8 + composer.json | 5 +- composer.lock | 263 +++++++++++++++++- src/DependencyInjection/Configuration.php | 1 + src/Resources/views/scripts.html.twig | 30 +- .../ConfigurationTest.php | 10 +- tests/Resources/Kernel/config/bundles.php | 1 + .../Kernel/config/packages/monolog.yaml | 12 + .../packages/rich_id_cookies_regulation.yaml | 8 +- .../CookiesRegulationTwigExtensionTest.php | 10 +- 11 files changed, 329 insertions(+), 21 deletions(-) create mode 100644 tests/Resources/Kernel/config/packages/monolog.yaml diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index 594d289..57df4ca 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":2506252486,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":806782089,"tests\/Resources\/Kernel\/config\/bundles.php":1465543017,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":297038170,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file +{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":1746163908,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1752397996,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":429969187,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 825c32f..7404a69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,9 @@ # Changelog + +## Version 0.1.2 + +- Add enable option in the service configuration + +## Version 0.1.0 + +- Initial commit diff --git a/composer.json b/composer.json index 3939ee7..c1950ae 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "license": "MIT", "authors": [ { - "name": "RichId", + "name": "Rich-ID", "homepage": "https://www.rich-id.com" } ], @@ -28,7 +28,8 @@ "phpunit/phpunit": "^9.5", "richcongress/static-analysis": "^0.1", "richcongress/test-suite": "^0.1", - "roave/security-advisories": "dev-latest" + "roave/security-advisories": "dev-latest", + "symfony/monolog-bundle": "^3.7" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index aaeb4bd..569c460 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "948fb1901d2abedab544d52224b5ff6b", + "content-hash": "49369437790d23584c8bba0a28cd640f", "packages": [ { "name": "composer/package-versions-deprecated", @@ -5424,6 +5424,102 @@ }, "time": "2021-02-24T09:51:49+00:00" }, + { + "name": "monolog/monolog", + "version": "2.3.2", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "71312564759a7db5b789296369c1a264efc43aad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/71312564759a7db5b789296369c1a264efc43aad", + "reference": "71312564759a7db5b789296369c1a264efc43aad", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/log": "^1.0.1" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7", + "graylog2/gelf-php": "^1.4.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpspec/prophecy": "^1.6.1", + "phpstan/phpstan": "^0.12.91", + "phpunit/phpunit": "^8.5", + "predis/predis": "^1.1", + "rollbar/rollbar": "^1.3", + "ruflin/elastica": ">=0.90 <7.0.1", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "php-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/2.3.2" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2021-07-23T07:42:52+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.10.2", @@ -9265,6 +9361,171 @@ ], "time": "2021-07-23T15:55:36+00:00" }, + { + "name": "symfony/monolog-bridge", + "version": "v5.3.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/monolog-bridge.git", + "reference": "a0d881165b902a04f41e873426aa52a068064ac4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/monolog-bridge/zipball/a0d881165b902a04f41e873426aa52a068064ac4", + "reference": "a0d881165b902a04f41e873426aa52a068064ac4", + "shasum": "" + }, + "require": { + "monolog/monolog": "^1.25.1|^2", + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1", + "symfony/http-kernel": "^5.3", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2" + }, + "conflict": { + "symfony/console": "<4.4", + "symfony/http-foundation": "<5.3" + }, + "require-dev": { + "symfony/console": "^4.4|^5.0", + "symfony/http-client": "^4.4|^5.0", + "symfony/mailer": "^4.4|^5.0", + "symfony/messenger": "^4.4|^5.0", + "symfony/mime": "^4.4|^5.0", + "symfony/security-core": "^4.4|^5.0", + "symfony/var-dumper": "^4.4|^5.0" + }, + "suggest": { + "symfony/console": "For the possibility to show log messages in console commands depending on verbosity settings.", + "symfony/http-kernel": "For using the debugging handlers together with the response life cycle of the HTTP kernel.", + "symfony/var-dumper": "For using the debugging handlers like the console handler or the log server handler." + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\Monolog\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides integration for Monolog with various Symfony components", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/monolog-bridge/tree/v5.3.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-07-23T15:55:36+00:00" + }, + { + "name": "symfony/monolog-bundle", + "version": "v3.7.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/monolog-bundle.git", + "reference": "4054b2e940a25195ae15f0a49ab0c51718922eb4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/monolog-bundle/zipball/4054b2e940a25195ae15f0a49ab0c51718922eb4", + "reference": "4054b2e940a25195ae15f0a49ab0c51718922eb4", + "shasum": "" + }, + "require": { + "monolog/monolog": "~1.22 || ~2.0", + "php": ">=7.1.3", + "symfony/config": "~4.4 || ^5.0", + "symfony/dependency-injection": "^4.4 || ^5.0", + "symfony/http-kernel": "~4.4 || ^5.0", + "symfony/monolog-bridge": "~4.4 || ^5.0" + }, + "require-dev": { + "symfony/console": "~4.4 || ^5.0", + "symfony/phpunit-bridge": "^5.1", + "symfony/yaml": "~4.4 || ^5.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bundle\\MonologBundle\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony MonologBundle", + "homepage": "https://symfony.com", + "keywords": [ + "log", + "logging" + ], + "support": { + "issues": "https://github.com/symfony/monolog-bundle/issues", + "source": "https://github.com/symfony/monolog-bundle/tree/v3.7.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-03-31T07:20:47+00:00" + }, { "name": "symfony/options-resolver", "version": "v5.3.4", diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 5164be5..3f94147 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -28,6 +28,7 @@ protected function buildConfig(NodeBuilder $nodeBuilder): void $modalNode->scalarNode('related_companies_privacy_policy_url')->isRequired(); $servicesNode = $nodeBuilder->arrayNode('services')->normalizeKeys(true)->arrayPrototype()->children(); + $servicesNode->booleanNode('enable')->defaultTrue(); $servicesNode->scalarNode('name')->isRequired(); $servicesNode->scalarNode('description')->isRequired(); $servicesNode->scalarNode('conservation')->isRequired(); diff --git a/src/Resources/views/scripts.html.twig b/src/Resources/views/scripts.html.twig index 7f101d8..7d5865a 100644 --- a/src/Resources/views/scripts.html.twig +++ b/src/Resources/views/scripts.html.twig @@ -28,20 +28,22 @@ }, services: { {% for serviceName, serviceConfig in config.services %} - {{ serviceName }}: { - name: '{{ serviceConfig.name }}', - description: '{{ serviceConfig.description }}', - conservation: '{{ serviceConfig.conservation }}', - {% if serviceConfig.predefined is not null %} - service: '{{ serviceConfig.predefined.name }}', - options: {{ serviceConfig.predefined.options|default([])|json_encode|raw }}, - {% endif %} - {% if serviceConfig.initialization_callback is not null %} - initializationCallback: function() { - {{ serviceConfig.initialization_callback|raw }} - }, - {% endif %} - }, + {% if serviceConfig.enable %} + {{ serviceName }}: { + name: '{{ serviceConfig.name }}', + description: '{{ serviceConfig.description }}', + conservation: '{{ serviceConfig.conservation }}', + {% if serviceConfig.predefined is not null %} + service: '{{ serviceConfig.predefined.name }}', + options: {{ serviceConfig.predefined.options|default([])|json_encode|raw }}, + {% endif %} + {% if serviceConfig.initialization_callback is not null %} + initializationCallback: function() { + {{ serviceConfig.initialization_callback|raw }} + }, + {% endif %} + }, + {% endif %} {% endfor %} }, } diff --git a/tests/DependencyConfiguration/ConfigurationTest.php b/tests/DependencyConfiguration/ConfigurationTest.php index d135654..3667651 100644 --- a/tests/DependencyConfiguration/ConfigurationTest.php +++ b/tests/DependencyConfiguration/ConfigurationTest.php @@ -47,15 +47,23 @@ public function testInstantiationContainer(): void ], 'services' => [ 'google_tag_manager' => [ + 'enable' => true, 'name' => 'Google Tag Manager', 'description' => 'Tag management system', - 'conservation' => '6 months.', + 'conservation' => '6 months', 'initialization_callback' => null, 'predefined' => [ 'name' => 'googleTagManager', 'options' => ['id' => 'GTM-TEST'], ], ], + 'another_service' => [ + 'enable' => false, + 'name' => 'Another Service', + 'description' => 'Description of the another service', + 'conservation' => '1 year', + 'initialization_callback' => 'init_callback()', + ], ], ], $config diff --git a/tests/Resources/Kernel/config/bundles.php b/tests/Resources/Kernel/config/bundles.php index 259dfac..9b2d55f 100644 --- a/tests/Resources/Kernel/config/bundles.php +++ b/tests/Resources/Kernel/config/bundles.php @@ -3,5 +3,6 @@ declare(strict_types=1); return [ + Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], RichId\CookiesRegulationBundle\RichIdCookiesRegulationBundle::class => ['all' => true], ]; diff --git a/tests/Resources/Kernel/config/packages/monolog.yaml b/tests/Resources/Kernel/config/packages/monolog.yaml new file mode 100644 index 0000000..2c5e682 --- /dev/null +++ b/tests/Resources/Kernel/config/packages/monolog.yaml @@ -0,0 +1,12 @@ +monolog: + handlers: + main: + type: rotating_file + path: '%kernel.logs_dir%/%kernel.environment%.log' + level: warning + max_files: 14 + channels: ['!event', '!app'] + console: + type: console + process_psr_3_messages: false + bubble: false diff --git a/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml b/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml index 6fddac3..02791cd 100644 --- a/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml +++ b/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml @@ -11,8 +11,14 @@ rich_id_cookies_regulation: google_tag_manager: name: 'Google Tag Manager' description: 'Tag management system' - conservation: '6 months.' + conservation: '6 months' predefined: name: 'googleTagManager' options: { id: 'GTM-TEST' } + another_service: + enable: false + name: 'Another Service' + description: 'Description of the another service' + conservation: '1 year' + initialization_callback: 'init_callback()' diff --git a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php index 89fd5ea..1e21616 100644 --- a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php +++ b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php @@ -46,15 +46,23 @@ public function testGetConfig(): void ], 'services' => [ 'google_tag_manager' => [ + 'enable' => true, 'name' => 'Google Tag Manager', 'description' => 'Tag management system', - 'conservation' => '6 months.', + 'conservation' => '6 months', 'initialization_callback' => null, 'predefined' => [ 'name' => 'googleTagManager', 'options' => ['id' => 'GTM-TEST'], ], ], + 'another_service' => [ + 'enable' => false, + 'name' => 'Another Service', + 'description' => 'Description of the another service', + 'conservation' => '1 year', + 'initialization_callback' => 'init_callback()', + ], ], ], $config From 9b2843b096fc43173a972dc942ed36e75f107544 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Tue, 3 Aug 2021 10:06:58 +0200 Subject: [PATCH 2/9] Fix changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7404a69..ace9f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Version 0.1.2 +## Version 0.1.1 - Add enable option in the service configuration From 899c793ef80ad1ad54894e3f38a7e4fbb9bf0371 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Tue, 3 Aug 2021 10:52:13 +0200 Subject: [PATCH 3/9] Add mandatory option --- .php-cs-fixer.cache | 2 +- CHANGELOG.md | 6 ++---- src/DependencyInjection/Configuration.php | 1 + src/Resources/views/scripts.html.twig | 1 + tests/DependencyConfiguration/ConfigurationTest.php | 2 ++ .../Kernel/config/packages/rich_id_cookies_regulation.yaml | 1 + tests/TwigExtension/CookiesRegulationTwigExtensionTest.php | 2 ++ 7 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index 57df4ca..a8fe8e9 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":1746163908,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1752397996,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":429969187,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file +{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":1391913670,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1934178024,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":2181479890,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ace9f53..7c0f18c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,7 @@ # Changelog -## Version 0.1.1 - -- Add enable option in the service configuration - ## Version 0.1.0 - Initial commit +- Add enable option in the service configuration +- Add mandatory option in the service configuration diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 3f94147..b8294cf 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -31,6 +31,7 @@ protected function buildConfig(NodeBuilder $nodeBuilder): void $servicesNode->booleanNode('enable')->defaultTrue(); $servicesNode->scalarNode('name')->isRequired(); $servicesNode->scalarNode('description')->isRequired(); + $servicesNode->booleanNode('mandatory')->defaultFalse(); $servicesNode->scalarNode('conservation')->isRequired(); $servicesNode->scalarNode('initialization_callback')->defaultNull(); diff --git a/src/Resources/views/scripts.html.twig b/src/Resources/views/scripts.html.twig index 7d5865a..f4144c4 100644 --- a/src/Resources/views/scripts.html.twig +++ b/src/Resources/views/scripts.html.twig @@ -33,6 +33,7 @@ name: '{{ serviceConfig.name }}', description: '{{ serviceConfig.description }}', conservation: '{{ serviceConfig.conservation }}', + mandatory: {% if serviceConfig.mandatory %}true{% else %}false{% endif %}, {% if serviceConfig.predefined is not null %} service: '{{ serviceConfig.predefined.name }}', options: {{ serviceConfig.predefined.options|default([])|json_encode|raw }}, diff --git a/tests/DependencyConfiguration/ConfigurationTest.php b/tests/DependencyConfiguration/ConfigurationTest.php index 3667651..2afbae4 100644 --- a/tests/DependencyConfiguration/ConfigurationTest.php +++ b/tests/DependencyConfiguration/ConfigurationTest.php @@ -50,6 +50,7 @@ public function testInstantiationContainer(): void 'enable' => true, 'name' => 'Google Tag Manager', 'description' => 'Tag management system', + 'mandatory' => true, 'conservation' => '6 months', 'initialization_callback' => null, 'predefined' => [ @@ -61,6 +62,7 @@ public function testInstantiationContainer(): void 'enable' => false, 'name' => 'Another Service', 'description' => 'Description of the another service', + 'mandatory' => false, 'conservation' => '1 year', 'initialization_callback' => 'init_callback()', ], diff --git a/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml b/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml index 02791cd..cd26aa5 100644 --- a/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml +++ b/tests/Resources/Kernel/config/packages/rich_id_cookies_regulation.yaml @@ -11,6 +11,7 @@ rich_id_cookies_regulation: google_tag_manager: name: 'Google Tag Manager' description: 'Tag management system' + mandatory: true conservation: '6 months' predefined: name: 'googleTagManager' diff --git a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php index 1e21616..ff41929 100644 --- a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php +++ b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php @@ -49,6 +49,7 @@ public function testGetConfig(): void 'enable' => true, 'name' => 'Google Tag Manager', 'description' => 'Tag management system', + 'mandatory' => true, 'conservation' => '6 months', 'initialization_callback' => null, 'predefined' => [ @@ -60,6 +61,7 @@ public function testGetConfig(): void 'enable' => false, 'name' => 'Another Service', 'description' => 'Description of the another service', + 'mandatory' => false, 'conservation' => '1 year', 'initialization_callback' => 'init_callback()', ], From 96f22d5ac60f6dccb5ec499ffffaad9640a3de27 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Tue, 3 Aug 2021 16:22:35 +0200 Subject: [PATCH 4/9] Fix all configurations flaws --- .php-cs-fixer.cache | 2 +- src/DependencyInjection/Configuration.php | 29 ++++++++++++--- src/Resources/views/partials/_modal.html.twig | 7 ++++ .../views/partials/_privacy_policy.html.twig | 7 ++++ .../views/partials/_services.html.twig | 26 ++++++++++++++ .../views/partials/_url_config.html.twig | 12 +++++++ src/Resources/views/scripts.html.twig | 36 ++++++------------- 7 files changed, 89 insertions(+), 30 deletions(-) create mode 100644 src/Resources/views/partials/_modal.html.twig create mode 100644 src/Resources/views/partials/_privacy_policy.html.twig create mode 100644 src/Resources/views/partials/_services.html.twig create mode 100644 src/Resources/views/partials/_url_config.html.twig diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache index a8fe8e9..5396806 100644 --- a/.php-cs-fixer.cache +++ b/.php-cs-fixer.cache @@ -1 +1 @@ -{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":1391913670,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1934178024,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":2181479890,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file +{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":2959179742,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1934178024,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":2181479890,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index b8294cf..2897b79 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -5,6 +5,7 @@ namespace RichId\CookiesRegulationBundle\DependencyInjection; use RichCongress\BundleToolbox\Configuration\AbstractConfiguration; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\NodeBuilder; class Configuration extends AbstractConfiguration @@ -18,25 +19,45 @@ protected function buildConfig(NodeBuilder $nodeBuilder): void $nodeBuilder->scalarNode('locale')->defaultValue('en')->isRequired(); $privacyPolicyNode = $nodeBuilder->arrayNode('privacy_policy')->addDefaultsIfNotSet()->children(); - $privacyPolicyNode->scalarNode('url')->isRequired(); + $privacyPolicyNode->scalarNode('route'); $privacyPolicyNode->scalarNode('label')->defaultValue('Privacy Policy'); $privacyPolicyNode->booleanNode('open_in_new_window')->defaultTrue(); + $privacyPolicyUrlNode = $privacyPolicyNode->arrayNode('url'); + self::addUrlOrRouteConfig($privacyPolicyUrlNode); + $modalNode = $nodeBuilder->arrayNode('modal')->children(); $modalNode->scalarNode('header')->isRequired(); $modalNode->integerNode('related_companies_count')->isRequired(); - $modalNode->scalarNode('related_companies_privacy_policy_url')->isRequired(); + + $relatedCompaniesPrivacyPolicyUrlNode = $modalNode->arrayNode('related_companies_privacy_policy_url'); + self::addUrlOrRouteConfig($relatedCompaniesPrivacyPolicyUrlNode); $servicesNode = $nodeBuilder->arrayNode('services')->normalizeKeys(true)->arrayPrototype()->children(); $servicesNode->booleanNode('enable')->defaultTrue(); $servicesNode->scalarNode('name')->isRequired(); - $servicesNode->scalarNode('description')->isRequired(); + $servicesNode->scalarNode('description'); $servicesNode->booleanNode('mandatory')->defaultFalse(); $servicesNode->scalarNode('conservation')->isRequired(); - $servicesNode->scalarNode('initialization_callback')->defaultNull(); + $servicesNode->arrayNode('cookies_identifiers')->scalarPrototype(); + $servicesNode->scalarNode('initialization_callback'); $predefinedServiceNode = $servicesNode->arrayNode('predefined')->children(); $predefinedServiceNode->scalarNode('name')->isRequired(); $predefinedServiceNode->arrayNode('options')->ignoreExtraKeys(false); } + + private static function addUrlOrRouteConfig(ArrayNodeDefinition $node): void + { + $node->beforeNormalization() + ->ifString() + ->then(function ($v) { + return ['absolute' => $v]; + }); + + $children = $node->children(); + $children->scalarNode('absolute')->end(); + $children->scalarNode('route')->end(); + $children->arrayNode('parameters')->ignoreExtraKeys(false); + } } diff --git a/src/Resources/views/partials/_modal.html.twig b/src/Resources/views/partials/_modal.html.twig new file mode 100644 index 0000000..43c5613 --- /dev/null +++ b/src/Resources/views/partials/_modal.html.twig @@ -0,0 +1,7 @@ +{% import '@RichIdCookiesRegulation/partials/_url_config.html.twig' as urlMacro %} + +{ + header: '{{ config.header|trans|e('js') }}', + relatedCompaniesCount: {{ config.related_companies_count }}, + relatedCompaniesPrivacyPolicyUrl: '{{ urlMacro.parse(config.related_companies_privacy_policy_url)|trim }}', +} diff --git a/src/Resources/views/partials/_privacy_policy.html.twig b/src/Resources/views/partials/_privacy_policy.html.twig new file mode 100644 index 0000000..2124cb1 --- /dev/null +++ b/src/Resources/views/partials/_privacy_policy.html.twig @@ -0,0 +1,7 @@ +{% import '@RichIdCookiesRegulation/partials/_url_config.html.twig' as urlMacro %} + +{ + url: '{{ urlMacro.parse(config.url)|trim }}', + label: '{{ config.label|trans|e('js') }}', + openInNewWindow: {{ config.open_in_new_window ? 'true' : 'false' }}, +} diff --git a/src/Resources/views/partials/_services.html.twig b/src/Resources/views/partials/_services.html.twig new file mode 100644 index 0000000..e864a64 --- /dev/null +++ b/src/Resources/views/partials/_services.html.twig @@ -0,0 +1,26 @@ +{ + name: '{{ config.name|trans|e('js') }}', + description: '{{ config.description|default('')|trans|e('js') }}', + conservation: '{{ config.conservation }}', + mandatory: {% if config.mandatory %}true{% else %}false{% endif %}, + + {# Cookies identifiers #} + cookiesIdentifiers: [ + {% for identifier in config.cookies_identifiers %} + '{{ identifier|e('js') }}', + {% endfor %} + ], + + {# Preconfigured service #} + {% if (config.predefined|default(null)) is not null %} + service: '{{ config.predefined.name }}', + options: {{ config.predefined.options|default([])|json_encode|raw }}, + {% endif %} + + {# Initialization callback that starts the service if enabled #} + {% if (config.initialization_callback|default(null)) is not null %} + initializationCallback: function() { + {{ config.initialization_callback|raw }} + }, + {% endif %} +} diff --git a/src/Resources/views/partials/_url_config.html.twig b/src/Resources/views/partials/_url_config.html.twig new file mode 100644 index 0000000..0d1c214 --- /dev/null +++ b/src/Resources/views/partials/_url_config.html.twig @@ -0,0 +1,12 @@ +{%- macro parse(urlConfig) -%} + {% if (urlConfig.absolute|default(null)) is not null %} + {{ urlConfig.absolute }} + {% else %} + {{ absolute_url( + path( + urlConfig.route, + urlConfig.parameters|default({}) + ) + ) }} + {% endif %} +{%- endmacro -%} diff --git a/src/Resources/views/scripts.html.twig b/src/Resources/views/scripts.html.twig index f4144c4..b39b779 100644 --- a/src/Resources/views/scripts.html.twig +++ b/src/Resources/views/scripts.html.twig @@ -10,40 +10,26 @@ { website: '{{ config.website }}', locale: '{{ config.locale }}', - privacyPolicy: { - url: '{{ config.privacy_policy.url }}', - label: '{{ config.privacy_policy.label }}', - openInNewWindow: {{ config.privacy_policy.open_in_new_window ? 'true' : 'false' }}, - }, - modal: { - header: '{{ config.modal.header }}', - relatedCompaniesCount: {{ config.modal.related_companies_count }}, - relatedCompaniesPrivacyPolicyUrl: '{{ config.modal.related_companies_privacy_policy_url }}', - }, + + {# Configuration the privacy policies #} + privacyPolicy: {% include '@RichIdCookiesRegulation/partials/_privacy_policy.html.twig' with {config: config.privacy_policy} %}, + + {# Configure the modal #} + modal: {% include '@RichIdCookiesRegulation/partials/_modal.html.twig' with {config: config.modal} %}, + + {# Logs each decisions #} decisionLogCallback: (decision) => { const client = new XMLHttpRequest(); client.open('POST', '{{ url('post_cookies_regulation_decision_log') }}', true); client.setRequestHeader('Content-type', 'application/json'); client.send(JSON.stringify(decision)); }, + + {# List of loaded services #} services: { {% for serviceName, serviceConfig in config.services %} {% if serviceConfig.enable %} - {{ serviceName }}: { - name: '{{ serviceConfig.name }}', - description: '{{ serviceConfig.description }}', - conservation: '{{ serviceConfig.conservation }}', - mandatory: {% if serviceConfig.mandatory %}true{% else %}false{% endif %}, - {% if serviceConfig.predefined is not null %} - service: '{{ serviceConfig.predefined.name }}', - options: {{ serviceConfig.predefined.options|default([])|json_encode|raw }}, - {% endif %} - {% if serviceConfig.initialization_callback is not null %} - initializationCallback: function() { - {{ serviceConfig.initialization_callback|raw }} - }, - {% endif %} - }, + {{ serviceName }}: {% include '@RichIdCookiesRegulation/partials/_services.html.twig' with {config: serviceConfig} %}, {% endif %} {% endfor %} }, From be8311706034c6e1b887b6901746f372a1bc2ce1 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Wed, 4 Aug 2021 09:40:01 +0200 Subject: [PATCH 5/9] Add translation for conservation --- src/Resources/views/partials/_services.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/partials/_services.html.twig b/src/Resources/views/partials/_services.html.twig index e864a64..c7e8af9 100644 --- a/src/Resources/views/partials/_services.html.twig +++ b/src/Resources/views/partials/_services.html.twig @@ -1,7 +1,7 @@ { name: '{{ config.name|trans|e('js') }}', description: '{{ config.description|default('')|trans|e('js') }}', - conservation: '{{ config.conservation }}', + conservation: '{{ config.conservation|trans|e('js') }}', mandatory: {% if config.mandatory %}true{% else %}false{% endif %}, {# Cookies identifiers #} From b1d6e39ab055b8e26e04e29b86998954f3d648ca Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Wed, 4 Aug 2021 14:49:05 +0200 Subject: [PATCH 6/9] Fix decision logging --- .gitignore | 1 + .php-cs-fixer.cache | 1 - composer.json | 2 +- composer.lock | 79 ++++++++++--------- ...DoctrineMigrationsPrependConfiguration.php | 17 ++++ .../DoctrineMigrationsPrependTrait.php | 26 ------ .../RichIdCookiesRegulationExtension.php | 11 +-- src/Factory/CookieDecisionMetadataFactory.php | 2 +- .../views/partials/_services.html.twig | 12 +-- src/RichIdCookiesRegulationBundle.php | 27 +------ 10 files changed, 71 insertions(+), 107 deletions(-) delete mode 100644 .php-cs-fixer.cache create mode 100644 src/DependencyInjection/PrependConfiguration/DoctrineMigrationsPrependConfiguration.php delete mode 100644 src/DependencyInjection/PrependTrait/DoctrineMigrationsPrependTrait.php diff --git a/.gitignore b/.gitignore index fa6bd9a..8f81d29 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ # Static utilities .php_cs.cache +/.php-cs-fixer.cache diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache deleted file mode 100644 index 5396806..0000000 --- a/.php-cs-fixer.cache +++ /dev/null @@ -1 +0,0 @@ -{"php":"8.0.8","version":"3.0.0:v3.0.0#c15377bdfa8d1ecf186f1deadec39c89984e1167","indent":" ","lineEnding":"\n","rules":{"array_syntax":true,"backtick_to_shell_exec":true,"binary_operator_spaces":{"operators":{"=>":"align_single_space_minimal"}},"blank_line_before_statement":{"statements":["return"]},"braces":{"position_after_functions_and_oop_constructs":"next"},"cast_spaces":true,"class_attributes_separation":{"elements":{"method":"one"}},"class_definition":true,"clean_namespace":true,"concat_space":{"spacing":"one"},"echo_tag_syntax":true,"fully_qualified_strict_types":true,"function_typehint_space":true,"general_phpdoc_tag_rename":{"replacements":{"inheritDocs":"inheritDoc"}},"include":true,"increment_style":{"style":"post"},"lambda_not_used_import":true,"linebreak_after_opening_tag":true,"magic_constant_casing":true,"magic_method_casing":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"native_function_casing":true,"native_function_type_declaration_casing":true,"no_alias_language_construct_call":true,"no_alternative_syntax":true,"no_binary_string":true,"no_blank_lines_after_phpdoc":true,"no_empty_comment":true,"no_empty_phpdoc":true,"no_empty_statement":true,"no_extra_blank_lines":{"tokens":["case","continue","curly_brace_block","default","extra","parenthesis_brace_block","square_brace_block","switch","throw","use","use_trait"]},"no_leading_namespace_whitespace":true,"no_mixed_echo_print":true,"no_multiline_whitespace_around_double_arrow":true,"no_short_bool_cast":true,"no_singleline_whitespace_before_semicolons":true,"no_spaces_around_offset":true,"no_superfluous_phpdoc_tags":{"allow_mixed":true,"allow_unused_params":true},"no_trailing_comma_in_list_call":true,"no_trailing_comma_in_singleline_array":true,"no_unneeded_control_parentheses":{"statements":["break","clone","continue","echo_print","return","switch_case","yield","yield_from"]},"no_unneeded_curly_braces":{"namespaces":true},"no_unset_cast":true,"no_unused_imports":true,"no_whitespace_before_comma_in_array":true,"normalize_index_brace":true,"object_operator_without_whitespace":true,"ordered_imports":true,"php_unit_fqcn_annotation":true,"php_unit_method_casing":true,"phpdoc_align":true,"phpdoc_annotation_without_dot":true,"phpdoc_indent":true,"phpdoc_inline_tag_normalizer":true,"phpdoc_no_access":true,"phpdoc_no_alias_tag":true,"phpdoc_no_package":true,"phpdoc_no_useless_inheritdoc":true,"phpdoc_return_self_reference":true,"phpdoc_scalar":true,"phpdoc_separation":true,"phpdoc_single_line_var_spacing":true,"phpdoc_summary":true,"phpdoc_tag_type":{"tags":{"inheritDoc":"inline"}},"phpdoc_to_comment":true,"phpdoc_trim":true,"phpdoc_trim_consecutive_blank_line_separation":true,"phpdoc_types":true,"phpdoc_types_order":{"null_adjustment":"always_last","sort_algorithm":"none"},"phpdoc_var_without_name":true,"protected_to_private":true,"semicolon_after_instruction":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_comment_style":{"comment_types":["hash"]},"single_quote":true,"single_space_after_construct":true,"space_after_semicolon":{"remove_in_empty_for_expressions":true},"standardize_increment":true,"standardize_not_equals":true,"switch_continue_to_break":true,"trailing_comma_in_multiline":true,"trim_array_spaces":true,"unary_operator_spaces":true,"visibility_required":{"elements":["method","property"]},"whitespace_after_comma_in_array":true,"blank_line_after_opening_tag":true,"compact_nullable_typehint":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_braces":true,"no_blank_lines_after_class_opening":true,"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"return_type_declaration":true,"short_scalar_cast":true,"single_blank_line_before_namespace":true,"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"blank_line_after_namespace":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true,"declare_strict_types":true,"native_function_invocation":{"include":["@internal"],"scope":"namespaced","strict":true},"no_null_property_initialization":true,"no_superfluous_elseif":true,"no_useless_else":true,"phpdoc_line_span":{"property":"single","const":"single","method":"single"},"simplified_if_return":true,"void_return":true},"hashes":{"src\/DependencyInjection\/Configuration.php":2959179742,"src\/DependencyInjection\/RichIdCookiesRegulationExtension.php":298110609,"src\/DependencyInjection\/PrependTrait\/DoctrineMigrationsPrependTrait.php":375171068,"src\/Migrations\/Version20210729153826.php":1342447225,"src\/Entity\/DecisionLog.php":3321957071,"src\/RichIdCookiesRegulationBundle.php":2290190810,"src\/TwigExtension\/CookiesRegulationTwigExtension.php":1778638610,"tests\/Controller\/DecisionLogRouteTest.php":1416599904,"tests\/DependencyConfiguration\/ConfigurationTest.php":1934178024,"tests\/Resources\/Kernel\/config\/bundles.php":2732965691,"tests\/Resources\/Kernel\/TestKernel.php":1673797058,"src\/Controller\/DecisionLogRoute.php":982714999,"tests\/TwigExtension\/CookiesRegulationTwigExtensionTest.php":2181479890,"src\/Factory\/CookieDecisionMetadataFactory.php":479469219,"src\/Factory\/CookieDecisionsFactory.php":4292692117,"src\/Model\/CookieDecision.php":945963652,"src\/Model\/CookieDecisionMetadata.php":687256262}} \ No newline at end of file diff --git a/composer.json b/composer.json index c1950ae..e3cca7e 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "require": { "doctrine/orm": "^2.7", "php": "^7.3 | ^8.0", - "richcongress/bundle-toolbox": "^1.0", + "richcongress/bundle-toolbox": "^1.2", "symfony/framework-bundle": "^4.0 || ^5.0", "symfony/routing": "^4.0 || ^5.0", "twig/twig": "^2.0" diff --git a/composer.lock b/composer.lock index 569c460..880bfb2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "49369437790d23584c8bba0a28cd640f", + "content-hash": "d5ce170613ea010597a78a08b5ae75d7", "packages": [ { "name": "composer/package-versions-deprecated", @@ -1276,16 +1276,16 @@ }, { "name": "richcongress/bundle-toolbox", - "version": "v1.1.3", + "version": "v1.2.0", "source": { "type": "git", "url": "https://github.com/rich-id/bundle-toolbox.git", - "reference": "d6357763a68fe3832783964a3936bdb0c2f50c18" + "reference": "40c60f95ab105811a6220806ee031401f66bb8a9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rich-id/bundle-toolbox/zipball/d6357763a68fe3832783964a3936bdb0c2f50c18", - "reference": "d6357763a68fe3832783964a3936bdb0c2f50c18", + "url": "https://api.github.com/repos/rich-id/bundle-toolbox/zipball/40c60f95ab105811a6220806ee031401f66bb8a9", + "reference": "40c60f95ab105811a6220806ee031401f66bb8a9", "shasum": "" }, "require": { @@ -1295,13 +1295,15 @@ "symfony/http-kernel": "^3.0 || ^4.0 || ^5.0" }, "require-dev": { - "phpunit/phpunit": "^7.5", - "roave/security-advisories": "dev-master" + "doctrine/doctrine-bundle": "^1.0 || ^2.0", + "doctrine/doctrine-migrations-bundle": "^2.0 || ^3.0", + "phpunit/phpunit": "^9.5", + "roave/security-advisories": "dev-latest" }, "type": "symfony-bundle", "autoload": { "psr-4": { - "RichCongress\\BundleToolbox\\": "" + "RichCongress\\BundleToolbox\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1317,9 +1319,9 @@ "description": "A set of classes and tools to quickly build a bundle", "support": { "issues": "https://github.com/rich-id/bundle-toolbox/issues", - "source": "https://github.com/rich-id/bundle-toolbox/tree/v1.1.3" + "source": "https://github.com/rich-id/bundle-toolbox/tree/v1.2.0" }, - "time": "2021-07-20T14:02:08+00:00" + "time": "2021-08-04T08:49:22+00:00" }, { "name": "symfony/cache", @@ -4137,21 +4139,21 @@ }, { "name": "composer/xdebug-handler", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496" + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", - "reference": "964adcdd3a28bf9ed5d9ac6450064e0d71ed7496", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/84674dd3a7575ba617f5a76d7e9e29a7d3891339", + "reference": "84674dd3a7575ba617f5a76d7e9e29a7d3891339", "shasum": "" }, "require": { "php": "^5.3.2 || ^7.0 || ^8.0", - "psr/log": "^1.0" + "psr/log": "^1 || ^2 || ^3" }, "require-dev": { "phpstan/phpstan": "^0.12.55", @@ -4181,7 +4183,7 @@ "support": { "irc": "irc://irc.freenode.org/composer", "issues": "https://github.com/composer/xdebug-handler/issues", - "source": "https://github.com/composer/xdebug-handler/tree/2.0.1" + "source": "https://github.com/composer/xdebug-handler/tree/2.0.2" }, "funding": [ { @@ -4197,7 +4199,7 @@ "type": "tidelift" } ], - "time": "2021-05-05T19:37:51+00:00" + "time": "2021-07-31T17:03:58+00:00" }, { "name": "dama/doctrine-test-bundle", @@ -4689,16 +4691,16 @@ }, { "name": "doctrine/migrations", - "version": "3.2.0", + "version": "3.2.1", "source": { "type": "git", "url": "https://github.com/doctrine/migrations.git", - "reference": "072c11c1dcfced4505e29a0487b06ea774c403f4" + "reference": "818e31703b4fb353c0c23caa714273fc64efa675" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/migrations/zipball/072c11c1dcfced4505e29a0487b06ea774c403f4", - "reference": "072c11c1dcfced4505e29a0487b06ea774c403f4", + "url": "https://api.github.com/repos/doctrine/migrations/zipball/818e31703b4fb353c0c23caa714273fc64efa675", + "reference": "818e31703b4fb353c0c23caa714273fc64efa675", "shasum": "" }, "require": { @@ -4708,7 +4710,7 @@ "doctrine/event-manager": "^1.0", "friendsofphp/proxy-manager-lts": "^1.0", "php": "^7.2 || ^8.0", - "psr/log": "^1.1.3", + "psr/log": "^1.1.3 || ^2 || ^3", "symfony/console": "^3.4 || ^4.4.16 || ^5.0", "symfony/stopwatch": "^3.4 || ^4.0 || ^5.0" }, @@ -4725,7 +4727,7 @@ "phpstan/phpstan-strict-rules": "^0.12", "phpstan/phpstan-symfony": "^0.12", "phpunit/phpunit": "^8.5 || ^9.4", - "symfony/cache": "^5.3", + "symfony/cache": "^3.4 || ^4.0 || ^5.0", "symfony/process": "^3.4 || ^4.0 || ^5.0", "symfony/yaml": "^3.4 || ^4.0 || ^5.0" }, @@ -4775,7 +4777,7 @@ ], "support": { "issues": "https://github.com/doctrine/migrations/issues", - "source": "https://github.com/doctrine/migrations/tree/3.2.0" + "source": "https://github.com/doctrine/migrations/tree/3.2.1" }, "funding": [ { @@ -4791,7 +4793,7 @@ "type": "tidelift" } ], - "time": "2021-07-05T07:06:31+00:00" + "time": "2021-08-03T11:49:27+00:00" }, { "name": "doctrine/sql-formatter", @@ -4917,16 +4919,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.0.0", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "c15377bdfa8d1ecf186f1deadec39c89984e1167" + "reference": "64c554bcef3c3b4702fcf34c227a316b47139b66" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/c15377bdfa8d1ecf186f1deadec39c89984e1167", - "reference": "c15377bdfa8d1ecf186f1deadec39c89984e1167", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/64c554bcef3c3b4702fcf34c227a316b47139b66", + "reference": "64c554bcef3c3b4702fcf34c227a316b47139b66", "shasum": "" }, "require": { @@ -4993,7 +4995,7 @@ "description": "A tool to automatically fix PHP code style", "support": { "issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues", - "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.0.0" + "source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v3.0.1" }, "funding": [ { @@ -5001,7 +5003,7 @@ "type": "github" } ], - "time": "2021-05-03T21:51:58+00:00" + "time": "2021-08-02T17:57:52+00:00" }, { "name": "friendsofphp/proxy-manager-lts", @@ -6880,16 +6882,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.7", + "version": "9.5.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5" + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d0dc8b6999c937616df4fb046792004b33fd31c5", - "reference": "d0dc8b6999c937616df4fb046792004b33fd31c5", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/191768ccd5c85513b4068bdbe99bb6390c7d54fb", + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb", "shasum": "" }, "require": { @@ -6901,7 +6903,7 @@ "ext-xml": "*", "ext-xmlwriter": "*", "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.1", + "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", "phpspec/prophecy": "^1.12.1", @@ -6967,7 +6969,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.7" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.8" }, "funding": [ { @@ -6979,7 +6981,7 @@ "type": "github" } ], - "time": "2021-07-19T06:14:47+00:00" + "time": "2021-07-31T15:17:34+00:00" }, { "name": "psr/simple-cache", @@ -8674,7 +8676,6 @@ "type": "github" } ], - "abandoned": true, "time": "2020-09-28T06:45:17+00:00" }, { diff --git a/src/DependencyInjection/PrependConfiguration/DoctrineMigrationsPrependConfiguration.php b/src/DependencyInjection/PrependConfiguration/DoctrineMigrationsPrependConfiguration.php new file mode 100644 index 0000000..e95a9d9 --- /dev/null +++ b/src/DependencyInjection/PrependConfiguration/DoctrineMigrationsPrependConfiguration.php @@ -0,0 +1,17 @@ + '@RichIdCookiesRegulationBundle/Migrations', + ]; + } +} diff --git a/src/DependencyInjection/PrependTrait/DoctrineMigrationsPrependTrait.php b/src/DependencyInjection/PrependTrait/DoctrineMigrationsPrependTrait.php deleted file mode 100644 index 65f4897..0000000 --- a/src/DependencyInjection/PrependTrait/DoctrineMigrationsPrependTrait.php +++ /dev/null @@ -1,26 +0,0 @@ -hasExtension('doctrine_migrations')) { - return; - } - - $doctrineConfig = $container->getExtensionConfig('doctrine_migrations'); - $doctrineMigrationPaths = \array_pop($doctrineConfig)['migrations_paths'] ?? []; - - $container->prependExtensionConfig('doctrine_migrations', [ - 'migrations_paths' => \array_merge($doctrineMigrationPaths, [ - 'RichId\CookiesRegulationBundle\Migrations' => '@RichIdCookiesRegulationBundle/Migrations', - ]), - ]); - } -} diff --git a/src/DependencyInjection/RichIdCookiesRegulationExtension.php b/src/DependencyInjection/RichIdCookiesRegulationExtension.php index d2ed23f..dd841b2 100644 --- a/src/DependencyInjection/RichIdCookiesRegulationExtension.php +++ b/src/DependencyInjection/RichIdCookiesRegulationExtension.php @@ -5,10 +5,8 @@ namespace RichId\CookiesRegulationBundle\DependencyInjection; use RichCongress\BundleToolbox\Configuration\AbstractExtension; -use RichId\CookiesRegulationBundle\DependencyInjection\PrependTrait\DoctrineMigrationsPrependTrait; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; /** @@ -16,10 +14,8 @@ * * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} */ -class RichIdCookiesRegulationExtension extends AbstractExtension implements PrependExtensionInterface +class RichIdCookiesRegulationExtension extends AbstractExtension { - use DoctrineMigrationsPrependTrait; - /** @param array $configs */ public function load(array $configs, ContainerBuilder $container): void { @@ -32,9 +28,4 @@ public function load(array $configs, ContainerBuilder $container): void $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources')); $loader->load('services.xml'); } - - public function prepend(ContainerBuilder $container): void - { - $this->prependDoctrineMigrations($container); - } } diff --git a/src/Factory/CookieDecisionMetadataFactory.php b/src/Factory/CookieDecisionMetadataFactory.php index 37f6f52..245e905 100644 --- a/src/Factory/CookieDecisionMetadataFactory.php +++ b/src/Factory/CookieDecisionMetadataFactory.php @@ -30,7 +30,7 @@ public function __invoke(): ?CookieDecisionMetadata } $uuid = $metadata['uuid'] ?? null; - $date = \DateTime::createFromFormat('d/m/Y, H:i:s', $metadata['date'] ?? ''); + $date = new \DateTime($metadata['date'] ?? ''); if (!\is_string($uuid) || empty($uuid) || !$date instanceof \DateTime) { return null; diff --git a/src/Resources/views/partials/_services.html.twig b/src/Resources/views/partials/_services.html.twig index c7e8af9..a5295c1 100644 --- a/src/Resources/views/partials/_services.html.twig +++ b/src/Resources/views/partials/_services.html.twig @@ -5,11 +5,13 @@ mandatory: {% if config.mandatory %}true{% else %}false{% endif %}, {# Cookies identifiers #} - cookiesIdentifiers: [ - {% for identifier in config.cookies_identifiers %} - '{{ identifier|e('js') }}', - {% endfor %} - ], + {% if config.cookies_identifiers is not empty %} + cookiesIdentifiers: [ + {% for identifier in config.cookies_identifiers %} + '{{ identifier|e('js') }}', + {% endfor %} + ], + {% endif %} {# Preconfigured service #} {% if (config.predefined|default(null)) is not null %} diff --git a/src/RichIdCookiesRegulationBundle.php b/src/RichIdCookiesRegulationBundle.php index 93a624e..73daf9f 100644 --- a/src/RichIdCookiesRegulationBundle.php +++ b/src/RichIdCookiesRegulationBundle.php @@ -4,32 +4,11 @@ namespace RichId\CookiesRegulationBundle; -use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass; use RichCongress\BundleToolbox\Configuration\AbstractBundle; -use Symfony\Component\DependencyInjection\ContainerBuilder; class RichIdCookiesRegulationBundle extends AbstractBundle { - public const COMPILER_PASSES = []; - - public function build(ContainerBuilder $container): void - { - parent::build($container); - - $this->addDoctrineOrmMappingsPass($container); - } - - private function addDoctrineOrmMappingsPass(ContainerBuilder $container): void - { - if (!\class_exists(DoctrineOrmMappingsPass::class)) { - return; - } - - $container->addCompilerPass( - DoctrineOrmMappingsPass::createAnnotationMappingDriver( - ['RichId\CookiesRegulationBundle\Entity'], - [__DIR__ . '/Entity'] - ) - ); - } + protected static $doctrineAnnotationMapping = [ + 'RichId\CookiesRegulationBundle\Entity' => __DIR__ . '/Entity', + ]; } From 4ef520be4422d356940223c8439625dbee968088 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Wed, 4 Aug 2021 15:22:33 +0200 Subject: [PATCH 7/9] Fix code style --- src/DependencyInjection/Configuration.php | 2 +- src/RichIdCookiesRegulationBundle.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 2897b79..47b2a42 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -51,7 +51,7 @@ private static function addUrlOrRouteConfig(ArrayNodeDefinition $node): void { $node->beforeNormalization() ->ifString() - ->then(function ($v) { + ->then(static function ($v) { return ['absolute' => $v]; }); diff --git a/src/RichIdCookiesRegulationBundle.php b/src/RichIdCookiesRegulationBundle.php index 73daf9f..3a4a78c 100644 --- a/src/RichIdCookiesRegulationBundle.php +++ b/src/RichIdCookiesRegulationBundle.php @@ -8,6 +8,7 @@ class RichIdCookiesRegulationBundle extends AbstractBundle { + /** @var array */ protected static $doctrineAnnotationMapping = [ 'RichId\CookiesRegulationBundle\Entity' => __DIR__ . '/Entity', ]; From c686254a07f19ff3045f48f82654f19b82bb7f76 Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Wed, 4 Aug 2021 15:37:35 +0200 Subject: [PATCH 8/9] Fix tests --- .github/workflows/static_analysis.yml | 29 +++++++++++++++++-- .github/workflows/tests.yml | 2 +- src/Factory/CookieDecisionMetadataFactory.php | 7 ++++- tests/Controller/DecisionLogRouteTest.php | 10 +++---- .../ConfigurationTest.php | 23 +++++++++------ .../CookiesRegulationTwigExtensionTest.php | 23 +++++++++------ 6 files changed, 66 insertions(+), 28 deletions(-) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index c28d6c9..dff017c 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -1,8 +1,8 @@ -name: Tests +name: Static Analysis on: [pull_request] jobs: - build-and-test: + phpinsights: runs-on: ubuntu-18.04 steps: - name: Checkout 🛎️ @@ -27,7 +27,30 @@ jobs: - name: PHPInsights 🔧 run: | - docker-compose exec -T application ./vendor/nunomaduro/phpinsights/bin/phpinsights + docker-compose exec -T application ./vendor/nunomaduro/phpinsights/bin/phpinsights --no-interaction --min-quality=100 --min-architecture=100 + + phpstan: + runs-on: ubuntu-18.04 + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v2 + with: + persist-credentials: false + + - name: Start docker 🔧 + run: | + docker-compose -f docker-compose.yml -f .github/docker-compose.yml up -d + + - name: Cache multiple paths + uses: actions/cache@v2 + with: + path: | + **/vendor + key: ${{ runner.os }}-${{ hashFiles('*.lock') }} + + - name: Install the dependencies 🔧 + run: | + docker-compose exec -T application composer install --prefer-dist --no-interaction --no-progress - name: PHPStan 🔧 run: | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 380164b..119152d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -2,7 +2,7 @@ name: Tests on: [push] jobs: - build-and-test: + phpunit: runs-on: ubuntu-18.04 steps: - name: Checkout 🛎️ diff --git a/src/Factory/CookieDecisionMetadataFactory.php b/src/Factory/CookieDecisionMetadataFactory.php index 245e905..8c1a0cd 100644 --- a/src/Factory/CookieDecisionMetadataFactory.php +++ b/src/Factory/CookieDecisionMetadataFactory.php @@ -30,7 +30,12 @@ public function __invoke(): ?CookieDecisionMetadata } $uuid = $metadata['uuid'] ?? null; - $date = new \DateTime($metadata['date'] ?? ''); + + try { + $date = new \DateTime($metadata['date'] ?? ''); + } catch (\Throwable $e) { + return null; + } if (!\is_string($uuid) || empty($uuid) || !$date instanceof \DateTime) { return null; diff --git a/tests/Controller/DecisionLogRouteTest.php b/tests/Controller/DecisionLogRouteTest.php index 278b6a1..56a7d15 100644 --- a/tests/Controller/DecisionLogRouteTest.php +++ b/tests/Controller/DecisionLogRouteTest.php @@ -28,7 +28,7 @@ public function testDecisionLog(): void ], 'metadata' => [ 'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd', - 'date' => '03/11/2020, 17:55:47', + 'date' => '2020-11-03 17:55:47', ], ]); @@ -58,7 +58,7 @@ public function testDecisionLogPreferencesNotArray(): void 'preferences' => 'BadData', 'metadata' => [ 'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd', - 'date' => '03/11/2020, 17:55:47', + 'date' => '2020-11-03 17:55:47', ], ]); @@ -73,7 +73,7 @@ public function testDecisionLogPreferencesWithBadDataInside(): void ], 'metadata' => [ 'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd', - 'date' => '03/11/2020, 17:55:47', + 'date' => '2020-11-03 17:55:47', ], ]); @@ -102,7 +102,7 @@ public function testDecisionLogMetadataBadUuid(): void ], 'metadata' => [ 'uuid' => false, - 'date' => '03/11/2020, 17:55:47', + 'date' => '2020-11-03 17:55:47', ], ]); @@ -118,7 +118,7 @@ public function testDecisionLogMetadataBadDate(): void ], 'metadata' => [ 'uuid' => '13336e1c-1c5c-4d24-8229-6eabb98f90bd', - 'date' => false, + 'date' => '1685463516584684', ], ]); diff --git a/tests/DependencyConfiguration/ConfigurationTest.php b/tests/DependencyConfiguration/ConfigurationTest.php index 2afbae4..c364304 100644 --- a/tests/DependencyConfiguration/ConfigurationTest.php +++ b/tests/DependencyConfiguration/ConfigurationTest.php @@ -36,24 +36,28 @@ public function testInstantiationContainer(): void 'website' => 'Test Website', 'locale' => 'fr', 'privacy_policy' => [ - 'url' => 'http://privacy_policy', + 'url' => [ + 'absolute' => 'http://privacy_policy', + ], 'label' => 'Privacy Policy', 'open_in_new_window' => true, ], 'modal' => [ 'header' => 'Modal header', 'related_companies_count' => 2, - 'related_companies_privacy_policy_url' => 'http://related_companies_privacy_policy', + 'related_companies_privacy_policy_url' => [ + 'absolute' => 'http://related_companies_privacy_policy', + ], ], 'services' => [ 'google_tag_manager' => [ - 'enable' => true, - 'name' => 'Google Tag Manager', - 'description' => 'Tag management system', - 'mandatory' => true, - 'conservation' => '6 months', - 'initialization_callback' => null, - 'predefined' => [ + 'enable' => true, + 'name' => 'Google Tag Manager', + 'description' => 'Tag management system', + 'mandatory' => true, + 'conservation' => '6 months', + 'cookies_identifiers' => [], + 'predefined' => [ 'name' => 'googleTagManager', 'options' => ['id' => 'GTM-TEST'], ], @@ -64,6 +68,7 @@ public function testInstantiationContainer(): void 'description' => 'Description of the another service', 'mandatory' => false, 'conservation' => '1 year', + 'cookies_identifiers' => [], 'initialization_callback' => 'init_callback()', ], ], diff --git a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php index ff41929..c1c9740 100644 --- a/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php +++ b/tests/TwigExtension/CookiesRegulationTwigExtensionTest.php @@ -35,24 +35,28 @@ public function testGetConfig(): void 'website' => 'Test Website', 'locale' => 'fr', 'privacy_policy' => [ - 'url' => 'http://privacy_policy', + 'url' => [ + 'absolute' => 'http://privacy_policy', + ], 'label' => 'Privacy Policy', 'open_in_new_window' => true, ], 'modal' => [ 'header' => 'Modal header', 'related_companies_count' => 2, - 'related_companies_privacy_policy_url' => 'http://related_companies_privacy_policy', + 'related_companies_privacy_policy_url' => [ + 'absolute' => 'http://related_companies_privacy_policy', + ], ], 'services' => [ 'google_tag_manager' => [ - 'enable' => true, - 'name' => 'Google Tag Manager', - 'description' => 'Tag management system', - 'mandatory' => true, - 'conservation' => '6 months', - 'initialization_callback' => null, - 'predefined' => [ + 'enable' => true, + 'name' => 'Google Tag Manager', + 'description' => 'Tag management system', + 'mandatory' => true, + 'conservation' => '6 months', + 'cookies_identifiers' => [], + 'predefined' => [ 'name' => 'googleTagManager', 'options' => ['id' => 'GTM-TEST'], ], @@ -63,6 +67,7 @@ public function testGetConfig(): void 'description' => 'Description of the another service', 'mandatory' => false, 'conservation' => '1 year', + 'cookies_identifiers' => [], 'initialization_callback' => 'init_callback()', ], ], From d78b9d9228e192ade98fc1b8d9f57f5eaa252b0d Mon Sep 17 00:00:00 2001 From: Nicolas Guilloux Date: Wed, 4 Aug 2021 15:41:16 +0200 Subject: [PATCH 9/9] Update static analysis --- composer.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.lock b/composer.lock index 880bfb2..1117cb7 100644 --- a/composer.lock +++ b/composer.lock @@ -7185,16 +7185,16 @@ }, { "name": "richcongress/static-analysis", - "version": "v0.1.0", + "version": "v0.1.1", "source": { "type": "git", "url": "https://github.com/rich-id/static-analysis.git", - "reference": "25efadca7d93c5c64c0ed1e31735bf45b8800268" + "reference": "ad043003f5418ab0661a7769e20f25c8aa471714" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/rich-id/static-analysis/zipball/25efadca7d93c5c64c0ed1e31735bf45b8800268", - "reference": "25efadca7d93c5c64c0ed1e31735bf45b8800268", + "url": "https://api.github.com/repos/rich-id/static-analysis/zipball/ad043003f5418ab0661a7769e20f25c8aa471714", + "reference": "ad043003f5418ab0661a7769e20f25c8aa471714", "shasum": "" }, "require": { @@ -7221,9 +7221,9 @@ "description": "A library to setup quickly the static analysis tools for RichCongress", "support": { "issues": "https://github.com/rich-id/static-analysis/issues", - "source": "https://github.com/rich-id/static-analysis/tree/v0.1.0" + "source": "https://github.com/rich-id/static-analysis/tree/v0.1.1" }, - "time": "2021-06-23T09:33:28+00:00" + "time": "2021-08-04T12:58:00+00:00" }, { "name": "richcongress/test-framework",