From 9703a6531efb1047c76dae8d45b5dabdc686a300 Mon Sep 17 00:00:00 2001 From: igor Date: Mon, 24 Apr 2017 08:47:28 +0300 Subject: [PATCH 001/192] Remove slug prefix providers. --- Resources/config/sluggable.yml | 1 - composer.json | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Resources/config/sluggable.yml b/Resources/config/sluggable.yml index 7f4996a..a4f1b52 100644 --- a/Resources/config/sluggable.yml +++ b/Resources/config/sluggable.yml @@ -10,7 +10,6 @@ services: darvin_utils.sluggable.manager.entity: class: "%darvin_utils.sluggable.manager.entity.class%" arguments: - - "@service_container" - "@darvin_utils.entity_manager.provider" - "@event_dispatcher" - "@darvin_utils.mapping.metadata_factory" diff --git a/composer.json b/composer.json index eed9967..690db52 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "doctrine/orm": "^2.4.8", "doctrine/doctrine-bundle": "~1.4", "twig/extensions": "^1.3", - "darvinstudio/darvin-utils": "*" + "darvinstudio/darvin-utils": "^6" }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } From 22c34f375b70e5e72d609579344489c9cbcf3ab5 Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 4 May 2017 11:07:28 +0300 Subject: [PATCH 002/192] Add upgrade docs. --- UPGRADE_6.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 UPGRADE_6.md diff --git a/UPGRADE_6.md b/UPGRADE_6.md new file mode 100644 index 0000000..7cc0a92 --- /dev/null +++ b/UPGRADE_6.md @@ -0,0 +1 @@ +1. Удалите свойство "prefixProvider" из аннотации "Slug". From 56752a659cf25d526fec0258865e565b3191e6e3 Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 5 May 2017 11:13:04 +0300 Subject: [PATCH 003/192] Implement entity utility. --- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/doctrine.yml | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 Resources/config/doctrine.yml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index bb347dc..86bf652 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -43,6 +43,7 @@ public function load(array $configs, ContainerBuilder $container) 'cloner', 'custom_object', 'default_value', + 'doctrine', 'flash', 'form', 'homepage', diff --git a/Resources/config/doctrine.yml b/Resources/config/doctrine.yml new file mode 100644 index 0000000..2d47363 --- /dev/null +++ b/Resources/config/doctrine.yml @@ -0,0 +1,8 @@ +parameters: + darvin_utils.doctrine.orm.entity_util.class: Darvin\Utils\Doctrine\ORM\EntityUtil + +services: + darvin_utils.doctrine.orm.entity_util: + class: "%darvin_utils.doctrine.orm.entity_util.class%" + arguments: + - "@darvin_utils.entity_manager.provider" From af25b5cd580fa0a03f0a91c8bddf366bb903b949 Mon Sep 17 00:00:00 2001 From: Lev Date: Mon, 8 May 2017 22:15:23 +0300 Subject: [PATCH 004/192] Allow use classes in target_entity_resolve option --- .../ValidateResolveTargetEntitiesConfigPass.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php index 34a61b0..6d79db9 100644 --- a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php +++ b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php @@ -29,16 +29,18 @@ public function process(ContainerBuilder $container) continue; } foreach ($part['orm']['resolve_target_entities'] as $target => $replacement) { - if (!interface_exists($target)) { - throw new ConfigurationException(sprintf('Target interface "%s" does not exist.', $target)); + if (!interface_exists($target) && !class_exists($target)) { + throw new ConfigurationException(sprintf('Target interface/class "%s" does not exist.', $target)); } if (!class_exists($replacement)) { throw new ConfigurationException(sprintf('Replacement entity class "%s" does not exist.', $replacement)); } - if (!in_array($target, class_implements($replacement))) { - throw new ConfigurationException( - sprintf('Replacement entity class "%s" must implement target interface "%s".', $replacement, $target) - ); + if (!in_array($target, array_merge(class_implements($replacement), class_parents($replacement)))) { + throw new ConfigurationException(sprintf( + 'Replacement entity class "%s" must implement/extend target interface/class "%s".', + $replacement, + $target + )); } } } From 024da39c2c0384624bd615049f9aa5ce83a23887 Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 11 May 2017 14:44:54 +0300 Subject: [PATCH 005/192] Remove redundant entity utility service. --- DependencyInjection/DarvinUtilsExtension.php | 1 - Resources/config/doctrine.yml | 8 -------- 2 files changed, 9 deletions(-) delete mode 100644 Resources/config/doctrine.yml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 86bf652..bb347dc 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -43,7 +43,6 @@ public function load(array $configs, ContainerBuilder $container) 'cloner', 'custom_object', 'default_value', - 'doctrine', 'flash', 'form', 'homepage', diff --git a/Resources/config/doctrine.yml b/Resources/config/doctrine.yml deleted file mode 100644 index 2d47363..0000000 --- a/Resources/config/doctrine.yml +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - darvin_utils.doctrine.orm.entity_util.class: Darvin\Utils\Doctrine\ORM\EntityUtil - -services: - darvin_utils.doctrine.orm.entity_util: - class: "%darvin_utils.doctrine.orm.entity_util.class%" - arguments: - - "@darvin_utils.entity_manager.provider" From 943e16323c4826252b6892a51766418d4aa58181 Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 4 Aug 2017 14:06:23 +0300 Subject: [PATCH 006/192] Implement data fixture load command. --- DependencyInjection/DarvinUtilsExtension.php | 3 +++ Resources/config/data_fixture.yml | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 Resources/config/data_fixture.yml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index bb347dc..d6b1ee2 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -63,6 +63,9 @@ public function load(array $configs, ContainerBuilder $container) if ($config['mailer']['enabled']) { $loader->load('mailer.yml'); } + if (interface_exists('Doctrine\Common\DataFixtures\FixtureInterface')) { + $loader->load('data_fixture.yml'); + } } /** diff --git a/Resources/config/data_fixture.yml b/Resources/config/data_fixture.yml new file mode 100644 index 0000000..122bba8 --- /dev/null +++ b/Resources/config/data_fixture.yml @@ -0,0 +1,12 @@ +parameters: + darvin_utils.data_fixture.load_command.class: Darvin\Utils\Command\LoadDataFixtureCommand + +services: + darvin_utils.data_fixture.load_command: + class: "%darvin_utils.data_fixture.load_command.class%" + arguments: + - darvin:utils:fixture:load + - "@service_container" + - "@doctrine.orm.entity_manager" + tags: + - { name: console.command } From a121533c25cb156299d147c498c8a515c7d62a05 Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 10 Aug 2017 16:31:13 +0300 Subject: [PATCH 007/192] Implement translate translations command. --- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/data_fixture.yml | 3 ++- Resources/config/translation.yml | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Resources/config/translation.yml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index d6b1ee2..1c7185a 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -55,6 +55,7 @@ public function load(array $configs, ContainerBuilder $container) 'service', 'sluggable', 'stringifier', + 'translation', 'transliteratable', 'user', ] as $resource) { diff --git a/Resources/config/data_fixture.yml b/Resources/config/data_fixture.yml index 122bba8..c480a8d 100644 --- a/Resources/config/data_fixture.yml +++ b/Resources/config/data_fixture.yml @@ -1,11 +1,12 @@ parameters: darvin_utils.data_fixture.load_command.class: Darvin\Utils\Command\LoadDataFixtureCommand + darvin_utils.data_fixture.load_command.name: darvin:utils:fixture:load services: darvin_utils.data_fixture.load_command: class: "%darvin_utils.data_fixture.load_command.class%" arguments: - - darvin:utils:fixture:load + - "%darvin_utils.data_fixture.load_command.name%" - "@service_container" - "@doctrine.orm.entity_manager" tags: diff --git a/Resources/config/translation.yml b/Resources/config/translation.yml new file mode 100644 index 0000000..badac2a --- /dev/null +++ b/Resources/config/translation.yml @@ -0,0 +1,12 @@ +parameters: + darvin_utils.translation.translate_command.class: Darvin\Utils\Command\TranslateTranslationsCommand + darvin_utils.translation.translate_command.name: darvin:utils:translations:translate + +services: + darvin_utils.translation.translate_command: + class: "%darvin_utils.translation.translate_command.class%" + arguments: + - "%darvin_utils.translation.translate_command.name%" + - "@=service('service_container').hasParameter('yandex_translate_api_key') ? parameter('yandex_translate_api_key') : null" + tags: + - { name: console.command } From 8a4e06e38501a8a2807d03f87853981776597e37 Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 1 Sep 2017 09:50:37 +0300 Subject: [PATCH 008/192] Make Swift Mailer optional (if missing mail will not be sent). --- Resources/config/mailer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index 123a17b..9264d5c 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -7,7 +7,7 @@ services: arguments: - "@logger" - "@request_stack" - - "@mailer" + - "@?mailer" - "@translator" - "%darvin_utils.mailer.charset%" - "%darvin_utils.mailer.from%" From ceb72d7af82319ab6b8ec2df0f96edcf829664bd Mon Sep 17 00:00:00 2001 From: igor Date: Tue, 5 Dec 2017 15:37:42 +0300 Subject: [PATCH 009/192] Implement cached route manager. --- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/routing.yml | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 Resources/config/routing.yml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 1c7185a..cd0de85 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -51,6 +51,7 @@ public function load(array $configs, ContainerBuilder $container) 'mapping', 'new_object', 'object_namer', + 'routing', 'security', 'service', 'sluggable', diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml new file mode 100644 index 0000000..caecca1 --- /dev/null +++ b/Resources/config/routing.yml @@ -0,0 +1,24 @@ +parameters: + darvin_utils.routing.route_cache_warmer.class: Darvin\Utils\Routing\RouteCacheWarmer + + darvin_utils.routing.route_manager.cached.class: Darvin\Utils\Routing\CachedRouteManager + +services: + darvin_utils.routing.route_cache_warmer: + class: "%darvin_utils.routing.route_cache_warmer.class%" + public: false + arguments: + - "@darvin_utils.routing.route_manager.cached" + tags: + - { name: kernel.cache_warmer } + + darvin_utils.routing.route_manager: + alias: darvin_utils.routing.route_manager.cached + + darvin_utils.routing.route_manager.cached: + class: "%darvin_utils.routing.route_manager.cached.class%" + public: false + arguments: + - "@router" + - "%kernel.cache_dir%/darvin/utils/routes.php" + - "%kernel.debug%" From 46f3f213e6cda82e8e3837b58de00d40ad6f65e3 Mon Sep 17 00:00:00 2001 From: igor Date: Mon, 18 Dec 2017 08:59:05 +0300 Subject: [PATCH 010/192] Allow to not prepend host to email subject. --- CHANGELOG.md | 1 + DependencyInjection/Configuration.php | 1 + Resources/config/mailer.yml | 1 + 3 files changed, 3 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fa8c1ee --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1 @@ +6.3.1: Add "mailer.prepend_host" bundle configuration parameter. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f4ca0e4..e8f0a01 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -38,6 +38,7 @@ public function getConfigTreeBuilder() ->children() ->scalarNode('charset')->defaultValue('utf-8')->end() ->scalarNode('from')->isRequired()->end() + ->booleanNode('prepend_host')->defaultTrue()->end() ->end() ->end() ->end(); diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index 9264d5c..6ebb877 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -11,3 +11,4 @@ services: - "@translator" - "%darvin_utils.mailer.charset%" - "%darvin_utils.mailer.from%" + - "%darvin_utils.mailer.prepend_host%" From 5acefb6af38f23407b95c007866caee301869bd9 Mon Sep 17 00:00:00 2001 From: igor Date: Thu, 11 Jan 2018 12:32:46 +0300 Subject: [PATCH 011/192] Pass "@router.default" instead of "@router" to the service "darvin_utils.routing.route_manager.cached" for compatibility with "jms/i18n-routing-bundle". --- CHANGELOG.md | 3 +++ Resources/config/routing.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa8c1ee..185a817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,4 @@ 6.3.1: Add "mailer.prepend_host" bundle configuration parameter. + +6.3.2: Pass "@router.default" instead of "@router" to the service "darvin_utils.routing.route_manager.cached" for + compatibility with "jms/i18n-routing-bundle". diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index caecca1..c2a8707 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -19,6 +19,6 @@ services: class: "%darvin_utils.routing.route_manager.cached.class%" public: false arguments: - - "@router" + - "@router.default" - "%kernel.cache_dir%/darvin/utils/routes.php" - "%kernel.debug%" From 6a55cdb0764a9cdd244bdd5d74fd145d91e328dc Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 12 Jan 2018 10:21:43 +0300 Subject: [PATCH 012/192] Always use locale "en" in the number and integer form view transformers. --- CHANGELOG.md | 2 ++ Resources/config/form.yml | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 185a817..f8dbd7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,3 +2,5 @@ 6.3.2: Pass "@router.default" instead of "@router" to the service "darvin_utils.routing.route_manager.cached" for compatibility with "jms/i18n-routing-bundle". + +6.4.0: Always use locale "en" in the number and integer form view transformers. diff --git a/Resources/config/form.yml b/Resources/config/form.yml index 70f97bc..90b5367 100644 --- a/Resources/config/form.yml +++ b/Resources/config/form.yml @@ -1,8 +1,22 @@ parameters: darvin_utils.form.description_extension.class: Darvin\Utils\Form\Extension\DescriptionExtension + darvin_utils.form.integer_type_extension.class: Darvin\Utils\Form\Extension\IntegerTypeExtension + + darvin_utils.form.number_type_extension.class: Darvin\Utils\Form\Extension\NumberTypeExtension + services: darvin_utils.form.description_extension: class: "%darvin_utils.form.description_extension.class%" tags: - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType } + + darvin_utils.form.integer_type_extension: + class: "%darvin_utils.form.integer_type_extension.class%" + tags: + - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\IntegerType } + + darvin_utils.form.number_type_extension: + class: "%darvin_utils.form.number_type_extension.class%" + tags: + - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\NumberType } From fbb2993ee8caead1d3b53a9331a9c4d09ae9a517 Mon Sep 17 00:00:00 2001 From: igor Date: Tue, 6 Feb 2018 15:21:31 +0300 Subject: [PATCH 013/192] Fix sluggable event subscriber initialization. --- Resources/config/sluggable.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/sluggable.yml b/Resources/config/sluggable.yml index a4f1b52..35150f4 100644 --- a/Resources/config/sluggable.yml +++ b/Resources/config/sluggable.yml @@ -19,6 +19,7 @@ services: class: "%darvin_utils.sluggable.subscriber.class%" public: false arguments: + - "@darvin_utils.entity_manager.provider" - "@darvin_utils.sluggable.manager" tags: - { name: doctrine.event_subscriber, priority: 200 } From d03e055f765ac67fad63f008800e44ec1215df3e Mon Sep 17 00:00:00 2001 From: igor Date: Tue, 8 May 2018 10:34:32 +0300 Subject: [PATCH 014/192] Add generic tree sorter. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/tree.yml | 11 +++++++++++ 3 files changed, 14 insertions(+) create mode 100644 Resources/config/tree.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index f8dbd7f..be1e58e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,5 @@ compatibility with "jms/i18n-routing-bundle". 6.4.0: Always use locale "en" in the number and integer form view transformers. + +6.4.2: Add generic tree sorter. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index cd0de85..a5a524d 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -58,6 +58,7 @@ public function load(array $configs, ContainerBuilder $container) 'stringifier', 'translation', 'transliteratable', + 'tree', 'user', ] as $resource) { $loader->load($resource.'.yml'); diff --git a/Resources/config/tree.yml b/Resources/config/tree.yml new file mode 100644 index 0000000..bb6c694 --- /dev/null +++ b/Resources/config/tree.yml @@ -0,0 +1,11 @@ +parameters: + darvin_utils.tree.sorter.class: Darvin\Utils\Tree\TreeSorter + +services: + darvin_utils.tree.sorter: + class: "%darvin_utils.tree.sorter.class%" + public: true + arguments: + - "@doctrine.orm.entity_manager" + - "@property_accessor" + - "@stof_doctrine_extensions.listener.tree" From ec0029106c67c1643a3057bb069f69ad125da6e3 Mon Sep 17 00:00:00 2001 From: igor Date: Fri, 18 May 2018 09:29:04 +0300 Subject: [PATCH 015/192] Init commands only in "dev" environment. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 14 ++++++++++---- Resources/config/{ => dev}/data_fixture.yml | 0 Resources/config/{ => dev}/translation.yml | 0 4 files changed, 12 insertions(+), 4 deletions(-) rename Resources/config/{ => dev}/data_fixture.yml (100%) rename Resources/config/{ => dev}/translation.yml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index be1e58e..8dbd5f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,5 @@ 6.4.0: Always use locale "en" in the number and integer form view transformers. 6.4.2: Add generic tree sorter. + +6.4.3: Init commands only in "dev" environment. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index a5a524d..dee0320 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -56,19 +56,25 @@ public function load(array $configs, ContainerBuilder $container) 'service', 'sluggable', 'stringifier', - 'translation', 'transliteratable', 'tree', 'user', ] as $resource) { $loader->load($resource.'.yml'); } + if ('dev' === $container->getParameter('kernel.environment')) { + foreach ([ + 'translation', + ] as $resource) { + $loader->load(sprintf('dev/%s.yml', $resource)); + } + if (interface_exists('Doctrine\Common\DataFixtures\FixtureInterface')) { + $loader->load('dev/data_fixture.yml'); + } + } if ($config['mailer']['enabled']) { $loader->load('mailer.yml'); } - if (interface_exists('Doctrine\Common\DataFixtures\FixtureInterface')) { - $loader->load('data_fixture.yml'); - } } /** diff --git a/Resources/config/data_fixture.yml b/Resources/config/dev/data_fixture.yml similarity index 100% rename from Resources/config/data_fixture.yml rename to Resources/config/dev/data_fixture.yml diff --git a/Resources/config/translation.yml b/Resources/config/dev/translation.yml similarity index 100% rename from Resources/config/translation.yml rename to Resources/config/dev/translation.yml From a8451c1159ec2f0c2e2a9afa858073a3f870c6b3 Mon Sep 17 00:00:00 2001 From: igor Date: Tue, 22 May 2018 15:09:20 +0300 Subject: [PATCH 016/192] Mailer: allow to configure from name. --- DependencyInjection/Configuration.php | 1 + Resources/config/mailer.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e8f0a01..07bc577 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -38,6 +38,7 @@ public function getConfigTreeBuilder() ->children() ->scalarNode('charset')->defaultValue('utf-8')->end() ->scalarNode('from')->isRequired()->end() + ->scalarNode('from_name')->defaultNull()->end() ->booleanNode('prepend_host')->defaultTrue()->end() ->end() ->end() diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index 6ebb877..a0755ad 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -11,4 +11,5 @@ services: - "@translator" - "%darvin_utils.mailer.charset%" - "%darvin_utils.mailer.from%" + - "%darvin_utils.mailer.from_name%" - "%darvin_utils.mailer.prepend_host%" From 60cc4b644cb85dbda34b70471c35f6b497145b7c Mon Sep 17 00:00:00 2001 From: igor Date: Tue, 22 May 2018 15:10:40 +0300 Subject: [PATCH 017/192] Update changelog. --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dbd5f7..9a362fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,3 +8,11 @@ 6.4.2: Add generic tree sorter. 6.4.3: Init commands only in "dev" environment. + +6.4.4: Mailer: allow to configure from name: + +```yaml +darvin_utils: + mailer: + from_name: Почта России +``` From 4443560c7a2bd1ddab9b3b9eaacda6209d38050d Mon Sep 17 00:00:00 2001 From: Alexey Gorshkov Date: Fri, 21 Sep 2018 11:21:15 +0300 Subject: [PATCH 018/192] Add title case translations command. --- CHANGELOG.md | 8 ++++++++ Resources/config/dev/translation.yml | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a362fe..1c006a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,3 +16,11 @@ darvin_utils: mailer: from_name: Почта России ``` + +6.4.5: Add title case translations command. + +To convert translations file to title case use + +```shell +$ /usr/bin/env php bin/console darvin:utils:translations:title-case +``` diff --git a/Resources/config/dev/translation.yml b/Resources/config/dev/translation.yml index badac2a..b89f3b9 100644 --- a/Resources/config/dev/translation.yml +++ b/Resources/config/dev/translation.yml @@ -1,8 +1,22 @@ parameters: + darvin_utils.translation.title_case_command.class: Darvin\Utils\Command\TitleCaseTranslationsCommand + darvin_utils.translation.title_case_command.name: darvin:utils:translations:title-case + darvin_utils.translation.title_case_command.base_url: http://brettterpstra.com + darvin_utils.translation.title_case_command.http_timeout: 30 + darvin_utils.translation.translate_command.class: Darvin\Utils\Command\TranslateTranslationsCommand darvin_utils.translation.translate_command.name: darvin:utils:translations:translate services: + darvin_utils.translation.title_case_command: + class: "%darvin_utils.translation.title_case_command.class%" + arguments: + - "%darvin_utils.translation.title_case_command.name%" + - "%darvin_utils.translation.title_case_command.base_url%" + - "%darvin_utils.translation.title_case_command.http_timeout%" + tags: + - { name: console.command } + darvin_utils.translation.translate_command: class: "%darvin_utils.translation.translate_command.class%" arguments: From 49f50c7e5e64aa5563c2a78030b7364f7b658ceb Mon Sep 17 00:00:00 2001 From: Alexey Gorshkov Date: Fri, 21 Sep 2018 11:23:25 +0300 Subject: [PATCH 019/192] Convert .en translations to title case. --- CHANGELOG.md | 6 +++++- Resources/translations/messages.en.yml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c006a5..b12e47e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,11 @@ darvin_utils: from_name: Почта России ``` -6.4.5: Add title case translations command. +6.4.5: + +- add title case translations command; + +- convert .en translations to title case. To convert translations file to title case use diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml index f33ab1f..1b1dc1e 100644 --- a/Resources/translations/messages.en.yml +++ b/Resources/translations/messages.en.yml @@ -4,4 +4,4 @@ boolean: flash: error: - form: Form errors detected. Fix them and resubmit form + form: Form Errors Detected. Fix Them and Resubmit Form From 05d82c43fb49b3477e4ecbd7076c37ccd9e1279e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 21 Sep 2018 14:27:54 +0300 Subject: [PATCH 020/192] Remove "symfony/symfony" from dependencies. --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 690db52..7e218df 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,6 @@ } ], "require": { - "symfony/symfony": ">=2.7", "doctrine/orm": "^2.4.8", "doctrine/doctrine-bundle": "~1.4", "twig/extensions": "^1.3", From de137ebb53ba83a2009e9823ac785b2fd7ec691f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 21 Sep 2018 14:29:17 +0300 Subject: [PATCH 021/192] Remove "symfony/symfony" from dependencies. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b12e47e..8d5e6be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,3 +28,5 @@ To convert translations file to title case use ```shell $ /usr/bin/env php bin/console darvin:utils:translations:title-case ``` + +6.4.6: Remove "symfony/symfony" from dependencies. From d96b1f901b7b153ea8b83adedd1ea00f5129677b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 27 Sep 2018 08:53:08 +0300 Subject: [PATCH 022/192] Force make services public by default. --- CHANGELOG.md | 2 ++ .../Compiler/CreateServiceProvidersPass.php | 4 ++-- Resources/config/anti_spam.yml | 3 +++ Resources/config/cloner.yml | 3 +++ Resources/config/custom_object.yml | 3 +++ Resources/config/default_value.yml | 3 +++ Resources/config/dev/data_fixture.yml | 3 +++ Resources/config/dev/translation.yml | 3 +++ Resources/config/flash.yml | 3 +++ Resources/config/form.yml | 3 +++ Resources/config/homepage.yml | 3 +++ Resources/config/intl.yml | 3 +++ Resources/config/locale.yml | 3 +++ Resources/config/mailer.yml | 3 +++ Resources/config/mapping.yml | 11 +++++++++++ Resources/config/new_object.yml | 3 +++ Resources/config/object_namer.yml | 3 +++ Resources/config/routing.yml | 3 +++ Resources/config/security.yml | 3 +++ Resources/config/service.yml | 3 +++ Resources/config/sluggable.yml | 3 +++ Resources/config/stringifier.yml | 3 +++ Resources/config/transliteratable.yml | 3 +++ Resources/config/tree.yml | 3 +++ Resources/config/user.yml | 3 +++ 25 files changed, 81 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d5e6be..9cc15c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case ``` 6.4.6: Remove "symfony/symfony" from dependencies. + +6.4.7: Force make services public by default. diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 6767b32..8c25906 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -10,9 +10,9 @@ namespace Darvin\UtilsBundle\DependencyInjection\Compiler; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\DefinitionDecorator; /** * Create service providers compiler pass @@ -86,7 +86,7 @@ private function addServiceProviders(ContainerBuilder $container, array $ids) ); } - $definitions[$providerId] = (new DefinitionDecorator(self::PARENT_ID))->addArgument($id); + $definitions[$providerId] = (new ChildDefinition(self::PARENT_ID))->addArgument($id); } $container->addDefinitions($definitions); diff --git a/Resources/config/anti_spam.yml b/Resources/config/anti_spam.yml index 24f2fac..5ddf67f 100644 --- a/Resources/config/anti_spam.yml +++ b/Resources/config/anti_spam.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.anti_spam.form_type.class: Darvin\Utils\Form\Type\AntiSpamType services: + _defaults: + public: true + darvin_utils.anti_spam.form_type: class: "%darvin_utils.anti_spam.form_type.class%" tags: diff --git a/Resources/config/cloner.yml b/Resources/config/cloner.yml index 203e355..be4e296 100644 --- a/Resources/config/cloner.yml +++ b/Resources/config/cloner.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.cloner.class: Darvin\Utils\Cloner\Cloner services: + _defaults: + public: true + darvin_utils.cloner: class: "%darvin_utils.cloner.class%" arguments: diff --git a/Resources/config/custom_object.yml b/Resources/config/custom_object.yml index 4e04d60..f7495aa 100644 --- a/Resources/config/custom_object.yml +++ b/Resources/config/custom_object.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.custom_object.loader.entity.class: Darvin\Utils\CustomObject\CustomEntityLoader services: + _defaults: + public: true + darvin_utils.custom_object.loader: alias: darvin_utils.custom_object.loader.entity diff --git a/Resources/config/default_value.yml b/Resources/config/default_value.yml index b42f124..0740d9d 100644 --- a/Resources/config/default_value.yml +++ b/Resources/config/default_value.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.default_value.subscriber.class: Darvin\Utils\EventListener\DefaultValueSubscriber services: + _defaults: + public: true + darvin_utils.default_value.subscriber: class: "%darvin_utils.default_value.subscriber.class%" public: false diff --git a/Resources/config/dev/data_fixture.yml b/Resources/config/dev/data_fixture.yml index c480a8d..effbc95 100644 --- a/Resources/config/dev/data_fixture.yml +++ b/Resources/config/dev/data_fixture.yml @@ -3,6 +3,9 @@ parameters: darvin_utils.data_fixture.load_command.name: darvin:utils:fixture:load services: + _defaults: + public: true + darvin_utils.data_fixture.load_command: class: "%darvin_utils.data_fixture.load_command.class%" arguments: diff --git a/Resources/config/dev/translation.yml b/Resources/config/dev/translation.yml index b89f3b9..caa26ac 100644 --- a/Resources/config/dev/translation.yml +++ b/Resources/config/dev/translation.yml @@ -8,6 +8,9 @@ parameters: darvin_utils.translation.translate_command.name: darvin:utils:translations:translate services: + _defaults: + public: true + darvin_utils.translation.title_case_command: class: "%darvin_utils.translation.title_case_command.class%" arguments: diff --git a/Resources/config/flash.yml b/Resources/config/flash.yml index 534fd2c..0802ba2 100644 --- a/Resources/config/flash.yml +++ b/Resources/config/flash.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.flash.notifier.class: Darvin\Utils\Flash\FlashNotifier services: + _defaults: + public: true + darvin_utils.flash.notifier: class: "%darvin_utils.flash.notifier.class%" arguments: diff --git a/Resources/config/form.yml b/Resources/config/form.yml index 90b5367..ab6bc15 100644 --- a/Resources/config/form.yml +++ b/Resources/config/form.yml @@ -6,6 +6,9 @@ parameters: darvin_utils.form.number_type_extension.class: Darvin\Utils\Form\Extension\NumberTypeExtension services: + _defaults: + public: true + darvin_utils.form.description_extension: class: "%darvin_utils.form.description_extension.class%" tags: diff --git a/Resources/config/homepage.yml b/Resources/config/homepage.yml index f431be5..dae022c 100644 --- a/Resources/config/homepage.yml +++ b/Resources/config/homepage.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.homepage.dummy_router.class: Darvin\Utils\Homepage\DummyHomepageRouter services: + _defaults: + public: true + darvin_utils.homepage.router: alias: darvin_utils.homepage.dummy_router diff --git a/Resources/config/intl.yml b/Resources/config/intl.yml index 933a9ad..05587cf 100644 --- a/Resources/config/intl.yml +++ b/Resources/config/intl.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.intl.twig_extension.class: Twig_Extensions_Extension_Intl services: + _defaults: + public: true + darvin_utils.intl.twig_extension: class: "%darvin_utils.intl.twig_extension.class%" public: false diff --git a/Resources/config/locale.yml b/Resources/config/locale.yml index 919376f..52c143b 100644 --- a/Resources/config/locale.yml +++ b/Resources/config/locale.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.locale.provider.class: Darvin\Utils\Locale\LocaleProvider services: + _defaults: + public: true + darvin_utils.locale.provider: class: "%darvin_utils.locale.provider.class%" arguments: diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index a0755ad..ba5466a 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.mailer.class: Darvin\Utils\Mailer\Mailer services: + _defaults: + public: true + darvin_utils.mailer: class: "%darvin_utils.mailer.class%" arguments: diff --git a/Resources/config/mapping.yml b/Resources/config/mapping.yml index ec35464..7b672dc 100644 --- a/Resources/config/mapping.yml +++ b/Resources/config/mapping.yml @@ -22,6 +22,9 @@ parameters: darvin_utils.mapping.set_default_discriminator_listener.class: Darvin\Utils\EventListener\SetDefaultDiscriminatorListener services: + _defaults: + public: true + darvin_utils.mapping.annotation_driver.abstract: class: "%darvin_utils.mapping.annotation_driver.abstract.class%" abstract: true @@ -32,48 +35,56 @@ services: darvin_utils.mapping.annotation_driver.clonable: class: "%darvin_utils.mapping.annotation_driver.clonable.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.custom_object: class: "%darvin_utils.mapping.annotation_driver.custom_object.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.default_value: class: "%darvin_utils.mapping.annotation_driver.default_value.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.new_object_flag: class: "%darvin_utils.mapping.annotation_driver.new_object_flag.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.slug: class: "%darvin_utils.mapping.annotation_driver.slug.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.transliteratable: class: "%darvin_utils.mapping.annotation_driver.transliteratable.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.updated_at: class: "%darvin_utils.mapping.annotation_driver.updated_at.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.user: class: "%darvin_utils.mapping.annotation_driver.user.class%" parent: darvin_utils.mapping.annotation_driver.abstract + public: false tags: - { name: darvin_utils.annotation_driver } diff --git a/Resources/config/new_object.yml b/Resources/config/new_object.yml index f0d85e2..10b8dc6 100644 --- a/Resources/config/new_object.yml +++ b/Resources/config/new_object.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.new_object.twig_extension.class: Darvin\Utils\Twig\Extension\NewObjectExtension services: + _defaults: + public: true + darvin_utils.new_object.counter: alias: darvin_utils.new_object.counter.entity diff --git a/Resources/config/object_namer.yml b/Resources/config/object_namer.yml index 7920c7a..97a4c8b 100644 --- a/Resources/config/object_namer.yml +++ b/Resources/config/object_namer.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.object_namer.twig_extension.class: Darvin\Utils\Twig\Extension\ObjectNamerExtension services: + _defaults: + public: true + darvin_utils.object_namer: class: "%darvin_utils.object_namer.class%" diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index c2a8707..eecf3f2 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.routing.route_manager.cached.class: Darvin\Utils\Routing\CachedRouteManager services: + _defaults: + public: true + darvin_utils.routing.route_cache_warmer: class: "%darvin_utils.routing.route_cache_warmer.class%" public: false diff --git a/Resources/config/security.yml b/Resources/config/security.yml index a50e84b..c06bdb9 100644 --- a/Resources/config/security.yml +++ b/Resources/config/security.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.security.accessibility_checker.class: Darvin\Utils\Security\Authorization\AccessibilityChecker services: + _defaults: + public: true + darvin_utils.security.accessibility_checker: class: "%darvin_utils.security.accessibility_checker.class%" arguments: diff --git a/Resources/config/service.yml b/Resources/config/service.yml index bbede3d..34b81b4 100644 --- a/Resources/config/service.yml +++ b/Resources/config/service.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.service.abstract_provider.class: Darvin\Utils\Service\ServiceProvider services: + _defaults: + public: true + darvin_utils.service.abstract_provider: class: "%darvin_utils.service.abstract_provider.class%" abstract: true diff --git a/Resources/config/sluggable.yml b/Resources/config/sluggable.yml index 35150f4..0ce337a 100644 --- a/Resources/config/sluggable.yml +++ b/Resources/config/sluggable.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.sluggable.subscriber.class: Darvin\Utils\EventListener\SluggableSubscriber services: + _defaults: + public: true + darvin_utils.sluggable.manager: alias: darvin_utils.sluggable.manager.entity diff --git a/Resources/config/stringifier.yml b/Resources/config/stringifier.yml index b38a324..9f6ceee 100644 --- a/Resources/config/stringifier.yml +++ b/Resources/config/stringifier.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.stringifier.doctrine.class: Darvin\Utils\Strings\Stringifier\DoctrineStringifier services: + _defaults: + public: true + darvin_utils.stringifier.doctrine: class: "%darvin_utils.stringifier.doctrine.class%" arguments: diff --git a/Resources/config/transliteratable.yml b/Resources/config/transliteratable.yml index 7a6786b..9316307 100644 --- a/Resources/config/transliteratable.yml +++ b/Resources/config/transliteratable.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator services: + _defaults: + public: true + darvin_utils.transliteratable.subscriber: class: "%darvin_utils.transliteratable.subscriber.class%" public: false diff --git a/Resources/config/tree.yml b/Resources/config/tree.yml index bb6c694..e094afc 100644 --- a/Resources/config/tree.yml +++ b/Resources/config/tree.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.tree.sorter.class: Darvin\Utils\Tree\TreeSorter services: + _defaults: + public: true + darvin_utils.tree.sorter: class: "%darvin_utils.tree.sorter.class%" public: true diff --git a/Resources/config/user.yml b/Resources/config/user.yml index 7ef1eda..e2fe4b0 100644 --- a/Resources/config/user.yml +++ b/Resources/config/user.yml @@ -2,6 +2,9 @@ parameters: darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer services: + _defaults: + public: true + darvin_utils.user.query_builder_filterer: class: "%darvin_utils.user.query_builder_filterer.class%" arguments: From 44d5145a36efb05209b11ecb0148887380cdd8bd Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 12:12:36 +0300 Subject: [PATCH 023/192] Change dependency versions. --- CHANGELOG.md | 4 ++++ composer.json | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cc15c1..15e555d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,3 +32,7 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 6.4.6: Remove "symfony/symfony" from dependencies. 6.4.7: Force make services public by default. + +7.0.0: + +- change dependency versions. diff --git a/composer.json b/composer.json index 7e218df..b7bf084 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,8 @@ } ], "require": { - "doctrine/orm": "^2.4.8", - "doctrine/doctrine-bundle": "~1.4", - "twig/extensions": "^1.3", - "darvinstudio/darvin-utils": "^6" + "twig/extensions": "^1.5", + "darvinstudio/darvin-utils": "^7" }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } From 04f31ba176521544bc3dbc3e29c27c4345b03305 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 12:13:06 +0300 Subject: [PATCH 024/192] Remove outdated docs. --- CHANGELOG.md | 4 ++- Resources/doc/reference/configuration.md | 9 ------ Resources/doc/reference/di_tags.md | 17 ----------- Resources/doc/reference/events.md | 14 --------- Resources/doc/reference/services.md | 37 ------------------------ 5 files changed, 3 insertions(+), 78 deletions(-) delete mode 100644 Resources/doc/reference/configuration.md delete mode 100644 Resources/doc/reference/di_tags.md delete mode 100644 Resources/doc/reference/events.md delete mode 100644 Resources/doc/reference/services.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 15e555d..ef2da25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,4 +35,6 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.0.0: -- change dependency versions. +- change dependency versions; + +- remove outdated docs. diff --git a/Resources/doc/reference/configuration.md b/Resources/doc/reference/configuration.md deleted file mode 100644 index 4ad7d9a..0000000 --- a/Resources/doc/reference/configuration.md +++ /dev/null @@ -1,9 +0,0 @@ -Конфигурация -============ - -```yaml -darvin_utils: - mailer: - charset: utf-8 # Кодировка e-mail - from: ~ # Отправитель e-mail -``` diff --git a/Resources/doc/reference/di_tags.md b/Resources/doc/reference/di_tags.md deleted file mode 100644 index 56d770c..0000000 --- a/Resources/doc/reference/di_tags.md +++ /dev/null @@ -1,17 +0,0 @@ -DI-теги -======= - -### darvin_utils.annotation_driver: - -- **что помечается** - драйвер аннотаций; -- **для чего используется** - для инъекции драйвера аннотаций в [Metadata factory](../metadata_factory.md) - "darvin_utils.mapping.metadata_factory"; -- **требования** - класс драйвера должен реализовывать "Darvin\Utils\Mapping\AnnotationDriver\AnnotationDriverInterface" - или наследоваться от "Darvin\Utils\Mapping\AnnotationDriver\AbstractDriver". - -### darvin_utils.slug_handler: - -- **что помечается** - обработчик slug'ов; -- **для чего используется** - для инъекции обработчика slug'ов в [Sluggable](../sluggable.md) event subscriber - "darvin_utils.slug.subscriber"; -- **требования** - класс обработчика должен реализовывать "Darvin\Utils\Slug\SlugHandlerInterface". diff --git a/Resources/doc/reference/events.md b/Resources/doc/reference/events.md deleted file mode 100644 index bc04321..0000000 --- a/Resources/doc/reference/events.md +++ /dev/null @@ -1,14 +0,0 @@ -События -======= - -### Darvin\Utils\Event\Events::POST_CLONE: -- **строковое представление** - "darvin_utils.post_clone"; -- **класс события** - "Darvin\Utils\Event\CloneEvent"; -- **кем вызывается** - сервисом "darvin_utils.cloner"; -- **когда вызывается** - после клонирования сущности. - -### Darvin\Utils\Event\Events::POST_SLUGS_UPDATE: -- **строковое представление** - "darvin_utils.post_slugs_update"; -- **класс события** - "Darvin\Utils\Event\SlugsUpdateEvent"; -- **кем вызывается** - event subscriber'ом "darvin_utils.slug.subscriber"; -- **когда вызывается** - после обновления slug'ов. diff --git a/Resources/doc/reference/services.md b/Resources/doc/reference/services.md deleted file mode 100644 index 107c779..0000000 --- a/Resources/doc/reference/services.md +++ /dev/null @@ -1,37 +0,0 @@ -Публичные сервисы -================= - -- **darvin_utils.anti_spam.form_type** - поле формы, реализующее функционал антиспам; - - -- **darvin_utils.cloner** - [сервис](../cloner.md) клонирования сущностей; - - -- **darvin_utils.custom_object.loader** - [сервис](../custom_entity_loader.md) инициализации сущности в поле другой - сущности с использованием атрибутов инициализации из свойств последней; - - -- **darvin_utils.flash.notifier** - [сервис](../flash_notifier.md), упрощающий добавление flash-сообщений; - - -- **darvin_utils.mailer** - [сервис](../mailer.md) отправки электронной почты; - - -- **darvin_utils.mapping.metadata_factory** - [фабрика](../metadata_factory.md) метаданных на базе аннотаций; - - -- **darvin_utils.new_object.counter** - [сервис](../new_entity_counter.md) подсчета количества новых сущностей; - - -- **darvin_utils.object_namer** - [сервис](../object_namer.md) генерации имени объекта в нотации "under_score" по его - классу, которое затем можно использовать, например, в строках переводов; - - -- **darvin_utils.security.accessibility_checker** - [сервис](../accessibility_checker.md) проверки доступности объекта для - текущего пользователя; - - -- **darvin_utils.stringifier.doctrine** - [сервис](../stringifier.md) приведения свойств объектов Doctrine к строке; - - -- **darvin_utils.transliteratable.transliterator** - [сервис](../transliteratable.md) транслитерации. From f1dd04f6baa77774fb87a4c4ddf8b596ea880dd5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 14:36:28 +0300 Subject: [PATCH 025/192] Rename post clone event. --- Resources/doc/cloner.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/doc/cloner.md b/Resources/doc/cloner.md index bb416fd..e65d891 100644 --- a/Resources/doc/cloner.md +++ b/Resources/doc/cloner.md @@ -62,4 +62,4 @@ echo $pageClone->getContent(); // 'Hello, world!' ``` После клонирования сущности (непосредственного или сущности в свойстве) вызывается событие - "Darvin\Utils\Event\Events::POST_CLONE" ("darvin_utils.post_clone"). Класс события - "Darvin\Utils\Event\CloneEvent". + "Darvin\Utils\Event\CloneEvents::CREATED" ("darvin_utils.clone.created"). Класс события - "Darvin\Utils\Event\CloneEvent". From 2e69a69e65bc0ab1d475682bd088981ed75bd23f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 14:49:57 +0300 Subject: [PATCH 026/192] Rename events. --- Resources/doc/cloner.md | 2 +- Resources/doc/sluggable.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/doc/cloner.md b/Resources/doc/cloner.md index e65d891..8cb8335 100644 --- a/Resources/doc/cloner.md +++ b/Resources/doc/cloner.md @@ -62,4 +62,4 @@ echo $pageClone->getContent(); // 'Hello, world!' ``` После клонирования сущности (непосредственного или сущности в свойстве) вызывается событие - "Darvin\Utils\Event\CloneEvents::CREATED" ("darvin_utils.clone.created"). Класс события - "Darvin\Utils\Event\CloneEvent". + "Darvin\Utils\Event\ClonableEvents::CLONED" ("darvin_utils.clonable.cloned"). Класс события - "Darvin\Utils\Event\CloneEvent". diff --git a/Resources/doc/sluggable.md b/Resources/doc/sluggable.md index e97414b..779678b 100644 --- a/Resources/doc/sluggable.md +++ b/Resources/doc/sluggable.md @@ -63,8 +63,8 @@ class Page **2. Event subscriber "darvin_utils.slug.subscriber" автоматически сгенерирует slug и присвоит его свойству Page::$slug (в приведенном выше примере).** -После обновления slug'ов subscriber вызывает событие "Darvin\Utils\Event\Events::POST_SLUGS_UPDATE" - ("darvin_utils.post_slugs_update"). Класс события - "Darvin\Utils\Event\SlugsUpdateEvent". +После обновления slug'ов subscriber вызывает событие "Darvin\Utils\Event\SluggableEvents::SLUGS_UPDATED" + ("darvin_utils.sluggable.slugs_updated"). Класс события - "Darvin\Utils\Event\SlugsUpdateEvent". ## Добавление обработчика slug'ов From 34736596f266c26073577ed228a08c320d3e8bc2 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 15:34:54 +0300 Subject: [PATCH 027/192] Rename event subscribers. --- Resources/config/default_value.yml | 10 +++++----- Resources/config/sluggable.yml | 20 ++++++++++---------- Resources/config/transliteratable.yml | 14 +++++++------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Resources/config/default_value.yml b/Resources/config/default_value.yml index 0740d9d..2dedf5c 100644 --- a/Resources/config/default_value.yml +++ b/Resources/config/default_value.yml @@ -1,15 +1,15 @@ parameters: - darvin_utils.default_value.subscriber.class: Darvin\Utils\EventListener\DefaultValueSubscriber + darvin_utils.default_value.set_event_subscriber.class: Darvin\Utils\EventListener\SetDefaultValuesSubscriber services: _defaults: public: true - darvin_utils.default_value.subscriber: - class: "%darvin_utils.default_value.subscriber.class%" + darvin_utils.default_value.set_event_subscriber: + class: '%darvin_utils.default_value.set_event_subscriber.class%' public: false arguments: - - "@darvin_utils.mapping.metadata_factory" - - "@property_accessor" + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' tags: - { name: doctrine.event_subscriber, priority: 500 } diff --git a/Resources/config/sluggable.yml b/Resources/config/sluggable.yml index 0ce337a..ff18c59 100644 --- a/Resources/config/sluggable.yml +++ b/Resources/config/sluggable.yml @@ -1,7 +1,7 @@ parameters: darvin_utils.sluggable.manager.entity.class: Darvin\Utils\Sluggable\SluggableEntityManager - darvin_utils.sluggable.subscriber.class: Darvin\Utils\EventListener\SluggableSubscriber + darvin_utils.sluggable.slugify_event_subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber services: _defaults: @@ -11,18 +11,18 @@ services: alias: darvin_utils.sluggable.manager.entity darvin_utils.sluggable.manager.entity: - class: "%darvin_utils.sluggable.manager.entity.class%" + class: '%darvin_utils.sluggable.manager.entity.class%' arguments: - - "@darvin_utils.entity_manager.provider" - - "@event_dispatcher" - - "@darvin_utils.mapping.metadata_factory" - - "@property_accessor" + - '@darvin_utils.entity_manager.provider' + - '@event_dispatcher' + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' - darvin_utils.sluggable.subscriber: - class: "%darvin_utils.sluggable.subscriber.class%" + darvin_utils.sluggable.slugify_event_subscriber: + class: '%darvin_utils.sluggable.slugify_event_subscriber.class%' public: false arguments: - - "@darvin_utils.entity_manager.provider" - - "@darvin_utils.sluggable.manager" + - '@darvin_utils.entity_manager.provider' + - '@darvin_utils.sluggable.manager' tags: - { name: doctrine.event_subscriber, priority: 200 } diff --git a/Resources/config/transliteratable.yml b/Resources/config/transliteratable.yml index 9316307..f01234f 100644 --- a/Resources/config/transliteratable.yml +++ b/Resources/config/transliteratable.yml @@ -1,5 +1,5 @@ parameters: - darvin_utils.transliteratable.subscriber.class: Darvin\Utils\EventListener\TransliteratableSubscriber + darvin_utils.transliteratable.transliterate_event_subscriber.class: Darvin\Utils\EventListener\TransliterateSubscriber darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator @@ -7,15 +7,15 @@ services: _defaults: public: true - darvin_utils.transliteratable.subscriber: - class: "%darvin_utils.transliteratable.subscriber.class%" + darvin_utils.transliteratable.transliterate_event_subscriber: + class: '%darvin_utils.transliteratable.transliterate_event_subscriber.class%' public: false arguments: - - "@darvin_utils.mapping.metadata_factory" - - "@property_accessor" - - "@darvin_utils.transliteratable.transliterator" + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' + - '@darvin_utils.transliteratable.transliterator' tags: - { name: doctrine.event_subscriber, priority: 300 } darvin_utils.transliteratable.transliterator: - class: "%darvin_utils.transliteratable.transliterator.class%" + class: '%darvin_utils.transliteratable.transliterator.class%' From 33aa66fada7d4b197245963c48c0cb214360550b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 16:05:33 +0300 Subject: [PATCH 028/192] Remove redundant exception classes. --- .../Compiler/ValidateResolveTargetEntitiesConfigPass.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php index 6d79db9..93229b2 100644 --- a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php +++ b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php @@ -10,7 +10,6 @@ namespace Darvin\UtilsBundle\DependencyInjection\Compiler; -use Darvin\Utils\Exception\ConfigurationException; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -30,13 +29,13 @@ public function process(ContainerBuilder $container) } foreach ($part['orm']['resolve_target_entities'] as $target => $replacement) { if (!interface_exists($target) && !class_exists($target)) { - throw new ConfigurationException(sprintf('Target interface/class "%s" does not exist.', $target)); + throw new \LogicException(sprintf('Target interface/class "%s" does not exist.', $target)); } if (!class_exists($replacement)) { - throw new ConfigurationException(sprintf('Replacement entity class "%s" does not exist.', $replacement)); + throw new \LogicException(sprintf('Replacement entity class "%s" does not exist.', $replacement)); } if (!in_array($target, array_merge(class_implements($replacement), class_parents($replacement)))) { - throw new ConfigurationException(sprintf( + throw new \LogicException(sprintf( 'Replacement entity class "%s" must implement/extend target interface/class "%s".', $replacement, $target From 87a59d56307597094ec7aa99f9f15b7042ea59d6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 16:35:20 +0300 Subject: [PATCH 029/192] Remove redundant docs. --- README.md | 9 --------- Resources/doc/coding_standards.md | 2 -- Resources/doc/mailer.md | 4 ++-- UPGRADE_6.md | 1 - 4 files changed, 2 insertions(+), 14 deletions(-) delete mode 100644 Resources/doc/coding_standards.md delete mode 100644 UPGRADE_6.md diff --git a/README.md b/README.md index 0de7422..7a46deb 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,3 @@ - [**Stringifier**](Resources/doc/stringifier.md) - сервис приведения свойств объектов Doctrine к строке; - [**Transliteratable**](Resources/doc/transliteratable.md) - функционал, позволяющий автоматически транслитерировать значения свойств сущностей. - -### Справочники: - -- [**DI-теги**](Resources/doc/reference/di_tags.md); -- [**Конфигурация**](Resources/doc/reference/configuration.md); -- [**Публичные сервисы**](Resources/doc/reference/services.md); -- [**События**](Resources/doc/reference/events.md). - -### [Рекомендации по стилю кода](Resources/doc/coding_standards.md) diff --git a/Resources/doc/coding_standards.md b/Resources/doc/coding_standards.md deleted file mode 100644 index 389de56..0000000 --- a/Resources/doc/coding_standards.md +++ /dev/null @@ -1,2 +0,0 @@ -- [**PSR-2**](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md); -- [**Symfony Coding Standards**](http://symfony.com/doc/current/contributing/code/standards.html). diff --git a/Resources/doc/mailer.md b/Resources/doc/mailer.md index 04ce161..a6bf275 100644 --- a/Resources/doc/mailer.md +++ b/Resources/doc/mailer.md @@ -25,5 +25,5 @@ $this->getContainer()->get('darvin_utils.mailer')->send( - в качестве аргумента "subject" можно передавать строку перевода, при этом можно использовать аргумент "subjectParams" для передачи параметров перевода (см. пример выше); -- имя отправителя задается параметром "darvin_utils.mailer.from" [конфигурации](reference/configuration.md) бандла; -- кодировка письма задается параметром "darvin_utils.mailer.charset" [конфигурации](reference/configuration.md) бандла. +- имя отправителя задается параметром "darvin_utils.mailer.from" конфигурации бандла; +- кодировка письма задается параметром "darvin_utils.mailer.charset" конфигурации бандла. diff --git a/UPGRADE_6.md b/UPGRADE_6.md deleted file mode 100644 index 7cc0a92..0000000 --- a/UPGRADE_6.md +++ /dev/null @@ -1 +0,0 @@ -1. Удалите свойство "prefixProvider" из аннотации "Slug". From 9826427a0fb56f9f83676ff58e59e759704af745 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 9 Oct 2018 16:41:15 +0300 Subject: [PATCH 030/192] Refactor DI classes. --- DependencyInjection/Configuration.php | 5 +---- DependencyInjection/DarvinUtilsExtension.php | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 07bc577..649f838 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -39,10 +39,7 @@ public function getConfigTreeBuilder() ->scalarNode('charset')->defaultValue('utf-8')->end() ->scalarNode('from')->isRequired()->end() ->scalarNode('from_name')->defaultNull()->end() - ->booleanNode('prepend_host')->defaultTrue()->end() - ->end() - ->end() - ->end(); + ->booleanNode('prepend_host')->defaultTrue(); return $treeBuilder; } diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index dee0320..ea3606b 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -30,11 +30,9 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac */ public function load(array $configs, ContainerBuilder $container) { - $configuration = new Configuration(); - $config = $this->processConfiguration($configuration, $configs); + $config = $this->processConfiguration(new Configuration(), $configs); - $configInjector = new ConfigInjector(); - $configInjector->inject($config, $container, $this->getAlias()); + (new ConfigInjector())->inject($config, $container, $this->getAlias()); $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); From 3f1aa69ba25670deecf8a19268f7489ce6554038 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 10 Oct 2018 08:49:17 +0300 Subject: [PATCH 031/192] Simplify compiler passes. --- .../Compiler/AddAnnotationDriversPass.php | 22 +++------------- .../Compiler/AddSlugHandlersPass.php | 25 ++++--------------- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/DependencyInjection/Compiler/AddAnnotationDriversPass.php b/DependencyInjection/Compiler/AddAnnotationDriversPass.php index bef71a0..c967140 100644 --- a/DependencyInjection/Compiler/AddAnnotationDriversPass.php +++ b/DependencyInjection/Compiler/AddAnnotationDriversPass.php @@ -19,31 +19,15 @@ */ class AddAnnotationDriversPass implements CompilerPassInterface { - const METADATA_FACTORY_ID = 'darvin_utils.mapping.metadata_factory'; - - const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; - /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { - if (!$container->hasDefinition(self::METADATA_FACTORY_ID)) { - return; - } - - $driverIds = $container->findTaggedServiceIds(self::TAG_ANNOTATION_DRIVER); - - if (empty($driverIds)) { - return; - } - - $factoryDefinition = $container->getDefinition(self::METADATA_FACTORY_ID); + $factory = $container->getDefinition('darvin_utils.mapping.metadata_factory'); - foreach ($driverIds as $id => $attr) { - $factoryDefinition->addMethodCall('addAnnotationDriver', [ - new Reference($id), - ]); + foreach (array_keys($container->findTaggedServiceIds('darvin_utils.annotation_driver')) as $id) { + $factory->addMethodCall('addAnnotationDriver', [new Reference($id)]); } } } diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index b66d8c4..aca1cbc 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -20,34 +20,19 @@ */ class AddSlugHandlersPass implements CompilerPassInterface { - const SLUGGABLE_MANAGER_ID = 'darvin_utils.sluggable.manager.entity'; - - const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; - /** * {@inheritdoc} */ public function process(ContainerBuilder $container) { - if (!$container->hasDefinition(self::SLUGGABLE_MANAGER_ID)) { - return; - } - - $handlerIds = $container->findTaggedServiceIds(self::TAG_SLUG_HANDLER); - - if (empty($handlerIds)) { - return; - } + $ids = $container->findTaggedServiceIds('darvin_utils.slug_handler'); - $sorter = new TaggedServiceIdsSorter(); - $sorter->sort($handlerIds); + (new TaggedServiceIdsSorter())->sort($ids); - $sluggableManagerDefinition = $container->getDefinition(self::SLUGGABLE_MANAGER_ID); + $manager = $container->getDefinition('darvin_utils.sluggable.manager.entity'); - foreach ($handlerIds as $id => $attr) { - $sluggableManagerDefinition->addMethodCall('addSlugHandler', [ - new Reference($id), - ]); + foreach (array_keys($ids) as $id) { + $manager->addMethodCall('addSlugHandler', [new Reference($id)]); } } } From 0925d0286d9968e3853e7071c7fae9b2abdb51a6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 10 Oct 2018 11:14:49 +0300 Subject: [PATCH 032/192] Fix copyright years. --- DependencyInjection/Compiler/AddAnnotationDriversPass.php | 2 +- DependencyInjection/Compiler/AddSlugHandlersPass.php | 2 +- DependencyInjection/Compiler/CreateServiceProvidersPass.php | 2 +- .../Compiler/ValidateResolveTargetEntitiesConfigPass.php | 2 +- DependencyInjection/Configuration.php | 2 +- DependencyInjection/DarvinUtilsExtension.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DependencyInjection/Compiler/AddAnnotationDriversPass.php b/DependencyInjection/Compiler/AddAnnotationDriversPass.php index c967140..1e61a3d 100644 --- a/DependencyInjection/Compiler/AddAnnotationDriversPass.php +++ b/DependencyInjection/Compiler/AddAnnotationDriversPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015, Darvin Studio + * @copyright Copyright (c) 2015-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index aca1cbc..411d7b6 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015, Darvin Studio + * @copyright Copyright (c) 2015-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 8c25906..71776f7 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2016, Darvin Studio + * @copyright Copyright (c) 2016-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php index 93229b2..13ec3ff 100644 --- a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php +++ b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2017, Darvin Studio + * @copyright Copyright (c) 2017-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 649f838..cdf062a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015, Darvin Studio + * @copyright Copyright (c) 2015-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index ea3606b..c0e08c3 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2016, Darvin Studio + * @copyright Copyright (c) 2015-2018, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE From 830f1dc3f138a1b36112c9ba2f86eda8f11b3673 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 19 Oct 2018 16:08:24 +0300 Subject: [PATCH 033/192] Implement override entities compiler pass in utils bundle. --- DarvinUtilsBundle.php | 8 +- .../Compiler/OverrideEntitiesPass.php | 83 +++++++++++++++++++ ...alidateResolveTargetEntitiesConfigPass.php | 47 ----------- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/app/doctrine.yml | 3 + 5 files changed, 91 insertions(+), 51 deletions(-) create mode 100644 DependencyInjection/Compiler/OverrideEntitiesPass.php delete mode 100644 DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php create mode 100644 Resources/config/app/doctrine.yml diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index c13d4eb..51a7528 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -1,4 +1,4 @@ - * @copyright Copyright (c) 2015, Darvin Studio @@ -13,7 +13,7 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddAnnotationDriversPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; -use Darvin\UtilsBundle\DependencyInjection\Compiler\ValidateResolveTargetEntitiesConfigPass; +use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -25,7 +25,7 @@ class DarvinUtilsBundle extends Bundle /** * {@inheritdoc} */ - public function build(ContainerBuilder $container) + public function build(ContainerBuilder $container): void { parent::build($container); @@ -33,6 +33,6 @@ public function build(ContainerBuilder $container) ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddSlugHandlersPass()) ->addCompilerPass(new CreateServiceProvidersPass()) - ->addCompilerPass(new ValidateResolveTargetEntitiesConfigPass()); + ->addCompilerPass(new OverrideEntitiesPass()); } } diff --git a/DependencyInjection/Compiler/OverrideEntitiesPass.php b/DependencyInjection/Compiler/OverrideEntitiesPass.php new file mode 100644 index 0000000..4895afe --- /dev/null +++ b/DependencyInjection/Compiler/OverrideEntitiesPass.php @@ -0,0 +1,83 @@ + + * @copyright Copyright (c) 2018, Darvin Studio + * @link https://www.darvin-studio.ru + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Darvin\UtilsBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; + +/** + * Override entities compiler pass + */ +class OverrideEntitiesPass implements CompilerPassInterface +{ + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container): void + { + $bundles = $container->getParameter('kernel.bundles_metadata'); + $filesystem = new Filesystem(); + $implementations = $replacements = []; + + foreach ($bundles as $bundle => $attr) { + if (0 !== strpos($attr['namespace'], 'Darvin\\')) { + continue; + } + + $dir = implode(DIRECTORY_SEPARATOR, [$attr['path'], 'Entity']); + + if (!$filesystem->exists($dir)) { + continue; + } + /** @var \Symfony\Component\Finder\SplFileInfo $file */ + foreach ((new Finder())->in($dir)->files()->name('*.php') as $file) { + $class = str_replace(DIRECTORY_SEPARATOR, '\\', preg_replace('/.php$/', '', $file->getRelativePathname())); + + $fqcn = implode('\\Entity\\', [$attr['namespace'], $class]); + + if (!class_exists($fqcn)) { + continue; + } + + $parts = array_merge(['App', 'Entity', preg_replace('/^Darvin|Bundle$/', '', $bundle)], explode('\\', $class)); + $parts[] = sprintf('App%s', array_pop($parts)); + + $replacement = implode('\\', $parts); + + if (class_exists($replacement) && in_array($fqcn, class_parents($replacement))) { + $replacements[$fqcn] = $replacement; + } + foreach (class_implements($fqcn) as $interface) { + if (sprintf('%sInterface', $fqcn) === $interface) { + $implementations[$interface] = $replacements[$fqcn] ?? $fqcn; + + break; + } + } + } + } + if (!empty($replacements) && isset($bundles['DarvinAdminBundle'])) { + $container->setParameter( + 'darvin_admin.entity_override', + array_merge($replacements, $container->getParameter('darvin_admin.entity_override')) + ); + } + if (!empty($implementations)) { + $listener = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity'); + + foreach ($implementations as $interface => $implementation) { + $listener->addMethodCall('addResolveTargetEntity', [$interface, $implementation, []]); + } + } + } +} diff --git a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php b/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php deleted file mode 100644 index 13ec3ff..0000000 --- a/DependencyInjection/Compiler/ValidateResolveTargetEntitiesConfigPass.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright Copyright (c) 2017-2018, Darvin Studio - * @link https://www.darvin-studio.ru - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Darvin\UtilsBundle\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * Validate resolve target entities configuration compiler pass - */ -class ValidateResolveTargetEntitiesConfigPass implements CompilerPassInterface -{ - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - foreach ($container->getExtensionConfig('doctrine') as $part) { - if (!isset($part['orm']['resolve_target_entities'])) { - continue; - } - foreach ($part['orm']['resolve_target_entities'] as $target => $replacement) { - if (!interface_exists($target) && !class_exists($target)) { - throw new \LogicException(sprintf('Target interface/class "%s" does not exist.', $target)); - } - if (!class_exists($replacement)) { - throw new \LogicException(sprintf('Replacement entity class "%s" does not exist.', $replacement)); - } - if (!in_array($target, array_merge(class_implements($replacement), class_parents($replacement)))) { - throw new \LogicException(sprintf( - 'Replacement entity class "%s" must implement/extend target interface/class "%s".', - $replacement, - $target - )); - } - } - } - } -} diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index c0e08c3..dd44149 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -83,6 +83,7 @@ public function prepend(ContainerBuilder $container) $fileLocator = new FileLocator(__DIR__.'/../Resources/config/app'); foreach ([ + 'doctrine', 'stof_doctrine_extensions', ] as $extension) { if ($container->hasExtension($extension)) { diff --git a/Resources/config/app/doctrine.yml b/Resources/config/app/doctrine.yml new file mode 100644 index 0000000..5843f3d --- /dev/null +++ b/Resources/config/app/doctrine.yml @@ -0,0 +1,3 @@ +doctrine: + orm: + resolve_target_entities: [.] From d2a4a0f48a7359f508511de3e6e63a72421a3cbd Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 19 Oct 2018 16:38:47 +0300 Subject: [PATCH 034/192] Add entity resolver. --- CHANGELOG.md | 4 +++- .../Compiler/OverrideEntitiesPass.php | 15 ++++++++------- DependencyInjection/DarvinUtilsExtension.php | 7 ++++--- Resources/config/orm.yml | 9 +++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 Resources/config/orm.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index ef2da25..1af999f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,4 +37,6 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - change dependency versions; -- remove outdated docs. +- remove outdated docs; + +- add entity resolver. diff --git a/DependencyInjection/Compiler/OverrideEntitiesPass.php b/DependencyInjection/Compiler/OverrideEntitiesPass.php index 4895afe..819dc00 100644 --- a/DependencyInjection/Compiler/OverrideEntitiesPass.php +++ b/DependencyInjection/Compiler/OverrideEntitiesPass.php @@ -59,19 +59,13 @@ public function process(ContainerBuilder $container): void } foreach (class_implements($fqcn) as $interface) { if (sprintf('%sInterface', $fqcn) === $interface) { - $implementations[$interface] = $replacements[$fqcn] ?? $fqcn; + $implementations[$interface] = $replacements[$interface] = $replacements[$fqcn] ?? $fqcn; break; } } } } - if (!empty($replacements) && isset($bundles['DarvinAdminBundle'])) { - $container->setParameter( - 'darvin_admin.entity_override', - array_merge($replacements, $container->getParameter('darvin_admin.entity_override')) - ); - } if (!empty($implementations)) { $listener = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity'); @@ -79,5 +73,12 @@ public function process(ContainerBuilder $container): void $listener->addMethodCall('addResolveTargetEntity', [$interface, $implementation, []]); } } + if (!empty($replacements)) { + $resolver = $container->getDefinition('darvin_utils.orm.entity_resolver'); + + foreach ($replacements as $entity => $replacement) { + $resolver->addMethodCall('addReplacement', [$entity, $replacement]); + } + } } } diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index dd44149..e88bd49 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -1,4 +1,4 @@ - * @copyright Copyright (c) 2015-2018, Darvin Studio @@ -28,7 +28,7 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac /** * {@inheritdoc} */ - public function load(array $configs, ContainerBuilder $container) + public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration(new Configuration(), $configs); @@ -49,6 +49,7 @@ public function load(array $configs, ContainerBuilder $container) 'mapping', 'new_object', 'object_namer', + 'orm', 'routing', 'security', 'service', @@ -78,7 +79,7 @@ public function load(array $configs, ContainerBuilder $container) /** * {@inheritdoc} */ - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container): void { $fileLocator = new FileLocator(__DIR__.'/../Resources/config/app'); diff --git a/Resources/config/orm.yml b/Resources/config/orm.yml new file mode 100644 index 0000000..ddd6f17 --- /dev/null +++ b/Resources/config/orm.yml @@ -0,0 +1,9 @@ +parameters: + darvin_utils.orm.entity_resolver.class: Darvin\Utils\ORM\EntityResolver + +services: + _defaults: + public: true + + darvin_utils.orm.entity_resolver: + class: '%darvin_utils.orm.entity_resolver.class%' From 4fb34344d4fb4293b271683d85ee8238be3463fe Mon Sep 17 00:00:00 2001 From: Alexey Gorshkov Date: Fri, 19 Oct 2018 16:58:40 +0300 Subject: [PATCH 035/192] Update mailer service configuration. --- DependencyInjection/Configuration.php | 2 +- Resources/config/mailer.yml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index cdf062a..caec623 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -36,7 +36,7 @@ public function getConfigTreeBuilder() ->arrayNode('mailer') ->canBeEnabled() ->children() - ->scalarNode('charset')->defaultValue('utf-8')->end() + ->scalarNode('charset')->defaultValue('utf-8')->cannotBeEmpty()->end() ->scalarNode('from')->isRequired()->end() ->scalarNode('from_name')->defaultNull()->end() ->booleanNode('prepend_host')->defaultTrue(); diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index ba5466a..b3f1660 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -1,6 +1,8 @@ parameters: darvin_utils.mailer.class: Darvin\Utils\Mailer\Mailer + darvin_utils.mailer.translation_domain: email + services: _defaults: public: true @@ -10,9 +12,10 @@ services: arguments: - "@logger" - "@request_stack" - - "@?mailer" - "@translator" + - "%darvin_utils.mailer.translation_domain%" - "%darvin_utils.mailer.charset%" - "%darvin_utils.mailer.from%" - "%darvin_utils.mailer.from_name%" - "%darvin_utils.mailer.prepend_host%" + - "@?mailer" From 35f76b0bf2df4931e3e53433168967de38f22af5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 23 Oct 2018 12:28:31 +0300 Subject: [PATCH 036/192] Init filesystem in constructor. --- .../Compiler/OverrideEntitiesPass.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Compiler/OverrideEntitiesPass.php b/DependencyInjection/Compiler/OverrideEntitiesPass.php index 819dc00..c121c42 100644 --- a/DependencyInjection/Compiler/OverrideEntitiesPass.php +++ b/DependencyInjection/Compiler/OverrideEntitiesPass.php @@ -20,13 +20,25 @@ */ class OverrideEntitiesPass implements CompilerPassInterface { + /** + * @var \Symfony\Component\Filesystem\Filesystem + */ + private $filesystem; + + /** + * Constructor. + */ + public function __construct() + { + $this->filesystem = new Filesystem(); + } + /** * {@inheritdoc} */ public function process(ContainerBuilder $container): void { $bundles = $container->getParameter('kernel.bundles_metadata'); - $filesystem = new Filesystem(); $implementations = $replacements = []; foreach ($bundles as $bundle => $attr) { @@ -36,7 +48,7 @@ public function process(ContainerBuilder $container): void $dir = implode(DIRECTORY_SEPARATOR, [$attr['path'], 'Entity']); - if (!$filesystem->exists($dir)) { + if (!$this->filesystem->exists($dir)) { continue; } /** @var \Symfony\Component\Finder\SplFileInfo $file */ From caef1a243513c0f41030392a0c7f4108406b1c0b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 6 Dec 2018 09:47:42 +0300 Subject: [PATCH 037/192] Add "format_price" Twig filter. --- CHANGELOG.md | 2 + DependencyInjection/DarvinUtilsExtension.php | 1 + Price/PriceFormatter.php | 52 ++++++++++++++++++++ Resources/config/price.yml | 18 +++++++ Resources/translations/messages.ar.yml | 2 + Resources/translations/messages.en.yml | 3 ++ Resources/translations/messages.fr.yml | 4 +- Resources/translations/messages.ru.yml | 3 ++ Resources/translations/messages.zh.yml | 2 + Resources/views/price.html.twig | 1 + 10 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 Price/PriceFormatter.php create mode 100644 Resources/config/price.yml create mode 100644 Resources/views/price.html.twig diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d5e6be..9b401e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,3 +30,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case ``` 6.4.6: Remove "symfony/symfony" from dependencies. + +6.5.0: Add "format_price" Twig filter. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index dee0320..dad57d2 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -51,6 +51,7 @@ public function load(array $configs, ContainerBuilder $container) 'mapping', 'new_object', 'object_namer', + 'price', 'routing', 'security', 'service', diff --git a/Price/PriceFormatter.php b/Price/PriceFormatter.php new file mode 100644 index 0000000..e033ff6 --- /dev/null +++ b/Price/PriceFormatter.php @@ -0,0 +1,52 @@ + + * @copyright Copyright (c) 2018, Darvin Studio + * @link https://www.darvin-studio.ru + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Darvin\UtilsBundle\Price; + +use Darvin\Utils\Price\PriceFormatterInterface; +use Darvin\Utils\Service\ServiceProviderInterface; + +/** + * Price formatter + */ +class PriceFormatter implements PriceFormatterInterface +{ + /** + * @var \Darvin\Utils\Service\ServiceProviderInterface + */ + private $templatingProvider; + + /** + * @param \Darvin\Utils\Service\ServiceProviderInterface $templatingProvider Templating service provider + */ + public function __construct(ServiceProviderInterface $templatingProvider) + { + $this->templatingProvider = $templatingProvider; + } + + /** + * {@inheritdoc} + */ + public function format($price, array $options = []) + { + return $this->getTemplating()->render(isset($options['template']) ? $options['template'] : '@DarvinUtils/price.html.twig', [ + 'price' => $price, + 'options' => $options, + ]); + } + + /** + * @return \Symfony\Component\Templating\EngineInterface + */ + final protected function getTemplating() + { + return $this->templatingProvider->getService(); + } +} diff --git a/Resources/config/price.yml b/Resources/config/price.yml new file mode 100644 index 0000000..7cb435c --- /dev/null +++ b/Resources/config/price.yml @@ -0,0 +1,18 @@ +parameters: + darvin_utils.price.formatter.class: Darvin\UtilsBundle\Price\PriceFormatter + + darvin_utils.price.twig_extension.class: Darvin\Utils\Twig\Extension\PriceExtension + +services: + darvin_utils.price.formatter: + class: "%darvin_utils.price.formatter.class%" + arguments: + - "@darvin_utils.templating.provider" + + darvin_utils.price.twig_extension: + class: "%darvin_utils.price.twig_extension.class%" + public: false + arguments: + - "@darvin_utils.price.formatter" + tags: + - { name: twig.extension } diff --git a/Resources/translations/messages.ar.yml b/Resources/translations/messages.ar.yml index 6b447a9..d975bb0 100644 --- a/Resources/translations/messages.ar.yml +++ b/Resources/translations/messages.ar.yml @@ -4,3 +4,5 @@ boolean: flash: error: form: 'شكل الأخطاء المكتشفة. اصلاحها وإعادة تشكيل' +price: + default: AED %price% diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yml index 1b1dc1e..fae8f8c 100644 --- a/Resources/translations/messages.en.yml +++ b/Resources/translations/messages.en.yml @@ -5,3 +5,6 @@ boolean: flash: error: form: Form Errors Detected. Fix Them and Resubmit Form + +price: + default: $%price% diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yml index f9dec4c..d7ebc13 100644 --- a/Resources/translations/messages.fr.yml +++ b/Resources/translations/messages.fr.yml @@ -3,4 +3,6 @@ boolean: - Oui flash: error: - form: 'Des erreurs détectées. Les corriger et de soumettre à nouveau le formulaire' + form: 'Des Erreurs Détectées. Les corriger et de soumettre à nouveau le Formulaire' +price: + default: '%price% €' diff --git a/Resources/translations/messages.ru.yml b/Resources/translations/messages.ru.yml index d290122..c540f3e 100644 --- a/Resources/translations/messages.ru.yml +++ b/Resources/translations/messages.ru.yml @@ -5,3 +5,6 @@ boolean: flash: error: form: При обработке формы были обнаружены ошибки. Исправьте их и повторите отправку + +price: + default: '%price% руб.' diff --git a/Resources/translations/messages.zh.yml b/Resources/translations/messages.zh.yml index e0b6bbf..8e41261 100644 --- a/Resources/translations/messages.zh.yml +++ b/Resources/translations/messages.zh.yml @@ -4,3 +4,5 @@ boolean: flash: error: form: '形成的错误检测。 解决这些问题,并重新提交形式' +price: + default: ¥%price% diff --git a/Resources/views/price.html.twig b/Resources/views/price.html.twig new file mode 100644 index 0000000..5ec85ab --- /dev/null +++ b/Resources/views/price.html.twig @@ -0,0 +1 @@ +{% trans with {'%price%': price|number_format(0, null, ' ')} %}price.default{% endtrans %} From 066e8999331267ded3e12915289b456e86725381 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 6 Dec 2018 09:48:43 +0300 Subject: [PATCH 038/192] Add "format_price" Twig filter. --- Resources/config/price.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/config/price.yml b/Resources/config/price.yml index 7cb435c..a0889ab 100644 --- a/Resources/config/price.yml +++ b/Resources/config/price.yml @@ -4,6 +4,9 @@ parameters: darvin_utils.price.twig_extension.class: Darvin\Utils\Twig\Extension\PriceExtension services: + _defaults: + public: true + darvin_utils.price.formatter: class: "%darvin_utils.price.formatter.class%" arguments: From 7c35ca98048511d1efb81ce4527cf09c1dfcc65e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 10 Dec 2018 14:19:43 +0300 Subject: [PATCH 039/192] Move translatable event subscriber from admin bundle. --- DarvinUtilsBundle.php | 4 ++- .../ReplaceTranslatableSubscriberPass.php | 36 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 51a7528..61f03a1 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -14,6 +14,7 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; +use Darvin\UtilsBundle\DependencyInjection\Compiler\ReplaceTranslatableSubscriberPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -33,6 +34,7 @@ public function build(ContainerBuilder $container): void ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddSlugHandlersPass()) ->addCompilerPass(new CreateServiceProvidersPass()) - ->addCompilerPass(new OverrideEntitiesPass()); + ->addCompilerPass(new OverrideEntitiesPass()) + ->addCompilerPass(new ReplaceTranslatableSubscriberPass()); } } diff --git a/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php b/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php new file mode 100644 index 0000000..1ecc537 --- /dev/null +++ b/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php @@ -0,0 +1,36 @@ + + * @copyright Copyright (c) 2017, Darvin Studio + * @link https://www.darvin-studio.ru + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Darvin\UtilsBundle\DependencyInjection\Compiler; + +use Darvin\Utils\EventListener\TranslatableSubscriber; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Replace translatable event subscriber compiler pass + */ +class ReplaceTranslatableSubscriberPass implements CompilerPassInterface +{ + private const ID = 'knp.doctrine_behaviors.translatable_subscriber'; + + /** + * {@inheritdoc} + */ + public function process(ContainerBuilder $container): void + { + if ($container->hasDefinition(static::ID)) { + $container->getDefinition(static::ID) + ->setClass(TranslatableSubscriber::class) + ->addArgument(new Reference('darvin_utils.orm.entity_resolver')); + } + } +} From d88d9c44a94b86b5048d88e5d47ca5f4b60705db Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 13 Dec 2018 16:34:57 +0300 Subject: [PATCH 040/192] "static" => "self". --- .../Compiler/ReplaceTranslatableSubscriberPass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php b/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php index 1ecc537..00bad3a 100644 --- a/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php +++ b/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php @@ -27,8 +27,8 @@ class ReplaceTranslatableSubscriberPass implements CompilerPassInterface */ public function process(ContainerBuilder $container): void { - if ($container->hasDefinition(static::ID)) { - $container->getDefinition(static::ID) + if ($container->hasDefinition(self::ID)) { + $container->getDefinition(self::ID) ->setClass(TranslatableSubscriber::class) ->addArgument(new Reference('darvin_utils.orm.entity_resolver')); } From 1d08445c8682c032d6b4518068f5219f6c04ab6d Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 21 Dec 2018 11:50:01 +0300 Subject: [PATCH 041/192] Check if Doctrine extensions bundle is enabled. --- DependencyInjection/DarvinUtilsExtension.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index dad57d2..7b279a6 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -58,7 +58,6 @@ public function load(array $configs, ContainerBuilder $container) 'sluggable', 'stringifier', 'transliteratable', - 'tree', 'user', ] as $resource) { $loader->load($resource.'.yml'); @@ -76,6 +75,12 @@ public function load(array $configs, ContainerBuilder $container) if ($config['mailer']['enabled']) { $loader->load('mailer.yml'); } + + $bundles = $container->getParameter('kernel.bundles'); + + if (isset($bundles['StofDoctrineExtensionsBundle'])) { + $loader->load('tree.yml'); + } } /** From 7497a8b9ae53ac7e6907509a3d80ec79918da677 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Jan 2019 10:18:40 +0300 Subject: [PATCH 042/192] Use Symfony route internationalization. --- Resources/config/routing.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index eecf3f2..414aa08 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -22,6 +22,8 @@ services: class: "%darvin_utils.routing.route_manager.cached.class%" public: false arguments: + - "@darvin_utils.locale.provider" - "@router.default" - "%kernel.cache_dir%/darvin/utils/routes.php" - "%kernel.debug%" + - "%locales%" From 537c2d83afbe93062a6f8cf4827137510ec6bbc0 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Jan 2019 11:20:03 +0300 Subject: [PATCH 043/192] Pass name to config tree builder. --- DependencyInjection/Configuration.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index caec623..ef3b21c 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -25,8 +25,10 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('darvin_utils'); + $treeBuilder = new TreeBuilder('darvin_utils'); + + /** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode */ + $rootNode = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for From f170f3c008e4f52ebef5b7e986c889ca72b3b012 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 16 Jan 2019 10:51:02 +0300 Subject: [PATCH 044/192] Require Swiftmailer bundle in order to use mailer service. --- DependencyInjection/Configuration.php | 3 +-- DependencyInjection/DarvinUtilsExtension.php | 14 +++++++++++--- Resources/config/mailer.yml | 2 +- composer.json | 3 +++ 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index ef3b21c..f2fcc5d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -35,8 +35,7 @@ public function getConfigTreeBuilder() // more information on that topic. $rootNode ->children() - ->arrayNode('mailer') - ->canBeEnabled() + ->arrayNode('mailer')->canBeEnabled() ->children() ->scalarNode('charset')->defaultValue('utf-8')->cannotBeEmpty()->end() ->scalarNode('from')->isRequired()->end() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index af49b48..5d94f94 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -30,12 +30,12 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac */ public function load(array $configs, ContainerBuilder $container): void { - $config = $this->processConfiguration(new Configuration(), $configs); + $bundles = $container->getParameter('kernel.bundles'); + $config = $this->processConfiguration(new Configuration(), $configs); + $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); (new ConfigInjector())->inject($config, $container, $this->getAlias()); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - foreach ([ 'anti_spam', 'cloner', @@ -72,6 +72,14 @@ public function load(array $configs, ContainerBuilder $container): void } } if ($config['mailer']['enabled']) { + if (!isset($bundles['SwiftmailerBundle'])) { + throw new \RuntimeException(<<load('mailer.yml'); } diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index b3f1660..3008f57 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -18,4 +18,4 @@ services: - "%darvin_utils.mailer.from%" - "%darvin_utils.mailer.from_name%" - "%darvin_utils.mailer.prepend_host%" - - "@?mailer" + - "@mailer" diff --git a/composer.json b/composer.json index b7bf084..93f0992 100644 --- a/composer.json +++ b/composer.json @@ -15,6 +15,9 @@ "twig/extensions": "^1.5", "darvinstudio/darvin-utils": "^7" }, + "suggest": { + "symfony/swiftmailer-bundle": "Allows to use mailer" + }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } } From a828b5703b74ae2cc3bb7eb0b50495a27e90f435 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 16 Jan 2019 11:20:40 +0300 Subject: [PATCH 045/192] Reorganize configuration. --- DependencyInjection/Configuration.php | 14 ++++++++------ Resources/config/mailer.yml | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f2fcc5d..305c0dd 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -27,20 +27,22 @@ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('darvin_utils'); - /** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $rootNode */ - $rootNode = $treeBuilder->getRootNode(); + /** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $root */ + $root = $treeBuilder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for // more information on that topic. - $rootNode + $root ->children() ->arrayNode('mailer')->canBeEnabled() ->children() ->scalarNode('charset')->defaultValue('utf-8')->cannotBeEmpty()->end() - ->scalarNode('from')->isRequired()->end() - ->scalarNode('from_name')->defaultNull()->end() - ->booleanNode('prepend_host')->defaultTrue(); + ->booleanNode('add_host')->defaultFalse()->end() + ->arrayNode('from')->isRequired() + ->children() + ->scalarNode('email')->isRequired()->end() + ->scalarNode('name')->defaultNull(); return $treeBuilder; } diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yml index 3008f57..1facc8f 100644 --- a/Resources/config/mailer.yml +++ b/Resources/config/mailer.yml @@ -15,7 +15,7 @@ services: - "@translator" - "%darvin_utils.mailer.translation_domain%" - "%darvin_utils.mailer.charset%" - - "%darvin_utils.mailer.from%" - - "%darvin_utils.mailer.from_name%" - - "%darvin_utils.mailer.prepend_host%" + - "%darvin_utils.mailer.from.email%" + - "%darvin_utils.mailer.from.name%" + - "%darvin_utils.mailer.add_host%" - "@mailer" From d11f2a73059aca7013c4195b8a18f7a6986eae62 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 17 Jan 2019 09:22:30 +0300 Subject: [PATCH 046/192] .yml => .yaml --- DependencyInjection/DarvinUtilsExtension.php | 12 ++++++------ Resources/config/{anti_spam.yml => anti_spam.yaml} | 0 Resources/config/app/{doctrine.yml => doctrine.yaml} | 0 ..._extensions.yml => stof_doctrine_extensions.yaml} | 0 Resources/config/{cloner.yml => cloner.yaml} | 0 .../config/{custom_object.yml => custom_object.yaml} | 0 .../config/{default_value.yml => default_value.yaml} | 0 .../dev/{data_fixture.yml => data_fixture.yaml} | 0 .../config/dev/{translation.yml => translation.yaml} | 0 Resources/config/{flash.yml => flash.yaml} | 0 Resources/config/{form.yml => form.yaml} | 0 Resources/config/{homepage.yml => homepage.yaml} | 0 Resources/config/{intl.yml => intl.yaml} | 0 Resources/config/{locale.yml => locale.yaml} | 0 Resources/config/{mailer.yml => mailer.yaml} | 0 Resources/config/{mapping.yml => mapping.yaml} | 0 Resources/config/{new_object.yml => new_object.yaml} | 0 .../config/{object_namer.yml => object_namer.yaml} | 0 Resources/config/{orm.yml => orm.yaml} | 0 Resources/config/{price.yml => price.yaml} | 0 Resources/config/{routing.yml => routing.yaml} | 0 Resources/config/{security.yml => security.yaml} | 0 Resources/config/{service.yml => service.yaml} | 0 Resources/config/{sluggable.yml => sluggable.yaml} | 0 .../config/{stringifier.yml => stringifier.yaml} | 0 .../{transliteratable.yml => transliteratable.yaml} | 0 Resources/config/{tree.yml => tree.yaml} | 0 Resources/config/{user.yml => user.yaml} | 0 .../{messages.ar.yml => messages.ar.yaml} | 0 .../{messages.en.yml => messages.en.yaml} | 0 .../{messages.fr.yml => messages.fr.yaml} | 0 .../{messages.ru.yml => messages.ru.yaml} | 0 .../{messages.zh.yml => messages.zh.yaml} | 0 33 files changed, 6 insertions(+), 6 deletions(-) rename Resources/config/{anti_spam.yml => anti_spam.yaml} (100%) rename Resources/config/app/{doctrine.yml => doctrine.yaml} (100%) rename Resources/config/app/{stof_doctrine_extensions.yml => stof_doctrine_extensions.yaml} (100%) rename Resources/config/{cloner.yml => cloner.yaml} (100%) rename Resources/config/{custom_object.yml => custom_object.yaml} (100%) rename Resources/config/{default_value.yml => default_value.yaml} (100%) rename Resources/config/dev/{data_fixture.yml => data_fixture.yaml} (100%) rename Resources/config/dev/{translation.yml => translation.yaml} (100%) rename Resources/config/{flash.yml => flash.yaml} (100%) rename Resources/config/{form.yml => form.yaml} (100%) rename Resources/config/{homepage.yml => homepage.yaml} (100%) rename Resources/config/{intl.yml => intl.yaml} (100%) rename Resources/config/{locale.yml => locale.yaml} (100%) rename Resources/config/{mailer.yml => mailer.yaml} (100%) rename Resources/config/{mapping.yml => mapping.yaml} (100%) rename Resources/config/{new_object.yml => new_object.yaml} (100%) rename Resources/config/{object_namer.yml => object_namer.yaml} (100%) rename Resources/config/{orm.yml => orm.yaml} (100%) rename Resources/config/{price.yml => price.yaml} (100%) rename Resources/config/{routing.yml => routing.yaml} (100%) rename Resources/config/{security.yml => security.yaml} (100%) rename Resources/config/{service.yml => service.yaml} (100%) rename Resources/config/{sluggable.yml => sluggable.yaml} (100%) rename Resources/config/{stringifier.yml => stringifier.yaml} (100%) rename Resources/config/{transliteratable.yml => transliteratable.yaml} (100%) rename Resources/config/{tree.yml => tree.yaml} (100%) rename Resources/config/{user.yml => user.yaml} (100%) rename Resources/translations/{messages.ar.yml => messages.ar.yaml} (100%) rename Resources/translations/{messages.en.yml => messages.en.yaml} (100%) rename Resources/translations/{messages.fr.yml => messages.fr.yaml} (100%) rename Resources/translations/{messages.ru.yml => messages.ru.yaml} (100%) rename Resources/translations/{messages.zh.yml => messages.zh.yaml} (100%) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 5d94f94..33b02cf 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -59,16 +59,16 @@ public function load(array $configs, ContainerBuilder $container): void 'transliteratable', 'user', ] as $resource) { - $loader->load($resource.'.yml'); + $loader->load($resource.'.yaml'); } if ('dev' === $container->getParameter('kernel.environment')) { foreach ([ 'translation', ] as $resource) { - $loader->load(sprintf('dev/%s.yml', $resource)); + $loader->load(sprintf('dev/%s.yaml', $resource)); } if (interface_exists('Doctrine\Common\DataFixtures\FixtureInterface')) { - $loader->load('dev/data_fixture.yml'); + $loader->load('dev/data_fixture.yaml'); } } if ($config['mailer']['enabled']) { @@ -80,13 +80,13 @@ public function load(array $configs, ContainerBuilder $container): void ); } - $loader->load('mailer.yml'); + $loader->load('mailer.yaml'); } $bundles = $container->getParameter('kernel.bundles'); if (isset($bundles['StofDoctrineExtensionsBundle'])) { - $loader->load('tree.yml'); + $loader->load('tree.yaml'); } } @@ -102,7 +102,7 @@ public function prepend(ContainerBuilder $container): void 'stof_doctrine_extensions', ] as $extension) { if ($container->hasExtension($extension)) { - $container->prependExtensionConfig($extension, Yaml::parse(file_get_contents($fileLocator->locate($extension.'.yml')))[$extension]); + $container->prependExtensionConfig($extension, Yaml::parse(file_get_contents($fileLocator->locate($extension.'.yaml')))[$extension]); } } } diff --git a/Resources/config/anti_spam.yml b/Resources/config/anti_spam.yaml similarity index 100% rename from Resources/config/anti_spam.yml rename to Resources/config/anti_spam.yaml diff --git a/Resources/config/app/doctrine.yml b/Resources/config/app/doctrine.yaml similarity index 100% rename from Resources/config/app/doctrine.yml rename to Resources/config/app/doctrine.yaml diff --git a/Resources/config/app/stof_doctrine_extensions.yml b/Resources/config/app/stof_doctrine_extensions.yaml similarity index 100% rename from Resources/config/app/stof_doctrine_extensions.yml rename to Resources/config/app/stof_doctrine_extensions.yaml diff --git a/Resources/config/cloner.yml b/Resources/config/cloner.yaml similarity index 100% rename from Resources/config/cloner.yml rename to Resources/config/cloner.yaml diff --git a/Resources/config/custom_object.yml b/Resources/config/custom_object.yaml similarity index 100% rename from Resources/config/custom_object.yml rename to Resources/config/custom_object.yaml diff --git a/Resources/config/default_value.yml b/Resources/config/default_value.yaml similarity index 100% rename from Resources/config/default_value.yml rename to Resources/config/default_value.yaml diff --git a/Resources/config/dev/data_fixture.yml b/Resources/config/dev/data_fixture.yaml similarity index 100% rename from Resources/config/dev/data_fixture.yml rename to Resources/config/dev/data_fixture.yaml diff --git a/Resources/config/dev/translation.yml b/Resources/config/dev/translation.yaml similarity index 100% rename from Resources/config/dev/translation.yml rename to Resources/config/dev/translation.yaml diff --git a/Resources/config/flash.yml b/Resources/config/flash.yaml similarity index 100% rename from Resources/config/flash.yml rename to Resources/config/flash.yaml diff --git a/Resources/config/form.yml b/Resources/config/form.yaml similarity index 100% rename from Resources/config/form.yml rename to Resources/config/form.yaml diff --git a/Resources/config/homepage.yml b/Resources/config/homepage.yaml similarity index 100% rename from Resources/config/homepage.yml rename to Resources/config/homepage.yaml diff --git a/Resources/config/intl.yml b/Resources/config/intl.yaml similarity index 100% rename from Resources/config/intl.yml rename to Resources/config/intl.yaml diff --git a/Resources/config/locale.yml b/Resources/config/locale.yaml similarity index 100% rename from Resources/config/locale.yml rename to Resources/config/locale.yaml diff --git a/Resources/config/mailer.yml b/Resources/config/mailer.yaml similarity index 100% rename from Resources/config/mailer.yml rename to Resources/config/mailer.yaml diff --git a/Resources/config/mapping.yml b/Resources/config/mapping.yaml similarity index 100% rename from Resources/config/mapping.yml rename to Resources/config/mapping.yaml diff --git a/Resources/config/new_object.yml b/Resources/config/new_object.yaml similarity index 100% rename from Resources/config/new_object.yml rename to Resources/config/new_object.yaml diff --git a/Resources/config/object_namer.yml b/Resources/config/object_namer.yaml similarity index 100% rename from Resources/config/object_namer.yml rename to Resources/config/object_namer.yaml diff --git a/Resources/config/orm.yml b/Resources/config/orm.yaml similarity index 100% rename from Resources/config/orm.yml rename to Resources/config/orm.yaml diff --git a/Resources/config/price.yml b/Resources/config/price.yaml similarity index 100% rename from Resources/config/price.yml rename to Resources/config/price.yaml diff --git a/Resources/config/routing.yml b/Resources/config/routing.yaml similarity index 100% rename from Resources/config/routing.yml rename to Resources/config/routing.yaml diff --git a/Resources/config/security.yml b/Resources/config/security.yaml similarity index 100% rename from Resources/config/security.yml rename to Resources/config/security.yaml diff --git a/Resources/config/service.yml b/Resources/config/service.yaml similarity index 100% rename from Resources/config/service.yml rename to Resources/config/service.yaml diff --git a/Resources/config/sluggable.yml b/Resources/config/sluggable.yaml similarity index 100% rename from Resources/config/sluggable.yml rename to Resources/config/sluggable.yaml diff --git a/Resources/config/stringifier.yml b/Resources/config/stringifier.yaml similarity index 100% rename from Resources/config/stringifier.yml rename to Resources/config/stringifier.yaml diff --git a/Resources/config/transliteratable.yml b/Resources/config/transliteratable.yaml similarity index 100% rename from Resources/config/transliteratable.yml rename to Resources/config/transliteratable.yaml diff --git a/Resources/config/tree.yml b/Resources/config/tree.yaml similarity index 100% rename from Resources/config/tree.yml rename to Resources/config/tree.yaml diff --git a/Resources/config/user.yml b/Resources/config/user.yaml similarity index 100% rename from Resources/config/user.yml rename to Resources/config/user.yaml diff --git a/Resources/translations/messages.ar.yml b/Resources/translations/messages.ar.yaml similarity index 100% rename from Resources/translations/messages.ar.yml rename to Resources/translations/messages.ar.yaml diff --git a/Resources/translations/messages.en.yml b/Resources/translations/messages.en.yaml similarity index 100% rename from Resources/translations/messages.en.yml rename to Resources/translations/messages.en.yaml diff --git a/Resources/translations/messages.fr.yml b/Resources/translations/messages.fr.yaml similarity index 100% rename from Resources/translations/messages.fr.yml rename to Resources/translations/messages.fr.yaml diff --git a/Resources/translations/messages.ru.yml b/Resources/translations/messages.ru.yaml similarity index 100% rename from Resources/translations/messages.ru.yml rename to Resources/translations/messages.ru.yaml diff --git a/Resources/translations/messages.zh.yml b/Resources/translations/messages.zh.yaml similarity index 100% rename from Resources/translations/messages.zh.yml rename to Resources/translations/messages.zh.yaml From fdb30568c427eb3db083adb12bda9ded7bfe69fd Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 17 Jan 2019 16:11:29 +0300 Subject: [PATCH 047/192] Use DI tools in extension. --- DependencyInjection/DarvinUtilsExtension.php | 64 ++++++++------------ 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 33b02cf..c8ccd67 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -11,12 +11,11 @@ namespace Darvin\UtilsBundle\DependencyInjection; use Darvin\Utils\DependencyInjection\ConfigInjector; -use Symfony\Component\Config\FileLocator; +use Darvin\Utils\DependencyInjection\ConfigLoader; +use Darvin\Utils\DependencyInjection\ExtensionConfigurator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; -use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -use Symfony\Component\Yaml\Yaml; /** * This is the class that loads and manages your bundle configuration @@ -32,11 +31,10 @@ public function load(array $configs, ContainerBuilder $container): void { $bundles = $container->getParameter('kernel.bundles'); $config = $this->processConfiguration(new Configuration(), $configs); - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); (new ConfigInjector())->inject($config, $container, $this->getAlias()); - foreach ([ + (new ConfigLoader($container, __DIR__.'/../Resources/config'))->load([ 'anti_spam', 'cloner', 'custom_object', @@ -58,36 +56,30 @@ public function load(array $configs, ContainerBuilder $container): void 'stringifier', 'transliteratable', 'user', - ] as $resource) { - $loader->load($resource.'.yaml'); - } - if ('dev' === $container->getParameter('kernel.environment')) { - foreach ([ - 'translation', - ] as $resource) { - $loader->load(sprintf('dev/%s.yaml', $resource)); - } - if (interface_exists('Doctrine\Common\DataFixtures\FixtureInterface')) { - $loader->load('dev/data_fixture.yaml'); - } - } - if ($config['mailer']['enabled']) { - if (!isset($bundles['SwiftmailerBundle'])) { - throw new \RuntimeException(<< ['bundle' => 'StofDoctrineExtensionsBundle'], + + 'dev/translation' => ['env' => 'dev'], + + 'dev/data_fixture' => ['env' => 'dev', 'callback' => function () { + return interface_exists('Doctrine\Common\DataFixtures\FixtureInterface'); + }], + + 'mailer' => ['callback' => function () use ($bundles, $config) { + if (!$config['mailer']['enabled']) { + return false; + } + if (!isset($bundles['SwiftmailerBundle'])) { + throw new \RuntimeException(<<load('mailer.yaml'); - } - - $bundles = $container->getParameter('kernel.bundles'); - - if (isset($bundles['StofDoctrineExtensionsBundle'])) { - $loader->load('tree.yaml'); - } + return true; + }], + ]); } /** @@ -95,15 +87,9 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { - $fileLocator = new FileLocator(__DIR__.'/../Resources/config/app'); - - foreach ([ + (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', 'stof_doctrine_extensions', - ] as $extension) { - if ($container->hasExtension($extension)) { - $container->prependExtensionConfig($extension, Yaml::parse(file_get_contents($fileLocator->locate($extension.'.yaml')))[$extension]); - } - } + ]); } } From 8800630e8ecbef3fd1cd9542517291ef15b94d4a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 17 Jan 2019 16:18:19 +0300 Subject: [PATCH 048/192] Pass container to config injector's constructor. --- DependencyInjection/DarvinUtilsExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index c8ccd67..59f4f57 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -32,7 +32,7 @@ public function load(array $configs, ContainerBuilder $container): void $bundles = $container->getParameter('kernel.bundles'); $config = $this->processConfiguration(new Configuration(), $configs); - (new ConfigInjector())->inject($config, $container, $this->getAlias()); + (new ConfigInjector($container))->inject($config, $this->getAlias()); (new ConfigLoader($container, __DIR__.'/../Resources/config'))->load([ 'anti_spam', From 0b153e17f15858d2274da26bb8c2e30c75ae2f79 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 18 Jan 2019 10:30:11 +0300 Subject: [PATCH 049/192] Replace static properties and methods. --- .../Compiler/CreateServiceProvidersPass.php | 51 ++++--------------- 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 71776f7..6cb28b6 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -1,4 +1,4 @@ - * @copyright Copyright (c) 2016-2018, Darvin Studio @@ -19,16 +19,11 @@ */ class CreateServiceProvidersPass implements CompilerPassInterface { - const ID_SUFFIX = '.provider'; + private const ID_SUFFIX = '.provider'; + private const PARENT_ID = 'darvin_utils.service.abstract_provider'; + private const TAG_PROVIDABLE = 'darvin_utils.providable'; - const PARENT_ID = 'darvin_utils.service.abstract_provider'; - - const TAG_PROVIDABLE = 'darvin_utils.providable'; - - /** - * @var array - */ - private static $ids = [ + private const IDS = [ 'darvin_utils.authorization_checker.provider' => 'security.authorization_checker', 'darvin_utils.entity_manager.provider' => 'doctrine.orm.default_entity_manager', 'darvin_utils.object_manager.provider' => 'doctrine.orm.default_entity_manager', @@ -38,40 +33,12 @@ class CreateServiceProvidersPass implements CompilerPassInterface /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { - $this->addServiceProviders($container, self::$ids); + $ids = self::IDS; - $this->createServiceProviders($container, array_keys($container->findTaggedServiceIds(self::TAG_PROVIDABLE))); - } - - /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container DI container - * @param string[] $ids Service IDs - */ - public function createServiceProviders(ContainerBuilder $container, array $ids) - { - if (empty($ids)) { - return; - } - - $ids = array_combine(array_map(function ($id) { - return $id.self::ID_SUFFIX; - }, $ids), $ids); - - $this->addServiceProviders($container, $ids); - } - - /** - * @param \Symfony\Component\DependencyInjection\ContainerBuilder $container DI container - * @param array $ids { string providerId => string serviceId } - * - * @throws \RuntimeException - */ - private function addServiceProviders(ContainerBuilder $container, array $ids) - { - if (empty($ids)) { - return; + foreach (array_keys($container->findTaggedServiceIds(self::TAG_PROVIDABLE)) as $id) { + $ids[$id.self::ID_SUFFIX] = $id; } $definitions = []; From 295120f42333a8c95941c99b90e05ec48a24af04 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 25 Jan 2019 09:32:54 +0300 Subject: [PATCH 050/192] Add Yandex.Translate API key configuration parameter. --- DependencyInjection/Configuration.php | 1 + Resources/config/dev/translation.yaml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 305c0dd..d53d132 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -35,6 +35,7 @@ public function getConfigTreeBuilder() // more information on that topic. $root ->children() + ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('mailer')->canBeEnabled() ->children() ->scalarNode('charset')->defaultValue('utf-8')->cannotBeEmpty()->end() diff --git a/Resources/config/dev/translation.yaml b/Resources/config/dev/translation.yaml index caa26ac..a35491f 100644 --- a/Resources/config/dev/translation.yaml +++ b/Resources/config/dev/translation.yaml @@ -24,6 +24,6 @@ services: class: "%darvin_utils.translation.translate_command.class%" arguments: - "%darvin_utils.translation.translate_command.name%" - - "@=service('service_container').hasParameter('yandex_translate_api_key') ? parameter('yandex_translate_api_key') : null" + - "%darvin_utils.yandex_translate_api_key%" tags: - { name: console.command } From 415c54ca88f2ef4d6e88a6207c1ed5bd6f4b566e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 1 Feb 2019 16:30:34 +0300 Subject: [PATCH 051/192] Refactor mailer. --- DependencyInjection/Configuration.php | 16 ++++++++-------- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/app/darvin_utils.yaml | 5 +++++ Resources/config/mailer.yaml | 7 ++----- 4 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 Resources/config/app/darvin_utils.yaml diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index d53d132..e83b8ae 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,7 +1,7 @@ - - * @copyright Copyright (c) 2015-2018, Darvin Studio + * @copyright Copyright (c) 2015-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE @@ -23,12 +23,12 @@ class Configuration implements ConfigurationInterface /** * {@inheritdoc} */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder('darvin_utils'); + $builder = new TreeBuilder('darvin_utils'); /** @var \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $root */ - $root = $treeBuilder->getRootNode(); + $root = $builder->getRootNode(); // Here you should define the parameters that are allowed to // configure your bundle. See the documentation linked above for @@ -38,13 +38,13 @@ public function getConfigTreeBuilder() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('mailer')->canBeEnabled() ->children() - ->scalarNode('charset')->defaultValue('utf-8')->cannotBeEmpty()->end() ->booleanNode('add_host')->defaultFalse()->end() + ->arrayNode('defaults')->useAttributeAsKey('name')->prototype('variable')->end()->end() ->arrayNode('from')->isRequired() ->children() - ->scalarNode('email')->isRequired()->end() + ->scalarNode('email')->isRequired()->cannotBeEmpty()->end() ->scalarNode('name')->defaultNull(); - return $treeBuilder; + return $builder; } } diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 59f4f57..b855fc2 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -88,6 +88,7 @@ public function load(array $configs, ContainerBuilder $container): void public function prepend(ContainerBuilder $container): void { (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ + 'darvin_utils', 'doctrine', 'stof_doctrine_extensions', ]); diff --git a/Resources/config/app/darvin_utils.yaml b/Resources/config/app/darvin_utils.yaml new file mode 100644 index 0000000..e8b0ed9 --- /dev/null +++ b/Resources/config/app/darvin_utils.yaml @@ -0,0 +1,5 @@ +darvin_utils: + mailer: + defaults: + charset: utf-8 + content_type: text/html diff --git a/Resources/config/mailer.yaml b/Resources/config/mailer.yaml index 1facc8f..44f18cc 100644 --- a/Resources/config/mailer.yaml +++ b/Resources/config/mailer.yaml @@ -1,8 +1,6 @@ parameters: darvin_utils.mailer.class: Darvin\Utils\Mailer\Mailer - darvin_utils.mailer.translation_domain: email - services: _defaults: public: true @@ -13,9 +11,8 @@ services: - "@logger" - "@request_stack" - "@translator" - - "%darvin_utils.mailer.translation_domain%" - - "%darvin_utils.mailer.charset%" + - "%darvin_utils.mailer.defaults%" + - "%darvin_utils.mailer.add_host%" - "%darvin_utils.mailer.from.email%" - "%darvin_utils.mailer.from.name%" - - "%darvin_utils.mailer.add_host%" - "@mailer" From c7992b4380df71735de11396ffd5d28ac806438b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 1 Feb 2019 16:39:57 +0300 Subject: [PATCH 052/192] Refactor mailer. --- Resources/doc/mailer.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Resources/doc/mailer.md b/Resources/doc/mailer.md index a6bf275..5bea874 100644 --- a/Resources/doc/mailer.md +++ b/Resources/doc/mailer.md @@ -10,15 +10,7 @@ Mailer - сервис отправки электронной почты. Пример использования: ```php -$this->getContainer()->get('darvin_utils.mailer')->send( - 'email.hello.subject', - 'Hello, world!', - 'world@example.com', - array( - '%name%' => 'world', - ), - 'text/plain' -); +$this->getContainer()->get('darvin_utils.mailer')->send('email.hello.subject', 'Hello, world!', 'world@example.com'); ``` Особенности: From e06e84d791203b73bedd9cd45ca09b89fd02ab28 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 4 Feb 2019 09:32:36 +0300 Subject: [PATCH 053/192] Implement template mailer. --- Resources/config/mailer.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Resources/config/mailer.yaml b/Resources/config/mailer.yaml index 44f18cc..ac644c5 100644 --- a/Resources/config/mailer.yaml +++ b/Resources/config/mailer.yaml @@ -1,6 +1,8 @@ parameters: darvin_utils.mailer.class: Darvin\Utils\Mailer\Mailer + darvin_utils.mailer.template.class: Darvin\Utils\Mailer\TemplateMailer + services: _defaults: public: true @@ -16,3 +18,9 @@ services: - "%darvin_utils.mailer.from.email%" - "%darvin_utils.mailer.from.name%" - "@mailer" + + darvin_utils.mailer.template: + class: "%darvin_utils.mailer.template.class%" + arguments: + - "@darvin_utils.mailer" + - "@darvin_utils.templating.provider" From 63f0a788fbeb5e35f7c74d6da42d5a2d3356478b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 5 Feb 2019 10:37:41 +0300 Subject: [PATCH 054/192] Remove default type="string" from mapping annotations. --- Resources/doc/default_value.md | 4 ++-- Resources/doc/sluggable.md | 4 ++-- Resources/doc/transliteratable.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Resources/doc/default_value.md b/Resources/doc/default_value.md index c5c4d89..9b4abe8 100644 --- a/Resources/doc/default_value.md +++ b/Resources/doc/default_value.md @@ -29,7 +29,7 @@ class Page /** * @var string * - * @ORM\Column(type="string") + * @ORM\Column * @Assert\NotBlank */ private $title; @@ -37,7 +37,7 @@ class Page /** * @var string * - * @ORM\Column(type="string") + * @ORM\Column * @Darvin\DefaultValue(sourcePropertyPath="title") */ private $metaTitle; diff --git a/Resources/doc/sluggable.md b/Resources/doc/sluggable.md index 779678b..3785be0 100644 --- a/Resources/doc/sluggable.md +++ b/Resources/doc/sluggable.md @@ -45,7 +45,7 @@ class Page /** * @var string * - * @ORM\Column(type="string") + * @ORM\Column * @Assert\NotBlank */ private $title; @@ -53,7 +53,7 @@ class Page /** * @var string * - * @ORM\Column(type="string") + * @ORM\Column * @Darvin\Slug(sourcePropertyPaths={"category.slug", "title"}, separator="/") */ private $slug; diff --git a/Resources/doc/transliteratable.md b/Resources/doc/transliteratable.md index af357e9..eaa31e7 100644 --- a/Resources/doc/transliteratable.md +++ b/Resources/doc/transliteratable.md @@ -31,7 +31,7 @@ class Page /** * @var string * - * @ORM\Column(type="string") + * @ORM\Column * @Darvin\Transliteratable(sanitize=true, allowedSymbols={"_"}, separator="-") */ private $slug; From 1461bf6cc7877df710aa1ae62a73e13297dfe638 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 12 Feb 2019 10:52:00 +0300 Subject: [PATCH 055/192] Move translatable event subscriber to the content bundle. --- DarvinUtilsBundle.php | 4 +-- .../ReplaceTranslatableSubscriberPass.php | 36 ------------------- 2 files changed, 1 insertion(+), 39 deletions(-) delete mode 100644 DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 61f03a1..51a7528 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -14,7 +14,6 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; -use Darvin\UtilsBundle\DependencyInjection\Compiler\ReplaceTranslatableSubscriberPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -34,7 +33,6 @@ public function build(ContainerBuilder $container): void ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddSlugHandlersPass()) ->addCompilerPass(new CreateServiceProvidersPass()) - ->addCompilerPass(new OverrideEntitiesPass()) - ->addCompilerPass(new ReplaceTranslatableSubscriberPass()); + ->addCompilerPass(new OverrideEntitiesPass()); } } diff --git a/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php b/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php deleted file mode 100644 index 00bad3a..0000000 --- a/DependencyInjection/Compiler/ReplaceTranslatableSubscriberPass.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @copyright Copyright (c) 2017, Darvin Studio - * @link https://www.darvin-studio.ru - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Darvin\UtilsBundle\DependencyInjection\Compiler; - -use Darvin\Utils\EventListener\TranslatableSubscriber; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; - -/** - * Replace translatable event subscriber compiler pass - */ -class ReplaceTranslatableSubscriberPass implements CompilerPassInterface -{ - private const ID = 'knp.doctrine_behaviors.translatable_subscriber'; - - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container): void - { - if ($container->hasDefinition(self::ID)) { - $container->getDefinition(self::ID) - ->setClass(TranslatableSubscriber::class) - ->addArgument(new Reference('darvin_utils.orm.entity_resolver')); - } - } -} From ff59c1c082b471757a28da410ae6396a5ae38d0f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 15 Feb 2019 15:09:50 +0300 Subject: [PATCH 056/192] Refactor tagged service IDs sorter. --- DependencyInjection/Compiler/AddSlugHandlersPass.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index 411d7b6..6fd6add 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -1,7 +1,7 @@ - - * @copyright Copyright (c) 2015-2018, Darvin Studio + * @copyright Copyright (c) 2015-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE @@ -23,15 +23,11 @@ class AddSlugHandlersPass implements CompilerPassInterface /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { - $ids = $container->findTaggedServiceIds('darvin_utils.slug_handler'); - - (new TaggedServiceIdsSorter())->sort($ids); - $manager = $container->getDefinition('darvin_utils.sluggable.manager.entity'); - foreach (array_keys($ids) as $id) { + foreach (array_keys((new TaggedServiceIdsSorter())->sort($container->findTaggedServiceIds('darvin_utils.slug_handler'))) as $id) { $manager->addMethodCall('addSlugHandler', [new Reference($id)]); } } From 0feaeecc520ee65c4e55000837257e63c66702f3 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 15 Feb 2019 15:24:51 +0300 Subject: [PATCH 057/192] Fix service sorting. --- DependencyInjection/Compiler/AddSlugHandlersPass.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index 6fd6add..f144498 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -26,8 +26,9 @@ class AddSlugHandlersPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { $manager = $container->getDefinition('darvin_utils.sluggable.manager.entity'); + $ids = $container->findTaggedServiceIds('darvin_utils.slug_handler'); - foreach (array_keys((new TaggedServiceIdsSorter())->sort($container->findTaggedServiceIds('darvin_utils.slug_handler'))) as $id) { + foreach (array_keys((new TaggedServiceIdsSorter())->sort($ids)) as $id) { $manager->addMethodCall('addSlugHandler', [new Reference($id)]); } } From ad0c268d0e48e6aeea95720f9e3eb52c07a2fe46 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 25 Feb 2019 13:19:32 +0300 Subject: [PATCH 058/192] Fix title case service URL. --- Resources/config/dev/translation.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/dev/translation.yaml b/Resources/config/dev/translation.yaml index a35491f..dd67079 100644 --- a/Resources/config/dev/translation.yaml +++ b/Resources/config/dev/translation.yaml @@ -1,7 +1,7 @@ parameters: darvin_utils.translation.title_case_command.class: Darvin\Utils\Command\TitleCaseTranslationsCommand darvin_utils.translation.title_case_command.name: darvin:utils:translations:title-case - darvin_utils.translation.title_case_command.base_url: http://brettterpstra.com + darvin_utils.translation.title_case_command.base_url: https://brettterpstra.com darvin_utils.translation.title_case_command.http_timeout: 30 darvin_utils.translation.translate_command.class: Darvin\Utils\Command\TranslateTranslationsCommand From 54c890c79f4d051df3f38f2e0fee9ef6fcd99e6e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 27 Feb 2019 08:55:14 +0300 Subject: [PATCH 059/192] Add strict transliterator. --- CHANGELOG.md | 9 +++++++++ DependencyInjection/Configuration.php | 1 + DependencyInjection/DarvinUtilsExtension.php | 5 +++++ Resources/config/transliteratable.yml | 13 ++++++++++--- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c253ee9..98cc588 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,3 +34,12 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 6.4.7: Force make services public by default. 6.5.0: Add "format_price" Twig filter. + +6.5.2: Add strict transliterator. + +Use configuration to choose transliterator: + +```yaml +darvin_utils: + transliterator: default # One of "default"; "strict" +``` diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 07bc577..b7f76ea 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -33,6 +33,7 @@ public function getConfigTreeBuilder() // more information on that topic. $rootNode ->children() + ->enumNode('transliterator')->values(['default', 'strict'])->defaultValue('default')->cannotBeEmpty()->end() ->arrayNode('mailer') ->canBeEnabled() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 7b279a6..9e0fd3b 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -81,6 +81,11 @@ public function load(array $configs, ContainerBuilder $container) if (isset($bundles['StofDoctrineExtensionsBundle'])) { $loader->load('tree.yml'); } + + $container->setAlias( + 'darvin_utils.transliteratable.transliterator', + sprintf('darvin_utils.transliteratable.transliterator.%s', $config['transliterator']) + ); } /** diff --git a/Resources/config/transliteratable.yml b/Resources/config/transliteratable.yml index 9316307..cf3fb5e 100644 --- a/Resources/config/transliteratable.yml +++ b/Resources/config/transliteratable.yml @@ -1,7 +1,9 @@ parameters: darvin_utils.transliteratable.subscriber.class: Darvin\Utils\EventListener\TransliteratableSubscriber - darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator + darvin_utils.transliteratable.transliterator.default.class: Darvin\Utils\Transliteratable\DefaultTransliterator + + darvin_utils.transliteratable.transliterator.strict.class: Darvin\Utils\Transliteratable\StrictTransliterator services: _defaults: @@ -17,5 +19,10 @@ services: tags: - { name: doctrine.event_subscriber, priority: 300 } - darvin_utils.transliteratable.transliterator: - class: "%darvin_utils.transliteratable.transliterator.class%" + darvin_utils.transliteratable.transliterator.default: + class: "%darvin_utils.transliteratable.transliterator.default.class%" + public: false + + darvin_utils.transliteratable.transliterator.strict: + class: "%darvin_utils.transliteratable.transliterator.strict.class%" + public: false From e908e180658e44c033c6700faf5cdd31680196f0 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 28 Feb 2019 14:38:00 +0300 Subject: [PATCH 060/192] Add homepage provider service. --- Resources/config/homepage.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Resources/config/homepage.yaml b/Resources/config/homepage.yaml index dae022c..59a5b0e 100644 --- a/Resources/config/homepage.yaml +++ b/Resources/config/homepage.yaml @@ -1,10 +1,19 @@ parameters: + darvin_utils.homepage.dummy_provider.class: Darvin\Utils\Homepage\DummyHomepageProvider + darvin_utils.homepage.dummy_router.class: Darvin\Utils\Homepage\DummyHomepageRouter services: _defaults: public: true + darvin_utils.homepage.provider: + alias: darvin_utils.homepage.dummy_provider + + darvin_utils.homepage.dummy_provider: + class: "%darvin_utils.homepage.dummy_provider.class%" + public: false + darvin_utils.homepage.router: alias: darvin_utils.homepage.dummy_router From 59e98afd9f54e116a6880690b601c6cb1960ef1a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 4 Mar 2019 10:49:35 +0300 Subject: [PATCH 061/192] Replace custom "description" form option with generic one "help". --- Resources/config/form.yaml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Resources/config/form.yaml b/Resources/config/form.yaml index ab6bc15..4894167 100644 --- a/Resources/config/form.yaml +++ b/Resources/config/form.yaml @@ -1,6 +1,4 @@ parameters: - darvin_utils.form.description_extension.class: Darvin\Utils\Form\Extension\DescriptionExtension - darvin_utils.form.integer_type_extension.class: Darvin\Utils\Form\Extension\IntegerTypeExtension darvin_utils.form.number_type_extension.class: Darvin\Utils\Form\Extension\NumberTypeExtension @@ -9,11 +7,6 @@ services: _defaults: public: true - darvin_utils.form.description_extension: - class: "%darvin_utils.form.description_extension.class%" - tags: - - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\FormType } - darvin_utils.form.integer_type_extension: class: "%darvin_utils.form.integer_type_extension.class%" tags: From fa79a7f47b2bdacaa84214cb138c9a65c8aa5682 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 4 Mar 2019 12:25:52 +0300 Subject: [PATCH 062/192] Rename service sorter class. --- DependencyInjection/Compiler/AddSlugHandlersPass.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index f144498..c09646c 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -10,7 +10,7 @@ namespace Darvin\UtilsBundle\DependencyInjection\Compiler; -use Darvin\Utils\DependencyInjection\TaggedServiceIdsSorter; +use Darvin\Utils\DependencyInjection\ServiceSorter; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -26,9 +26,8 @@ class AddSlugHandlersPass implements CompilerPassInterface public function process(ContainerBuilder $container): void { $manager = $container->getDefinition('darvin_utils.sluggable.manager.entity'); - $ids = $container->findTaggedServiceIds('darvin_utils.slug_handler'); - foreach (array_keys((new TaggedServiceIdsSorter())->sort($ids)) as $id) { + foreach (array_keys((new ServiceSorter())->sort($container->findTaggedServiceIds('darvin_utils.slug_handler'))) as $id) { $manager->addMethodCall('addSlugHandler', [new Reference($id)]); } } From 35ff69985a9f3093f77bd3cbeac7985f2e97fba1 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 5 Mar 2019 08:57:59 +0300 Subject: [PATCH 063/192] Update copyrights. --- DarvinUtilsBundle.php | 2 +- DependencyInjection/Compiler/CreateServiceProvidersPass.php | 2 +- DependencyInjection/DarvinUtilsExtension.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 51a7528..f0c7507 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015, Darvin Studio + * @copyright Copyright (c) 2015-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 6cb28b6..ba4998e 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2016-2018, Darvin Studio + * @copyright Copyright (c) 2016-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index b855fc2..23dd428 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2018, Darvin Studio + * @copyright Copyright (c) 2015-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE From a61fd8f2a71c6b2d9625879d226c82d150188f1b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 12 Mar 2019 09:48:29 +0300 Subject: [PATCH 064/192] Add phone validation constraint. --- Resources/translations/validators.ar.yaml | 2 ++ Resources/translations/validators.en.yaml | 2 ++ Resources/translations/validators.fr.yaml | 2 ++ Resources/translations/validators.ru.yaml | 2 ++ Resources/translations/validators.zh.yaml | 2 ++ 5 files changed, 10 insertions(+) create mode 100644 Resources/translations/validators.ar.yaml create mode 100644 Resources/translations/validators.en.yaml create mode 100644 Resources/translations/validators.fr.yaml create mode 100644 Resources/translations/validators.ru.yaml create mode 100644 Resources/translations/validators.zh.yaml diff --git a/Resources/translations/validators.ar.yaml b/Resources/translations/validators.ar.yaml new file mode 100644 index 0000000..d6f4979 --- /dev/null +++ b/Resources/translations/validators.ar.yaml @@ -0,0 +1,2 @@ +phone: + regex: 'هذه القيمة غير صالحة رقم الهاتف.' diff --git a/Resources/translations/validators.en.yaml b/Resources/translations/validators.en.yaml new file mode 100644 index 0000000..33ef3f7 --- /dev/null +++ b/Resources/translations/validators.en.yaml @@ -0,0 +1,2 @@ +phone: + regex: This value is not valid phone number. diff --git a/Resources/translations/validators.fr.yaml b/Resources/translations/validators.fr.yaml new file mode 100644 index 0000000..98b4740 --- /dev/null +++ b/Resources/translations/validators.fr.yaml @@ -0,0 +1,2 @@ +phone: + regex: 'Cette valeur n''est pas valide, numéro de téléphone.' diff --git a/Resources/translations/validators.ru.yaml b/Resources/translations/validators.ru.yaml new file mode 100644 index 0000000..a6fd19d --- /dev/null +++ b/Resources/translations/validators.ru.yaml @@ -0,0 +1,2 @@ +phone: + regex: Номер телефона указан в неверном формате. diff --git a/Resources/translations/validators.zh.yaml b/Resources/translations/validators.zh.yaml new file mode 100644 index 0000000..d2272d1 --- /dev/null +++ b/Resources/translations/validators.zh.yaml @@ -0,0 +1,2 @@ +phone: + regex: 这种价值是不是有效的电话号码。 From 734eee03a5d7c08bbbb612ab3c560fd8f8ff4ae5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 14 Mar 2019 10:18:29 +0300 Subject: [PATCH 065/192] Remove load fixture command. --- DependencyInjection/DarvinUtilsExtension.php | 4 ---- Resources/config/dev/data_fixture.yaml | 16 ---------------- 2 files changed, 20 deletions(-) delete mode 100644 Resources/config/dev/data_fixture.yaml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 23dd428..17cccc8 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -61,10 +61,6 @@ public function load(array $configs, ContainerBuilder $container): void 'dev/translation' => ['env' => 'dev'], - 'dev/data_fixture' => ['env' => 'dev', 'callback' => function () { - return interface_exists('Doctrine\Common\DataFixtures\FixtureInterface'); - }], - 'mailer' => ['callback' => function () use ($bundles, $config) { if (!$config['mailer']['enabled']) { return false; diff --git a/Resources/config/dev/data_fixture.yaml b/Resources/config/dev/data_fixture.yaml deleted file mode 100644 index effbc95..0000000 --- a/Resources/config/dev/data_fixture.yaml +++ /dev/null @@ -1,16 +0,0 @@ -parameters: - darvin_utils.data_fixture.load_command.class: Darvin\Utils\Command\LoadDataFixtureCommand - darvin_utils.data_fixture.load_command.name: darvin:utils:fixture:load - -services: - _defaults: - public: true - - darvin_utils.data_fixture.load_command: - class: "%darvin_utils.data_fixture.load_command.class%" - arguments: - - "%darvin_utils.data_fixture.load_command.name%" - - "@service_container" - - "@doctrine.orm.entity_manager" - tags: - - { name: console.command } From fd628d07a41e054386059c4cf75858db2bf301fe Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 26 Mar 2019 10:18:32 +0300 Subject: [PATCH 066/192] Add "format" option to price formatter. --- CHANGELOG.md | 2 ++ Price/PriceFormatter.php | 4 ++++ Resources/views/price.html.twig | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98cc588..360a5e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,3 +43,5 @@ Use configuration to choose transliterator: darvin_utils: transliterator: default # One of "default"; "strict" ``` + +6.5.3: Add "format" option to price formatter. diff --git a/Price/PriceFormatter.php b/Price/PriceFormatter.php index e033ff6..18386e2 100644 --- a/Price/PriceFormatter.php +++ b/Price/PriceFormatter.php @@ -36,6 +36,10 @@ public function __construct(ServiceProviderInterface $templatingProvider) */ public function format($price, array $options = []) { + if (!isset($options['format'])) { + $options['format'] = 'default'; + } + return $this->getTemplating()->render(isset($options['template']) ? $options['template'] : '@DarvinUtils/price.html.twig', [ 'price' => $price, 'options' => $options, diff --git a/Resources/views/price.html.twig b/Resources/views/price.html.twig index 5ec85ab..e2f9b35 100644 --- a/Resources/views/price.html.twig +++ b/Resources/views/price.html.twig @@ -1 +1 @@ -{% trans with {'%price%': price|number_format(0, null, ' ')} %}price.default{% endtrans %} +{{ ('price.' ~ options.format)|trans({'%price%': price|number_format(0, null, ' ')}) }} From 6acb4cec6b03e48d870c918fc7fda6d0eb5afaf1 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 8 Apr 2019 15:12:27 +0300 Subject: [PATCH 067/192] Add "property()" macro. --- Resources/views/macros.html.twig | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Resources/views/macros.html.twig diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig new file mode 100644 index 0000000..ffa7e04 --- /dev/null +++ b/Resources/views/macros.html.twig @@ -0,0 +1,56 @@ +{% macro property(name, title, value) %} + + {% import _self as that %} + +
+ {% if name %} + + {% if value is iterable %} + {{ (title ~ '.title')|trans }} + {% else %} + {{ title|trans }} + {% endif %} + + {% endif %} + {% if value is not same as(null) %} + + {% if value is iterable %} + {% if value is not empty %} + + {% set keys = value|keys %} + + {% if keys == keys|keys %} +
    + {% for item_name, item_value in value %} +
  1. {{ that.property(null, title, item_value) }}
  2. + {% endfor %} +
+ {% else %} +
    + {% for item_name, item_value in value %} +
  • {{ that.property(item_name, title ~ '.item.' ~ item_name, item_value) }}
  • + {% endfor %} +
+ {% endif %} + {% endif %} + {% elseif value is same as(true) or value is same as(false) %} + {{ ('boolean.' ~ (value ? 1 : 0))|trans }} + {% elseif 'email' in name|lower %} + + {{ value }} + + {% elseif 'phone' in name|lower %} + + {{ value }} + + {% else %} + {{ value|trans }} + {% endif %} +
+ {% endif %} +
+{% endmacro %} From e8fa648f2ab7c7e1fc37d062300324e5992a3018 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 8 Apr 2019 15:32:56 +0300 Subject: [PATCH 068/192] Render raw value in "property()" macro. --- Resources/views/macros.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index ffa7e04..b01082f 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -48,7 +48,7 @@ {{ value }} {% else %} - {{ value|trans }} + {{ value|trans|raw }} {% endif %} {% endif %} From 040da7a3711420bb98ea05e420f6f57dbcc5a57f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 27 May 2019 09:25:06 +0300 Subject: [PATCH 069/192] Always pass subject to email templates. --- Resources/config/mailer.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/mailer.yaml b/Resources/config/mailer.yaml index ac644c5..8355cdf 100644 --- a/Resources/config/mailer.yaml +++ b/Resources/config/mailer.yaml @@ -24,3 +24,4 @@ services: arguments: - "@darvin_utils.mailer" - "@darvin_utils.templating.provider" + - "@translator" From 6b0f4c4d79a8244335f050425f532d0ff88610ba Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 27 May 2019 16:34:27 +0300 Subject: [PATCH 070/192] Allow to pass translation domain to property macro. --- Resources/views/macros.html.twig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index b01082f..ea399e2 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -1,7 +1,13 @@ -{% macro property(name, title, value) %} +{% macro property(name, title, value, trans_domain) %} {% import _self as that %} + {% if trans_domain %} + + {% trans_default_domain trans_domain %} + + {% endif %} +
{% if name %} {% for item_name, item_value in value %} -
  • {{ that.property(null, title, item_value) }}
  • +
  • {{ that.property(null, title, item_value, trans_domain) }}
  • {% endfor %} {% else %}
      {% for item_name, item_value in value %} -
    • {{ that.property(item_name, title ~ '.item.' ~ item_name, item_value) }}
    • +
    • {{ that.property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • {% endfor %}
    {% endif %} From aa80152e2a05c091c8ae4e86cf4da117088cd3de Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 28 May 2019 15:29:27 +0300 Subject: [PATCH 071/192] Fix property macro. --- Resources/views/macros.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index ea399e2..acfa9b1 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -2,7 +2,7 @@ {% import _self as that %} - {% if trans_domain %} + {% if trans_domain is defined %} {% trans_default_domain trans_domain %} From 705d5c87175785a6e10827b70a0c11ebc4c04d51 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 30 May 2019 16:11:14 +0300 Subject: [PATCH 072/192] Do not restrict versions of Darvin bundles. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 93f0992..c1942fb 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ ], "require": { "twig/extensions": "^1.5", - "darvinstudio/darvin-utils": "^7" + "darvinstudio/darvin-utils": "*" }, "suggest": { "symfony/swiftmailer-bundle": "Allows to use mailer" From 8454f5f22c9016a04f3bf61b788cf768958b1e0b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 18 Jun 2019 11:28:07 +0300 Subject: [PATCH 073/192] Change routing cache path. --- Resources/config/routing.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/routing.yaml b/Resources/config/routing.yaml index 414aa08..355c972 100644 --- a/Resources/config/routing.yaml +++ b/Resources/config/routing.yaml @@ -24,6 +24,6 @@ services: arguments: - "@darvin_utils.locale.provider" - "@router.default" - - "%kernel.cache_dir%/darvin/utils/routes.php" + - "%kernel.cache_dir%/darvin_utils/routes.php" - "%kernel.debug%" - "%locales%" From 83ebe81632a61964a58311770f35b4909f7de21c Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 10 Jul 2019 15:25:31 +0300 Subject: [PATCH 074/192] Remove redundant new object Twig extension. --- Resources/config/new_object.yaml | 10 ---------- Resources/doc/new_entity_counter.md | 2 -- 2 files changed, 12 deletions(-) diff --git a/Resources/config/new_object.yaml b/Resources/config/new_object.yaml index 10b8dc6..b4d9aaa 100644 --- a/Resources/config/new_object.yaml +++ b/Resources/config/new_object.yaml @@ -1,8 +1,6 @@ parameters: darvin_utils.new_object.counter.entity.class: Darvin\Utils\NewObject\NewEntityCounter - darvin_utils.new_object.twig_extension.class: Darvin\Utils\Twig\Extension\NewObjectExtension - services: _defaults: public: true @@ -16,11 +14,3 @@ services: - "@doctrine.orm.entity_manager" - "@darvin_utils.mapping.metadata_factory" - "@darvin_utils.user.query_builder_filterer" - - darvin_utils.new_object.twig_extension: - class: "%darvin_utils.new_object.twig_extension.class%" - public: false - arguments: - - "@darvin_utils.new_object.counter" - tags: - - { name: twig.extension } diff --git a/Resources/doc/new_entity_counter.md b/Resources/doc/new_entity_counter.md index 5939162..8ca0a98 100644 --- a/Resources/doc/new_entity_counter.md +++ b/Resources/doc/new_entity_counter.md @@ -37,5 +37,3 @@ $newPagesCount = $this->getContainer()->get('darvin_utils.new_object.counter')-> ``` Для проверки возможности подсчета новых сущностей того или иного класса сервис содержит метод "isCountable()". - -Методы сервиса доступны в Twig - это функции "utils_count_new_objects()" и "utils_new_objects_countable()" соответственно. From 77a54a7571a5774138529f244cbb18152163cde1 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 31 Jul 2019 10:37:51 +0300 Subject: [PATCH 075/192] Increase priority of override entities compiler pass. --- CHANGELOG.md | 2 ++ DarvinUtilsBundle.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ade8c97..31e7678 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,3 +44,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - remove outdated docs; - add entity resolver. + +7.0.3: Increase priority of override entities compiler pass. diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index f0c7507..f4031bc 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -14,6 +14,7 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -33,6 +34,6 @@ public function build(ContainerBuilder $container): void ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddSlugHandlersPass()) ->addCompilerPass(new CreateServiceProvidersPass()) - ->addCompilerPass(new OverrideEntitiesPass()); + ->addCompilerPass(new OverrideEntitiesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); } } From fbf41ddcf12b98be5aa82b7b1af9d6f27ddbc39f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 12 Aug 2019 10:58:39 +0300 Subject: [PATCH 076/192] Refactor stringifying booleans. --- CHANGELOG.md | 2 ++ Resources/translations/messages.ar.yaml | 5 +++-- Resources/translations/messages.en.yaml | 5 +++-- Resources/translations/messages.fr.yaml | 5 +++-- Resources/translations/messages.ru.yaml | 5 +++-- Resources/translations/messages.zh.yaml | 5 +++-- Resources/views/macros.html.twig | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31e7678..bfcbdda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,3 +46,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - add entity resolver. 7.0.3: Increase priority of override entities compiler pass. + +7.0.4: Refactor stringifying booleans. diff --git a/Resources/translations/messages.ar.yaml b/Resources/translations/messages.ar.yaml index d975bb0..7c9af5e 100644 --- a/Resources/translations/messages.ar.yaml +++ b/Resources/translations/messages.ar.yaml @@ -1,6 +1,7 @@ boolean: - - لا - - نعم + indeterminate: 'غير محدد' + 'no': لا + 'yes': نعم flash: error: form: 'شكل الأخطاء المكتشفة. اصلاحها وإعادة تشكيل' diff --git a/Resources/translations/messages.en.yaml b/Resources/translations/messages.en.yaml index fae8f8c..3b22dc3 100644 --- a/Resources/translations/messages.en.yaml +++ b/Resources/translations/messages.en.yaml @@ -1,6 +1,7 @@ boolean: - - No - - Yes + indeterminate: Indeterminate + no: No + yes: Yes flash: error: diff --git a/Resources/translations/messages.fr.yaml b/Resources/translations/messages.fr.yaml index d7ebc13..0a68160 100644 --- a/Resources/translations/messages.fr.yaml +++ b/Resources/translations/messages.fr.yaml @@ -1,6 +1,7 @@ boolean: - - 'Pas de' - - Oui + indeterminate: Indéterminée + 'no': 'Pas de' + 'yes': Oui flash: error: form: 'Des Erreurs Détectées. Les corriger et de soumettre à nouveau le Formulaire' diff --git a/Resources/translations/messages.ru.yaml b/Resources/translations/messages.ru.yaml index c540f3e..cfe7ef7 100644 --- a/Resources/translations/messages.ru.yaml +++ b/Resources/translations/messages.ru.yaml @@ -1,6 +1,7 @@ boolean: - - Нет - - Да + indeterminate: Не определено + no: Нет + yes: Да flash: error: diff --git a/Resources/translations/messages.zh.yaml b/Resources/translations/messages.zh.yaml index 8e41261..5127d35 100644 --- a/Resources/translations/messages.zh.yaml +++ b/Resources/translations/messages.zh.yaml @@ -1,6 +1,7 @@ boolean: - - 没有 - - 是的 + indeterminate: 不确定 + 'no': 没有 + 'yes': 是的 flash: error: form: '形成的错误检测。 解决这些问题,并重新提交形式' diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index acfa9b1..da36d48 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -42,7 +42,7 @@ {% endif %} {% endif %} {% elseif value is same as(true) or value is same as(false) %} - {{ ('boolean.' ~ (value ? 1 : 0))|trans }} + {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} {% elseif 'email' in name|lower %} From 5b429c0eec8a14dbe9ce92b50679b3762f2dc518 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 3 Oct 2019 14:45:38 +0300 Subject: [PATCH 077/192] Add compress response event subscriber. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 5 +++++ DependencyInjection/DarvinUtilsExtension.php | 4 ++++ Resources/config/response/compress.yaml | 8 ++++++++ 4 files changed, 19 insertions(+) create mode 100644 Resources/config/response/compress.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index bfcbdda..aa64abf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,3 +48,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.0.3: Increase priority of override entities compiler pass. 7.0.4: Refactor stringifying booleans. + +7.0.5: Add compress response event subscriber. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e83b8ae..1938cd4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -36,6 +36,11 @@ public function getConfigTreeBuilder(): TreeBuilder $root ->children() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() + ->arrayNode('response')->addDefaultsIfNotSet() + ->children() + ->booleanNode('compress')->defaultFalse()->end() + ->end() + ->end() ->arrayNode('mailer')->canBeEnabled() ->children() ->booleanNode('add_host')->defaultFalse()->end() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 17cccc8..1796599 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -75,6 +75,10 @@ public function load(array $configs, ContainerBuilder $container): void return true; }], + + 'response/compress' => ['callback' => function () use ($config) { + return $config['response']['compress']; + }], ]); } diff --git a/Resources/config/response/compress.yaml b/Resources/config/response/compress.yaml new file mode 100644 index 0000000..8d78c9b --- /dev/null +++ b/Resources/config/response/compress.yaml @@ -0,0 +1,8 @@ +parameters: + darvin_utils.response.compress.event_subscriber.class: Darvin\Utils\EventListener\CompressResponseSubscriber + +services: + darvin_utils.response.compress.event_subscriber: + class: '%darvin_utils.response.compress.event_subscriber.class%' + tags: + - { name: kernel.event_subscriber } From 6ddb105f81574c3031b8cb34a53ec2a3c2593b3f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 7 Oct 2019 15:39:49 +0300 Subject: [PATCH 078/192] Move mailer to Mailer bundle. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 12 +-------- DependencyInjection/DarvinUtilsExtension.php | 19 +------------- README.md | 1 - Resources/config/app/darvin_utils.yaml | 5 ---- Resources/config/mailer.yaml | 27 -------------------- Resources/doc/mailer.md | 21 --------------- composer.json | 3 --- 8 files changed, 4 insertions(+), 86 deletions(-) delete mode 100644 Resources/config/app/darvin_utils.yaml delete mode 100644 Resources/config/mailer.yaml delete mode 100644 Resources/doc/mailer.md diff --git a/CHANGELOG.md b/CHANGELOG.md index aa64abf..ca84cff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,3 +50,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.0.4: Refactor stringifying booleans. 7.0.5: Add compress response event subscriber. + +7.1.0: Move mailer to Mailer bundle. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 1938cd4..87b5ad4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -38,17 +38,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() - ->booleanNode('compress')->defaultFalse()->end() - ->end() - ->end() - ->arrayNode('mailer')->canBeEnabled() - ->children() - ->booleanNode('add_host')->defaultFalse()->end() - ->arrayNode('defaults')->useAttributeAsKey('name')->prototype('variable')->end()->end() - ->arrayNode('from')->isRequired() - ->children() - ->scalarNode('email')->isRequired()->cannotBeEmpty()->end() - ->scalarNode('name')->defaultNull(); + ->booleanNode('compress')->defaultFalse(); return $builder; } diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 1796599..0a955f0 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -29,8 +29,7 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac */ public function load(array $configs, ContainerBuilder $container): void { - $bundles = $container->getParameter('kernel.bundles'); - $config = $this->processConfiguration(new Configuration(), $configs); + $config = $this->processConfiguration(new Configuration(), $configs); (new ConfigInjector($container))->inject($config, $this->getAlias()); @@ -61,21 +60,6 @@ public function load(array $configs, ContainerBuilder $container): void 'dev/translation' => ['env' => 'dev'], - 'mailer' => ['callback' => function () use ($bundles, $config) { - if (!$config['mailer']['enabled']) { - return false; - } - if (!isset($bundles['SwiftmailerBundle'])) { - throw new \RuntimeException(<< ['callback' => function () use ($config) { return $config['response']['compress']; }], @@ -88,7 +72,6 @@ public function load(array $configs, ContainerBuilder $container): void public function prepend(ContainerBuilder $container): void { (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ - 'darvin_utils', 'doctrine', 'stof_doctrine_extensions', ]); diff --git a/README.md b/README.md index 7a46deb..7824d72 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ - [**Default value**](Resources/doc/default_value.md) - функционал, позволяющий автоматически присваивать свойству сущности, значение которого не задано, значение другого свойства; - [**Flash notifier**](Resources/doc/flash_notifier.md) - сервис, упрощающий добавление flash-сообщений; -- [**Mailer**](Resources/doc/mailer.md) - сервис отправки электронной почты; - [**Metadata factory**](Resources/doc/metadata_factory.md) - фабрика метаданных на базе аннотаций; - [**New entity counter**](Resources/doc/new_entity_counter.md) - сервис подсчета количества новых сущностей; - [**Object namer**](Resources/doc/object_namer.md) - сервис генерации имени объекта в нотации "under_score" по его diff --git a/Resources/config/app/darvin_utils.yaml b/Resources/config/app/darvin_utils.yaml deleted file mode 100644 index e8b0ed9..0000000 --- a/Resources/config/app/darvin_utils.yaml +++ /dev/null @@ -1,5 +0,0 @@ -darvin_utils: - mailer: - defaults: - charset: utf-8 - content_type: text/html diff --git a/Resources/config/mailer.yaml b/Resources/config/mailer.yaml deleted file mode 100644 index 8355cdf..0000000 --- a/Resources/config/mailer.yaml +++ /dev/null @@ -1,27 +0,0 @@ -parameters: - darvin_utils.mailer.class: Darvin\Utils\Mailer\Mailer - - darvin_utils.mailer.template.class: Darvin\Utils\Mailer\TemplateMailer - -services: - _defaults: - public: true - - darvin_utils.mailer: - class: "%darvin_utils.mailer.class%" - arguments: - - "@logger" - - "@request_stack" - - "@translator" - - "%darvin_utils.mailer.defaults%" - - "%darvin_utils.mailer.add_host%" - - "%darvin_utils.mailer.from.email%" - - "%darvin_utils.mailer.from.name%" - - "@mailer" - - darvin_utils.mailer.template: - class: "%darvin_utils.mailer.template.class%" - arguments: - - "@darvin_utils.mailer" - - "@darvin_utils.templating.provider" - - "@translator" diff --git a/Resources/doc/mailer.md b/Resources/doc/mailer.md deleted file mode 100644 index 5bea874..0000000 --- a/Resources/doc/mailer.md +++ /dev/null @@ -1,21 +0,0 @@ -Mailer -====== - -## Описание - -Mailer - сервис отправки электронной почты. - -## Использование - -Пример использования: - -```php -$this->getContainer()->get('darvin_utils.mailer')->send('email.hello.subject', 'Hello, world!', 'world@example.com'); -``` - -Особенности: - -- в качестве аргумента "subject" можно передавать строку перевода, при этом можно использовать аргумент "subjectParams" - для передачи параметров перевода (см. пример выше); -- имя отправителя задается параметром "darvin_utils.mailer.from" конфигурации бандла; -- кодировка письма задается параметром "darvin_utils.mailer.charset" конфигурации бандла. diff --git a/composer.json b/composer.json index c1942fb..e051980 100644 --- a/composer.json +++ b/composer.json @@ -15,9 +15,6 @@ "twig/extensions": "^1.5", "darvinstudio/darvin-utils": "*" }, - "suggest": { - "symfony/swiftmailer-bundle": "Allows to use mailer" - }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } } From 0f7f97b4698bad7b42be979485cbf61dd39d5ac9 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:07:04 +0300 Subject: [PATCH 079/192] Rename "property" macro to "email_property". --- Resources/views/macros.html.twig | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index da36d48..d66fa8a 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -2,6 +2,14 @@ {% import _self as that %} + {{ that.email_property(name, title, value, trans_domain) }} + +{% endmacro %} + +{% macro email_property(name, title, value, trans_domain) %} + + {% import _self as that %} + {% if trans_domain is defined %} {% trans_default_domain trans_domain %} @@ -30,13 +38,13 @@ {% if keys == keys|keys %}
      {% for item_name, item_value in value %} -
    1. {{ that.property(null, title, item_value, trans_domain) }}
    2. +
    3. {{ that.email_property(null, title, item_value, trans_domain) }}
    4. {% endfor %}
    {% else %}
      {% for item_name, item_value in value %} -
    • {{ that.property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • +
    • {{ that.email_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • {% endfor %}
    {% endif %} From 480b2dd6a1f6272cd9f938527ecba9d0e2ba83d7 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:10:12 +0300 Subject: [PATCH 080/192] Implement "email_data()" macro. --- Resources/views/macros.html.twig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index d66fa8a..dbef96b 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -3,7 +3,15 @@ {% import _self as that %} {{ that.email_property(name, title, value, trans_domain) }} +{% endmacro %} + +{% macro email_data(data, trans_prefix, trans_domain) %} + + {% import _self as that %} + {% for name, value in data %} + {{ that.email_property(name, trans_prefix ~ name, value, trans_domain) }} + {% endfor %} {% endmacro %} {% macro email_property(name, title, value, trans_domain) %} From 0ce08b5202f574ac09e790d7b686f2a313829ad9 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:12:05 +0300 Subject: [PATCH 081/192] Implement "table_data()" macro. --- Resources/views/macros.html.twig | 72 ++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index dbef96b..ca2b149 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -76,3 +76,75 @@ {% endif %}
    {% endmacro %} + +{% macro table_data(data, trans_prefix, trans_domain) %} + + {% import _self as that %} + + {% for name, value in data %} + {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} + {% endfor %} +{% endmacro %} + +{% macro table_property(name, title, value, trans_domain) %} + + {% import _self as that %} + + {% if trans_domain is defined %} + + {% trans_default_domain trans_domain %} + + {% endif %} + + +{% endmacro %} From 3d83aff4102e8db2d567f257e11081500c5f27c5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:20:02 +0300 Subject: [PATCH 082/192] Always render value in property macros. --- Resources/views/macros.html.twig | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index ca2b149..269502c 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -35,9 +35,11 @@ {% endif %} {% endif %} - {% if value is not same as(null) %} - + + {% if value is same as(null) %} + - + {% else %} {% if value is iterable %} {% if value is not empty %} @@ -72,8 +74,8 @@ {% else %} {{ value|trans|raw }} {% endif %} - - {% endif %} + {% endif %} + {% endmacro %} @@ -107,9 +109,11 @@ {% endif %} {% endif %} - {% if value is not same as(null) %} - + + {% if value is same as(null) %} + - + {% else %} {% if value is iterable %} {% if value is not empty %} @@ -144,7 +148,7 @@ {% else %} {{ value|trans|raw }} {% endif %} - - {% endif %} + {% endif %} + {% endmacro %} From 466bf0a8c5c9e55ab59e11e406d599fc0463e2ba Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:26:40 +0300 Subject: [PATCH 083/192] Render table in "table_data" macro. --- Resources/views/macros.html.twig | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index 269502c..3269ff2 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -83,9 +83,13 @@ {% import _self as that %} - {% for name, value in data %} - {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} - {% endfor %} + {% if data is not empty %} + + {% for name, value in data %} + {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} + {% endfor %} +
    + {% endif %} {% endmacro %} {% macro table_property(name, title, value, trans_domain) %} @@ -98,40 +102,36 @@ {% endif %} -
    + {% if name %} - + {% if value is iterable %} {{ (title ~ '.title')|trans }} {% else %} {{ title|trans }} {% endif %} - + {% endif %} - + {% if value is same as(null) %} - {% else %} {% if value is iterable %} {% if value is not empty %} + - {% set keys = value|keys %} + {% set keys = value|keys %} - {% if keys == keys|keys %} -
      + {% if keys == keys|keys %} {% for item_name, item_value in value %} -
    1. {{ that.table_property(null, title, item_value, trans_domain) }}
    2. + {{ that.table_property(null, title, item_value, trans_domain) }} {% endfor %} -
    - {% else %} -
      + {% else %} {% for item_name, item_value in value %} -
    • {{ that.table_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • + {{ that.table_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }} {% endfor %} -
    - {% endif %} + {% endif %} +
    {% endif %} {% elseif value is same as(true) or value is same as(false) %} {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} @@ -149,6 +149,6 @@ {{ value|trans|raw }} {% endif %} {% endif %} -
    -
    + + {% endmacro %} From fbf235c06e859a6e9c1885029952d261a8a494ab Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 15 Oct 2019 16:31:05 +0300 Subject: [PATCH 084/192] Add "email_data()" and "table_data()" macros. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca84cff..a7ea069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,3 +52,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.0.5: Add compress response event subscriber. 7.1.0: Move mailer to Mailer bundle. + +7.1.1: Add "email_data()" and "table_data()" macros. From 796140bfac6d48ee4c3b07ce70ae0be53023206f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 16 Oct 2019 09:04:31 +0300 Subject: [PATCH 085/192] Rename "email_data()" macro to "div_data()". Remove "property()" macro. --- CHANGELOG.md | 2 ++ Resources/views/macros.html.twig | 41 +++++++++++++------------------- 2 files changed, 19 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ea069..dccee06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,3 +54,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.0: Move mailer to Mailer bundle. 7.1.1: Add "email_data()" and "table_data()" macros. + +7.1.2: Rename "email_data()" macro to "div_data()". Remove "property()" macro. diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index 3269ff2..a9baa11 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -1,20 +1,26 @@ -{% macro property(name, title, value, trans_domain) %} +{% macro div_data(data, trans_prefix, trans_domain) %} {% import _self as that %} - {{ that.email_property(name, title, value, trans_domain) }} + {% for name, value in data %} + {{ that.div_property(name, trans_prefix ~ name, value, trans_domain) }} + {% endfor %} {% endmacro %} -{% macro email_data(data, trans_prefix, trans_domain) %} +{% macro table_data(data, trans_prefix, trans_domain) %} {% import _self as that %} - {% for name, value in data %} - {{ that.email_property(name, trans_prefix ~ name, value, trans_domain) }} - {% endfor %} + {% if data is not empty %} + + {% for name, value in data %} + {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} + {% endfor %} +
    + {% endif %} {% endmacro %} -{% macro email_property(name, title, value, trans_domain) %} +{% macro div_property(name, title, value, trans_domain) %} {% import _self as that %} @@ -45,16 +51,16 @@ {% set keys = value|keys %} - {% if keys == keys|keys %} + {% if keys is same as(keys|keys) %}
      {% for item_name, item_value in value %} -
    1. {{ that.email_property(null, title, item_value, trans_domain) }}
    2. +
    3. {{ that.div_property(null, title, item_value, trans_domain) }}
    4. {% endfor %}
    {% else %}
      {% for item_name, item_value in value %} -
    • {{ that.email_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • +
    • {{ that.div_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • {% endfor %}
    {% endif %} @@ -79,19 +85,6 @@ {% endmacro %} -{% macro table_data(data, trans_prefix, trans_domain) %} - - {% import _self as that %} - - {% if data is not empty %} - - {% for name, value in data %} - {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} - {% endfor %} -
    - {% endif %} -{% endmacro %} - {% macro table_property(name, title, value, trans_domain) %} {% import _self as that %} @@ -122,7 +115,7 @@ {% set keys = value|keys %} - {% if keys == keys|keys %} + {% if keys is same as(keys|keys) %} {% for item_name, item_value in value %} {{ that.table_property(null, title, item_value, trans_domain) }} {% endfor %} From 3441f7cfb1b219800715880e28567a071474e151 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 23 Oct 2019 08:58:04 +0300 Subject: [PATCH 086/192] Do not render empty properties' titles in data macros. --- CHANGELOG.md | 2 + Resources/views/macros.html.twig | 144 +++++++++++++++---------------- 2 files changed, 70 insertions(+), 76 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dccee06..dcc5a9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,3 +56,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.1: Add "email_data()" and "table_data()" macros. 7.1.2: Rename "email_data()" macro to "div_data()". Remove "property()" macro. + +7.1.3: Do not render empty properties' titles in data macros. diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig index a9baa11..fb6ef8f 100644 --- a/Resources/views/macros.html.twig +++ b/Resources/views/macros.html.twig @@ -21,49 +21,45 @@ {% endmacro %} {% macro div_property(name, title, value, trans_domain) %} + {% if value is not same as(null) and value is not same as('') and not (value is iterable and value is empty) %} - {% import _self as that %} - - {% if trans_domain is defined %} + {% import _self as that %} - {% trans_default_domain trans_domain %} + {% if trans_domain is defined %} - {% endif %} + {% trans_default_domain trans_domain %} -
    - {% if name %} - - {% if value is iterable %} - {{ (title ~ '.title')|trans }} - {% else %} - {{ title|trans }} - {% endif %} - {% endif %} - - {% if value is same as(null) %} - - - {% else %} - {% if value is iterable %} - {% if value is not empty %} - {% set keys = value|keys %} +
    + {% if name %} + + {% if value is iterable %} + {{ (title ~ '.title')|trans }} + {% else %} + {{ title|trans }} + {% endif %} + + {% endif %} + + {% if value is iterable %} - {% if keys is same as(keys|keys) %} -
      - {% for item_name, item_value in value %} -
    1. {{ that.div_property(null, title, item_value, trans_domain) }}
    2. - {% endfor %} -
    - {% else %} -
      - {% for item_name, item_value in value %} -
    • {{ that.div_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • - {% endfor %} -
    - {% endif %} + {% set keys = value|keys %} + + {% if keys is same as(keys|keys) %} +
      + {% for item_name, item_value in value %} +
    1. {{ that.div_property(null, title, item_value, trans_domain) }}
    2. + {% endfor %} +
    + {% else %} +
      + {% for item_name, item_value in value %} +
    • {{ that.div_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • + {% endfor %} +
    {% endif %} {% elseif value is same as(true) or value is same as(false) %} {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} @@ -80,52 +76,48 @@ {% else %} {{ value|trans|raw }} {% endif %} - {% endif %} -
    -
    +
    +
    + {% endif %} {% endmacro %} {% macro table_property(name, title, value, trans_domain) %} + {% if value is not same as(null) and value is not same as('') and not (value is iterable and value is empty) %} - {% import _self as that %} - - {% if trans_domain is defined %} + {% import _self as that %} - {% trans_default_domain trans_domain %} + {% if trans_domain is defined %} - {% endif %} + {% trans_default_domain trans_domain %} - - {% if name %} - - {% if value is iterable %} - {{ (title ~ '.title')|trans }} - {% else %} - {{ title|trans }} - {% endif %} - {% endif %} - - {% if value is same as(null) %} - - - {% else %} - {% if value is iterable %} - {% if value is not empty %} - - - {% set keys = value|keys %} - - {% if keys is same as(keys|keys) %} - {% for item_name, item_value in value %} - {{ that.table_property(null, title, item_value, trans_domain) }} - {% endfor %} - {% else %} - {% for item_name, item_value in value %} - {{ that.table_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }} - {% endfor %} - {% endif %} -
    + + + {% if name %} + + {% if value is iterable %} + {{ (title ~ '.title')|trans }} + {% else %} + {{ title|trans }} {% endif %} + + {% endif %} + + {% if value is iterable %} + + + {% set keys = value|keys %} + + {% if keys is same as(keys|keys) %} + {% for item_name, item_value in value %} + {{ that.table_property(null, title, item_value, trans_domain) }} + {% endfor %} + {% else %} + {% for item_name, item_value in value %} + {{ that.table_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }} + {% endfor %} + {% endif %} +
    {% elseif value is same as(true) or value is same as(false) %} {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} {% elseif 'email' in name|lower %} @@ -141,7 +133,7 @@ {% else %} {{ value|trans|raw }} {% endif %} - {% endif %} - - + + + {% endif %} {% endmacro %} From e1af2c7d514dfd462c40337a429db96fc23ec592 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 13 Nov 2019 11:10:14 +0300 Subject: [PATCH 087/192] Apply "raw" filter in price template. --- CHANGELOG.md | 2 ++ Resources/views/price.html.twig | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcc5a9a..320d7bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,3 +58,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.2: Rename "email_data()" macro to "div_data()". Remove "property()" macro. 7.1.3: Do not render empty properties' titles in data macros. + +7.1.4: Apply "raw" filter in price template. diff --git a/Resources/views/price.html.twig b/Resources/views/price.html.twig index e2f9b35..1e3179e 100644 --- a/Resources/views/price.html.twig +++ b/Resources/views/price.html.twig @@ -1 +1 @@ -{{ ('price.' ~ options.format)|trans({'%price%': price|number_format(0, null, ' ')}) }} +{{ ('price.' ~ options.format)|trans({'%price%': price|number_format(0, null, ' ')})|raw }} From b39ea4da2c798a37f32d03ca4b959b9b61c54251 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 29 Nov 2019 09:22:07 +0300 Subject: [PATCH 088/192] Replace "templating" => "twig". --- .../Compiler/CreateServiceProvidersPass.php | 2 +- Price/PriceFormatter.php | 23 ++++++++++--------- Resources/config/price.yaml | 2 +- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index ba4998e..a68b54c 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -27,7 +27,7 @@ class CreateServiceProvidersPass implements CompilerPassInterface 'darvin_utils.authorization_checker.provider' => 'security.authorization_checker', 'darvin_utils.entity_manager.provider' => 'doctrine.orm.default_entity_manager', 'darvin_utils.object_manager.provider' => 'doctrine.orm.default_entity_manager', - 'darvin_utils.templating.provider' => 'templating', + 'darvin_utils.twig.provider' => 'twig', ]; /** diff --git a/Price/PriceFormatter.php b/Price/PriceFormatter.php index 18386e2..64c3ba0 100644 --- a/Price/PriceFormatter.php +++ b/Price/PriceFormatter.php @@ -1,7 +1,7 @@ - - * @copyright Copyright (c) 2018, Darvin Studio + * @copyright Copyright (c) 2018-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE @@ -12,6 +12,7 @@ use Darvin\Utils\Price\PriceFormatterInterface; use Darvin\Utils\Service\ServiceProviderInterface; +use Twig\Environment; /** * Price formatter @@ -21,36 +22,36 @@ class PriceFormatter implements PriceFormatterInterface /** * @var \Darvin\Utils\Service\ServiceProviderInterface */ - private $templatingProvider; + private $twigProvider; /** - * @param \Darvin\Utils\Service\ServiceProviderInterface $templatingProvider Templating service provider + * @param \Darvin\Utils\Service\ServiceProviderInterface $twigProvider Twig service provider */ - public function __construct(ServiceProviderInterface $templatingProvider) + public function __construct(ServiceProviderInterface $twigProvider) { - $this->templatingProvider = $templatingProvider; + $this->twigProvider = $twigProvider; } /** * {@inheritdoc} */ - public function format($price, array $options = []) + public function format($price, array $options = []): string { if (!isset($options['format'])) { $options['format'] = 'default'; } - return $this->getTemplating()->render(isset($options['template']) ? $options['template'] : '@DarvinUtils/price.html.twig', [ + return $this->getTwig()->render(isset($options['template']) ? $options['template'] : '@DarvinUtils/price.html.twig', [ 'price' => $price, 'options' => $options, ]); } /** - * @return \Symfony\Component\Templating\EngineInterface + * @return \Twig\Environment */ - final protected function getTemplating() + final protected function getTwig(): Environment { - return $this->templatingProvider->getService(); + return $this->twigProvider->getService(); } } diff --git a/Resources/config/price.yaml b/Resources/config/price.yaml index a0889ab..aa0fa5f 100644 --- a/Resources/config/price.yaml +++ b/Resources/config/price.yaml @@ -10,7 +10,7 @@ services: darvin_utils.price.formatter: class: "%darvin_utils.price.formatter.class%" arguments: - - "@darvin_utils.templating.provider" + - "@darvin_utils.twig.provider" darvin_utils.price.twig_extension: class: "%darvin_utils.price.twig_extension.class%" From 4ad29bfd9625449655073964e453886ffe4d42b4 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 29 Nov 2019 13:32:55 +0300 Subject: [PATCH 089/192] Make providable services public. --- CHANGELOG.md | 2 ++ DependencyInjection/Compiler/CreateServiceProvidersPass.php | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 320d7bb..0e83b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,3 +60,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.3: Do not render empty properties' titles in data macros. 7.1.4: Apply "raw" filter in price template. + +7.1.6: Make providable services public. diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index a68b54c..6974553 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -44,15 +44,14 @@ public function process(ContainerBuilder $container): void $definitions = []; foreach ($ids as $providerId => $id) { - if ($container->hasDefinition($id) && !$container->getDefinition($id)->isPublic()) { - throw new \RuntimeException(sprintf('Unable to create provider for service "%s": service is not public.', $id)); - } if ($container->hasDefinition($providerId)) { throw new \RuntimeException( sprintf('Unable to create provider for service "%s": service "%s" already exists.', $id, $providerId) ); } + $container->getDefinition($id)->setPublic(true); + $definitions[$providerId] = (new ChildDefinition(self::PARENT_ID))->addArgument($id); } From 9d35dcddbd21a2abe161e2c1efe65f2fbfeb061c Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 3 Dec 2019 09:52:08 +0300 Subject: [PATCH 090/192] Make services private. --- Resources/config/anti_spam.yaml | 3 --- Resources/config/cloner.yaml | 3 --- Resources/config/custom_object.yaml | 3 --- Resources/config/default_value.yaml | 6 +----- Resources/config/dev/translation.yaml | 3 --- Resources/config/flash.yaml | 3 --- Resources/config/form.yaml | 3 --- Resources/config/homepage.yaml | 9 ++------- Resources/config/intl.yaml | 6 +----- Resources/config/locale.yaml | 6 ++---- Resources/config/mapping.yaml | 15 +-------------- Resources/config/new_object.yaml | 3 --- Resources/config/object_namer.yaml | 6 +----- Resources/config/orm.yaml | 6 ++---- Resources/config/price.yaml | 6 +----- Resources/config/routing.yaml | 9 ++------- Resources/config/security.yaml | 3 --- Resources/config/service.yaml | 4 ---- Resources/config/sluggable.yaml | 6 +----- Resources/config/stringifier.yaml | 3 --- Resources/config/transliteratable.yaml | 6 +----- Resources/config/tree.yaml | 3 --- Resources/config/user.yaml | 3 --- 23 files changed, 15 insertions(+), 103 deletions(-) diff --git a/Resources/config/anti_spam.yaml b/Resources/config/anti_spam.yaml index 5ddf67f..24f2fac 100644 --- a/Resources/config/anti_spam.yaml +++ b/Resources/config/anti_spam.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.anti_spam.form_type.class: Darvin\Utils\Form\Type\AntiSpamType services: - _defaults: - public: true - darvin_utils.anti_spam.form_type: class: "%darvin_utils.anti_spam.form_type.class%" tags: diff --git a/Resources/config/cloner.yaml b/Resources/config/cloner.yaml index be4e296..203e355 100644 --- a/Resources/config/cloner.yaml +++ b/Resources/config/cloner.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.cloner.class: Darvin\Utils\Cloner\Cloner services: - _defaults: - public: true - darvin_utils.cloner: class: "%darvin_utils.cloner.class%" arguments: diff --git a/Resources/config/custom_object.yaml b/Resources/config/custom_object.yaml index f7495aa..4e04d60 100644 --- a/Resources/config/custom_object.yaml +++ b/Resources/config/custom_object.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.custom_object.loader.entity.class: Darvin\Utils\CustomObject\CustomEntityLoader services: - _defaults: - public: true - darvin_utils.custom_object.loader: alias: darvin_utils.custom_object.loader.entity diff --git a/Resources/config/default_value.yaml b/Resources/config/default_value.yaml index 2dedf5c..763b60c 100644 --- a/Resources/config/default_value.yaml +++ b/Resources/config/default_value.yaml @@ -2,12 +2,8 @@ parameters: darvin_utils.default_value.set_event_subscriber.class: Darvin\Utils\EventListener\SetDefaultValuesSubscriber services: - _defaults: - public: true - darvin_utils.default_value.set_event_subscriber: - class: '%darvin_utils.default_value.set_event_subscriber.class%' - public: false + class: '%darvin_utils.default_value.set_event_subscriber.class%' arguments: - '@darvin_utils.mapping.metadata_factory' - '@property_accessor' diff --git a/Resources/config/dev/translation.yaml b/Resources/config/dev/translation.yaml index dd67079..bcad194 100644 --- a/Resources/config/dev/translation.yaml +++ b/Resources/config/dev/translation.yaml @@ -8,9 +8,6 @@ parameters: darvin_utils.translation.translate_command.name: darvin:utils:translations:translate services: - _defaults: - public: true - darvin_utils.translation.title_case_command: class: "%darvin_utils.translation.title_case_command.class%" arguments: diff --git a/Resources/config/flash.yaml b/Resources/config/flash.yaml index 0802ba2..534fd2c 100644 --- a/Resources/config/flash.yaml +++ b/Resources/config/flash.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.flash.notifier.class: Darvin\Utils\Flash\FlashNotifier services: - _defaults: - public: true - darvin_utils.flash.notifier: class: "%darvin_utils.flash.notifier.class%" arguments: diff --git a/Resources/config/form.yaml b/Resources/config/form.yaml index 4894167..b2fab0e 100644 --- a/Resources/config/form.yaml +++ b/Resources/config/form.yaml @@ -4,9 +4,6 @@ parameters: darvin_utils.form.number_type_extension.class: Darvin\Utils\Form\Extension\NumberTypeExtension services: - _defaults: - public: true - darvin_utils.form.integer_type_extension: class: "%darvin_utils.form.integer_type_extension.class%" tags: diff --git a/Resources/config/homepage.yaml b/Resources/config/homepage.yaml index 59a5b0e..4b6e60d 100644 --- a/Resources/config/homepage.yaml +++ b/Resources/config/homepage.yaml @@ -4,19 +4,14 @@ parameters: darvin_utils.homepage.dummy_router.class: Darvin\Utils\Homepage\DummyHomepageRouter services: - _defaults: - public: true - darvin_utils.homepage.provider: alias: darvin_utils.homepage.dummy_provider darvin_utils.homepage.dummy_provider: - class: "%darvin_utils.homepage.dummy_provider.class%" - public: false + class: "%darvin_utils.homepage.dummy_provider.class%" darvin_utils.homepage.router: alias: darvin_utils.homepage.dummy_router darvin_utils.homepage.dummy_router: - class: "%darvin_utils.homepage.dummy_router.class%" - public: false \ No newline at end of file + class: "%darvin_utils.homepage.dummy_router.class%" diff --git a/Resources/config/intl.yaml b/Resources/config/intl.yaml index 05587cf..55656e7 100644 --- a/Resources/config/intl.yaml +++ b/Resources/config/intl.yaml @@ -2,11 +2,7 @@ parameters: darvin_utils.intl.twig_extension.class: Twig_Extensions_Extension_Intl services: - _defaults: - public: true - darvin_utils.intl.twig_extension: - class: "%darvin_utils.intl.twig_extension.class%" - public: false + class: "%darvin_utils.intl.twig_extension.class%" tags: - { name: twig.extension } diff --git a/Resources/config/locale.yaml b/Resources/config/locale.yaml index 52c143b..bfe5fbf 100644 --- a/Resources/config/locale.yaml +++ b/Resources/config/locale.yaml @@ -2,11 +2,9 @@ parameters: darvin_utils.locale.provider.class: Darvin\Utils\Locale\LocaleProvider services: - _defaults: - public: true - darvin_utils.locale.provider: - class: "%darvin_utils.locale.provider.class%" + class: "%darvin_utils.locale.provider.class%" + public: true arguments: - "@request_stack" - "%locale%" diff --git a/Resources/config/mapping.yaml b/Resources/config/mapping.yaml index 7b672dc..3674e8a 100644 --- a/Resources/config/mapping.yaml +++ b/Resources/config/mapping.yaml @@ -22,69 +22,57 @@ parameters: darvin_utils.mapping.set_default_discriminator_listener.class: Darvin\Utils\EventListener\SetDefaultDiscriminatorListener services: - _defaults: - public: true - darvin_utils.mapping.annotation_driver.abstract: class: "%darvin_utils.mapping.annotation_driver.abstract.class%" abstract: true - public: false arguments: - "@annotation_reader" darvin_utils.mapping.annotation_driver.clonable: class: "%darvin_utils.mapping.annotation_driver.clonable.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.custom_object: class: "%darvin_utils.mapping.annotation_driver.custom_object.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.default_value: class: "%darvin_utils.mapping.annotation_driver.default_value.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.new_object_flag: class: "%darvin_utils.mapping.annotation_driver.new_object_flag.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.slug: class: "%darvin_utils.mapping.annotation_driver.slug.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.transliteratable: class: "%darvin_utils.mapping.annotation_driver.transliteratable.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.updated_at: class: "%darvin_utils.mapping.annotation_driver.updated_at.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.user: class: "%darvin_utils.mapping.annotation_driver.user.class%" parent: darvin_utils.mapping.annotation_driver.abstract - public: false tags: - { name: darvin_utils.annotation_driver } @@ -94,7 +82,6 @@ services: - "@darvin_utils.object_manager.provider" darvin_utils.mapping.set_default_discriminator_listener: - class: "%darvin_utils.mapping.set_default_discriminator_listener.class%" - public: false + class: "%darvin_utils.mapping.set_default_discriminator_listener.class%" tags: - { name: doctrine.event_listener, event: postGenerateSchemaTable } diff --git a/Resources/config/new_object.yaml b/Resources/config/new_object.yaml index b4d9aaa..5eb1eaf 100644 --- a/Resources/config/new_object.yaml +++ b/Resources/config/new_object.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.new_object.counter.entity.class: Darvin\Utils\NewObject\NewEntityCounter services: - _defaults: - public: true - darvin_utils.new_object.counter: alias: darvin_utils.new_object.counter.entity diff --git a/Resources/config/object_namer.yaml b/Resources/config/object_namer.yaml index 97a4c8b..2dbc4dc 100644 --- a/Resources/config/object_namer.yaml +++ b/Resources/config/object_namer.yaml @@ -4,15 +4,11 @@ parameters: darvin_utils.object_namer.twig_extension.class: Darvin\Utils\Twig\Extension\ObjectNamerExtension services: - _defaults: - public: true - darvin_utils.object_namer: class: "%darvin_utils.object_namer.class%" darvin_utils.object_namer.twig_extension: - class: "%darvin_utils.object_namer.twig_extension.class%" - public: false + class: "%darvin_utils.object_namer.twig_extension.class%" arguments: - "@darvin_utils.object_namer" tags: diff --git a/Resources/config/orm.yaml b/Resources/config/orm.yaml index ddd6f17..55b2ce9 100644 --- a/Resources/config/orm.yaml +++ b/Resources/config/orm.yaml @@ -2,8 +2,6 @@ parameters: darvin_utils.orm.entity_resolver.class: Darvin\Utils\ORM\EntityResolver services: - _defaults: - public: true - darvin_utils.orm.entity_resolver: - class: '%darvin_utils.orm.entity_resolver.class%' + class: '%darvin_utils.orm.entity_resolver.class%' + public: true diff --git a/Resources/config/price.yaml b/Resources/config/price.yaml index aa0fa5f..e06176f 100644 --- a/Resources/config/price.yaml +++ b/Resources/config/price.yaml @@ -4,17 +4,13 @@ parameters: darvin_utils.price.twig_extension.class: Darvin\Utils\Twig\Extension\PriceExtension services: - _defaults: - public: true - darvin_utils.price.formatter: class: "%darvin_utils.price.formatter.class%" arguments: - "@darvin_utils.twig.provider" darvin_utils.price.twig_extension: - class: "%darvin_utils.price.twig_extension.class%" - public: false + class: "%darvin_utils.price.twig_extension.class%" arguments: - "@darvin_utils.price.formatter" tags: diff --git a/Resources/config/routing.yaml b/Resources/config/routing.yaml index 355c972..0549910 100644 --- a/Resources/config/routing.yaml +++ b/Resources/config/routing.yaml @@ -4,12 +4,8 @@ parameters: darvin_utils.routing.route_manager.cached.class: Darvin\Utils\Routing\CachedRouteManager services: - _defaults: - public: true - darvin_utils.routing.route_cache_warmer: - class: "%darvin_utils.routing.route_cache_warmer.class%" - public: false + class: "%darvin_utils.routing.route_cache_warmer.class%" arguments: - "@darvin_utils.routing.route_manager.cached" tags: @@ -19,8 +15,7 @@ services: alias: darvin_utils.routing.route_manager.cached darvin_utils.routing.route_manager.cached: - class: "%darvin_utils.routing.route_manager.cached.class%" - public: false + class: "%darvin_utils.routing.route_manager.cached.class%" arguments: - "@darvin_utils.locale.provider" - "@router.default" diff --git a/Resources/config/security.yaml b/Resources/config/security.yaml index c06bdb9..a50e84b 100644 --- a/Resources/config/security.yaml +++ b/Resources/config/security.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.security.accessibility_checker.class: Darvin\Utils\Security\Authorization\AccessibilityChecker services: - _defaults: - public: true - darvin_utils.security.accessibility_checker: class: "%darvin_utils.security.accessibility_checker.class%" arguments: diff --git a/Resources/config/service.yaml b/Resources/config/service.yaml index 34b81b4..11c43e9 100644 --- a/Resources/config/service.yaml +++ b/Resources/config/service.yaml @@ -2,12 +2,8 @@ parameters: darvin_utils.service.abstract_provider.class: Darvin\Utils\Service\ServiceProvider services: - _defaults: - public: true - darvin_utils.service.abstract_provider: class: "%darvin_utils.service.abstract_provider.class%" abstract: true - public: false calls: - [ setContainer, [ "@service_container" ] ] diff --git a/Resources/config/sluggable.yaml b/Resources/config/sluggable.yaml index ff18c59..2206249 100644 --- a/Resources/config/sluggable.yaml +++ b/Resources/config/sluggable.yaml @@ -4,9 +4,6 @@ parameters: darvin_utils.sluggable.slugify_event_subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber services: - _defaults: - public: true - darvin_utils.sluggable.manager: alias: darvin_utils.sluggable.manager.entity @@ -19,8 +16,7 @@ services: - '@property_accessor' darvin_utils.sluggable.slugify_event_subscriber: - class: '%darvin_utils.sluggable.slugify_event_subscriber.class%' - public: false + class: '%darvin_utils.sluggable.slugify_event_subscriber.class%' arguments: - '@darvin_utils.entity_manager.provider' - '@darvin_utils.sluggable.manager' diff --git a/Resources/config/stringifier.yaml b/Resources/config/stringifier.yaml index 9f6ceee..b38a324 100644 --- a/Resources/config/stringifier.yaml +++ b/Resources/config/stringifier.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.stringifier.doctrine.class: Darvin\Utils\Strings\Stringifier\DoctrineStringifier services: - _defaults: - public: true - darvin_utils.stringifier.doctrine: class: "%darvin_utils.stringifier.doctrine.class%" arguments: diff --git a/Resources/config/transliteratable.yaml b/Resources/config/transliteratable.yaml index f01234f..bb92634 100644 --- a/Resources/config/transliteratable.yaml +++ b/Resources/config/transliteratable.yaml @@ -4,12 +4,8 @@ parameters: darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator services: - _defaults: - public: true - darvin_utils.transliteratable.transliterate_event_subscriber: - class: '%darvin_utils.transliteratable.transliterate_event_subscriber.class%' - public: false + class: '%darvin_utils.transliteratable.transliterate_event_subscriber.class%' arguments: - '@darvin_utils.mapping.metadata_factory' - '@property_accessor' diff --git a/Resources/config/tree.yaml b/Resources/config/tree.yaml index e094afc..bb6c694 100644 --- a/Resources/config/tree.yaml +++ b/Resources/config/tree.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.tree.sorter.class: Darvin\Utils\Tree\TreeSorter services: - _defaults: - public: true - darvin_utils.tree.sorter: class: "%darvin_utils.tree.sorter.class%" public: true diff --git a/Resources/config/user.yaml b/Resources/config/user.yaml index e2fe4b0..7ef1eda 100644 --- a/Resources/config/user.yaml +++ b/Resources/config/user.yaml @@ -2,9 +2,6 @@ parameters: darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer services: - _defaults: - public: true - darvin_utils.user.query_builder_filterer: class: "%darvin_utils.user.query_builder_filterer.class%" arguments: From f66d12cd95fd38bb628f51e6b619b6cece552d36 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 3 Dec 2019 11:30:06 +0300 Subject: [PATCH 091/192] Move service configs to "services" dir. --- CHANGELOG.md | 4 ++++ DependencyInjection/DarvinUtilsExtension.php | 2 +- Resources/config/{ => services}/anti_spam.yaml | 0 Resources/config/{ => services}/cloner.yaml | 0 Resources/config/{ => services}/custom_object.yaml | 0 Resources/config/{ => services}/default_value.yaml | 0 Resources/config/{ => services}/dev/translation.yaml | 0 Resources/config/{ => services}/flash.yaml | 0 Resources/config/{ => services}/form.yaml | 0 Resources/config/{ => services}/homepage.yaml | 0 Resources/config/{ => services}/intl.yaml | 0 Resources/config/{ => services}/locale.yaml | 0 Resources/config/{ => services}/mapping.yaml | 0 Resources/config/{ => services}/new_object.yaml | 0 Resources/config/{ => services}/object_namer.yaml | 0 Resources/config/{ => services}/orm.yaml | 0 Resources/config/{ => services}/price.yaml | 0 Resources/config/{ => services}/response/compress.yaml | 0 Resources/config/{ => services}/routing.yaml | 0 Resources/config/{ => services}/security.yaml | 0 Resources/config/{ => services}/service.yaml | 0 Resources/config/{ => services}/sluggable.yaml | 0 Resources/config/{ => services}/stringifier.yaml | 0 Resources/config/{ => services}/transliteratable.yaml | 0 Resources/config/{ => services}/tree.yaml | 0 Resources/config/{ => services}/user.yaml | 0 26 files changed, 5 insertions(+), 1 deletion(-) rename Resources/config/{ => services}/anti_spam.yaml (100%) rename Resources/config/{ => services}/cloner.yaml (100%) rename Resources/config/{ => services}/custom_object.yaml (100%) rename Resources/config/{ => services}/default_value.yaml (100%) rename Resources/config/{ => services}/dev/translation.yaml (100%) rename Resources/config/{ => services}/flash.yaml (100%) rename Resources/config/{ => services}/form.yaml (100%) rename Resources/config/{ => services}/homepage.yaml (100%) rename Resources/config/{ => services}/intl.yaml (100%) rename Resources/config/{ => services}/locale.yaml (100%) rename Resources/config/{ => services}/mapping.yaml (100%) rename Resources/config/{ => services}/new_object.yaml (100%) rename Resources/config/{ => services}/object_namer.yaml (100%) rename Resources/config/{ => services}/orm.yaml (100%) rename Resources/config/{ => services}/price.yaml (100%) rename Resources/config/{ => services}/response/compress.yaml (100%) rename Resources/config/{ => services}/routing.yaml (100%) rename Resources/config/{ => services}/security.yaml (100%) rename Resources/config/{ => services}/service.yaml (100%) rename Resources/config/{ => services}/sluggable.yaml (100%) rename Resources/config/{ => services}/stringifier.yaml (100%) rename Resources/config/{ => services}/transliteratable.yaml (100%) rename Resources/config/{ => services}/tree.yaml (100%) rename Resources/config/{ => services}/user.yaml (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e83b1c..d807e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,3 +62,7 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.4: Apply "raw" filter in price template. 7.1.6: Make providable services public. + +7.1.8: + +- Move service configs to "services" dir. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 0a955f0..f306439 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -33,7 +33,7 @@ public function load(array $configs, ContainerBuilder $container): void (new ConfigInjector($container))->inject($config, $this->getAlias()); - (new ConfigLoader($container, __DIR__.'/../Resources/config'))->load([ + (new ConfigLoader($container, __DIR__.'/../Resources/config/services'))->load([ 'anti_spam', 'cloner', 'custom_object', diff --git a/Resources/config/anti_spam.yaml b/Resources/config/services/anti_spam.yaml similarity index 100% rename from Resources/config/anti_spam.yaml rename to Resources/config/services/anti_spam.yaml diff --git a/Resources/config/cloner.yaml b/Resources/config/services/cloner.yaml similarity index 100% rename from Resources/config/cloner.yaml rename to Resources/config/services/cloner.yaml diff --git a/Resources/config/custom_object.yaml b/Resources/config/services/custom_object.yaml similarity index 100% rename from Resources/config/custom_object.yaml rename to Resources/config/services/custom_object.yaml diff --git a/Resources/config/default_value.yaml b/Resources/config/services/default_value.yaml similarity index 100% rename from Resources/config/default_value.yaml rename to Resources/config/services/default_value.yaml diff --git a/Resources/config/dev/translation.yaml b/Resources/config/services/dev/translation.yaml similarity index 100% rename from Resources/config/dev/translation.yaml rename to Resources/config/services/dev/translation.yaml diff --git a/Resources/config/flash.yaml b/Resources/config/services/flash.yaml similarity index 100% rename from Resources/config/flash.yaml rename to Resources/config/services/flash.yaml diff --git a/Resources/config/form.yaml b/Resources/config/services/form.yaml similarity index 100% rename from Resources/config/form.yaml rename to Resources/config/services/form.yaml diff --git a/Resources/config/homepage.yaml b/Resources/config/services/homepage.yaml similarity index 100% rename from Resources/config/homepage.yaml rename to Resources/config/services/homepage.yaml diff --git a/Resources/config/intl.yaml b/Resources/config/services/intl.yaml similarity index 100% rename from Resources/config/intl.yaml rename to Resources/config/services/intl.yaml diff --git a/Resources/config/locale.yaml b/Resources/config/services/locale.yaml similarity index 100% rename from Resources/config/locale.yaml rename to Resources/config/services/locale.yaml diff --git a/Resources/config/mapping.yaml b/Resources/config/services/mapping.yaml similarity index 100% rename from Resources/config/mapping.yaml rename to Resources/config/services/mapping.yaml diff --git a/Resources/config/new_object.yaml b/Resources/config/services/new_object.yaml similarity index 100% rename from Resources/config/new_object.yaml rename to Resources/config/services/new_object.yaml diff --git a/Resources/config/object_namer.yaml b/Resources/config/services/object_namer.yaml similarity index 100% rename from Resources/config/object_namer.yaml rename to Resources/config/services/object_namer.yaml diff --git a/Resources/config/orm.yaml b/Resources/config/services/orm.yaml similarity index 100% rename from Resources/config/orm.yaml rename to Resources/config/services/orm.yaml diff --git a/Resources/config/price.yaml b/Resources/config/services/price.yaml similarity index 100% rename from Resources/config/price.yaml rename to Resources/config/services/price.yaml diff --git a/Resources/config/response/compress.yaml b/Resources/config/services/response/compress.yaml similarity index 100% rename from Resources/config/response/compress.yaml rename to Resources/config/services/response/compress.yaml diff --git a/Resources/config/routing.yaml b/Resources/config/services/routing.yaml similarity index 100% rename from Resources/config/routing.yaml rename to Resources/config/services/routing.yaml diff --git a/Resources/config/security.yaml b/Resources/config/services/security.yaml similarity index 100% rename from Resources/config/security.yaml rename to Resources/config/services/security.yaml diff --git a/Resources/config/service.yaml b/Resources/config/services/service.yaml similarity index 100% rename from Resources/config/service.yaml rename to Resources/config/services/service.yaml diff --git a/Resources/config/sluggable.yaml b/Resources/config/services/sluggable.yaml similarity index 100% rename from Resources/config/sluggable.yaml rename to Resources/config/services/sluggable.yaml diff --git a/Resources/config/stringifier.yaml b/Resources/config/services/stringifier.yaml similarity index 100% rename from Resources/config/stringifier.yaml rename to Resources/config/services/stringifier.yaml diff --git a/Resources/config/transliteratable.yaml b/Resources/config/services/transliteratable.yaml similarity index 100% rename from Resources/config/transliteratable.yaml rename to Resources/config/services/transliteratable.yaml diff --git a/Resources/config/tree.yaml b/Resources/config/services/tree.yaml similarity index 100% rename from Resources/config/tree.yaml rename to Resources/config/services/tree.yaml diff --git a/Resources/config/user.yaml b/Resources/config/services/user.yaml similarity index 100% rename from Resources/config/user.yaml rename to Resources/config/services/user.yaml From b9edf4da784de4dcfe12d87e07280cf9ede28808 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 3 Dec 2019 11:31:14 +0300 Subject: [PATCH 092/192] Use single quotes in YAML. --- CHANGELOG.md | 2 ++ Resources/config/services/anti_spam.yaml | 2 +- Resources/config/services/cloner.yaml | 8 +++--- Resources/config/services/custom_object.yaml | 8 +++--- .../config/services/dev/translation.yaml | 14 +++++----- Resources/config/services/flash.yaml | 4 +-- Resources/config/services/form.yaml | 4 +-- Resources/config/services/homepage.yaml | 4 +-- Resources/config/services/intl.yaml | 2 +- Resources/config/services/locale.yaml | 6 ++--- Resources/config/services/mapping.yaml | 26 +++++++++---------- Resources/config/services/new_object.yaml | 8 +++--- Resources/config/services/object_namer.yaml | 6 ++--- Resources/config/services/price.yaml | 8 +++--- Resources/config/services/routing.yaml | 16 ++++++------ Resources/config/services/security.yaml | 4 +-- Resources/config/services/service.yaml | 4 +-- Resources/config/services/stringifier.yaml | 4 +-- Resources/config/services/tree.yaml | 8 +++--- Resources/config/services/user.yaml | 8 +++--- 20 files changed, 74 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d807e60..e172cd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,3 +66,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.8: - Move service configs to "services" dir. + +- Use single quotes in YAML. diff --git a/Resources/config/services/anti_spam.yaml b/Resources/config/services/anti_spam.yaml index 24f2fac..76ac867 100644 --- a/Resources/config/services/anti_spam.yaml +++ b/Resources/config/services/anti_spam.yaml @@ -3,6 +3,6 @@ parameters: services: darvin_utils.anti_spam.form_type: - class: "%darvin_utils.anti_spam.form_type.class%" + class: '%darvin_utils.anti_spam.form_type.class%' tags: - { name: form.type } diff --git a/Resources/config/services/cloner.yaml b/Resources/config/services/cloner.yaml index 203e355..e66b082 100644 --- a/Resources/config/services/cloner.yaml +++ b/Resources/config/services/cloner.yaml @@ -3,8 +3,8 @@ parameters: services: darvin_utils.cloner: - class: "%darvin_utils.cloner.class%" + class: '%darvin_utils.cloner.class%' arguments: - - "@event_dispatcher" - - "@darvin_utils.mapping.metadata_factory" - - "@property_accessor" + - '@event_dispatcher' + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' diff --git a/Resources/config/services/custom_object.yaml b/Resources/config/services/custom_object.yaml index 4e04d60..d12022a 100644 --- a/Resources/config/services/custom_object.yaml +++ b/Resources/config/services/custom_object.yaml @@ -6,8 +6,8 @@ services: alias: darvin_utils.custom_object.loader.entity darvin_utils.custom_object.loader.entity: - class: "%darvin_utils.custom_object.loader.entity.class%" + class: '%darvin_utils.custom_object.loader.entity.class%' arguments: - - "@doctrine.orm.entity_manager" - - "@darvin_utils.mapping.metadata_factory" - - "@property_accessor" + - '@doctrine.orm.entity_manager' + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' diff --git a/Resources/config/services/dev/translation.yaml b/Resources/config/services/dev/translation.yaml index bcad194..80f1882 100644 --- a/Resources/config/services/dev/translation.yaml +++ b/Resources/config/services/dev/translation.yaml @@ -9,18 +9,18 @@ parameters: services: darvin_utils.translation.title_case_command: - class: "%darvin_utils.translation.title_case_command.class%" + class: '%darvin_utils.translation.title_case_command.class%' arguments: - - "%darvin_utils.translation.title_case_command.name%" - - "%darvin_utils.translation.title_case_command.base_url%" - - "%darvin_utils.translation.title_case_command.http_timeout%" + - '%darvin_utils.translation.title_case_command.name%' + - '%darvin_utils.translation.title_case_command.base_url%' + - '%darvin_utils.translation.title_case_command.http_timeout%' tags: - { name: console.command } darvin_utils.translation.translate_command: - class: "%darvin_utils.translation.translate_command.class%" + class: '%darvin_utils.translation.translate_command.class%' arguments: - - "%darvin_utils.translation.translate_command.name%" - - "%darvin_utils.yandex_translate_api_key%" + - '%darvin_utils.translation.translate_command.name%' + - '%darvin_utils.yandex_translate_api_key%' tags: - { name: console.command } diff --git a/Resources/config/services/flash.yaml b/Resources/config/services/flash.yaml index 534fd2c..48859d8 100644 --- a/Resources/config/services/flash.yaml +++ b/Resources/config/services/flash.yaml @@ -3,6 +3,6 @@ parameters: services: darvin_utils.flash.notifier: - class: "%darvin_utils.flash.notifier.class%" + class: '%darvin_utils.flash.notifier.class%' arguments: - - "@session.flash_bag" + - '@session.flash_bag' diff --git a/Resources/config/services/form.yaml b/Resources/config/services/form.yaml index b2fab0e..98eb210 100644 --- a/Resources/config/services/form.yaml +++ b/Resources/config/services/form.yaml @@ -5,11 +5,11 @@ parameters: services: darvin_utils.form.integer_type_extension: - class: "%darvin_utils.form.integer_type_extension.class%" + class: '%darvin_utils.form.integer_type_extension.class%' tags: - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\IntegerType } darvin_utils.form.number_type_extension: - class: "%darvin_utils.form.number_type_extension.class%" + class: '%darvin_utils.form.number_type_extension.class%' tags: - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\NumberType } diff --git a/Resources/config/services/homepage.yaml b/Resources/config/services/homepage.yaml index 4b6e60d..d57bdf3 100644 --- a/Resources/config/services/homepage.yaml +++ b/Resources/config/services/homepage.yaml @@ -8,10 +8,10 @@ services: alias: darvin_utils.homepage.dummy_provider darvin_utils.homepage.dummy_provider: - class: "%darvin_utils.homepage.dummy_provider.class%" + class: '%darvin_utils.homepage.dummy_provider.class%' darvin_utils.homepage.router: alias: darvin_utils.homepage.dummy_router darvin_utils.homepage.dummy_router: - class: "%darvin_utils.homepage.dummy_router.class%" + class: '%darvin_utils.homepage.dummy_router.class%' diff --git a/Resources/config/services/intl.yaml b/Resources/config/services/intl.yaml index 55656e7..3cc434b 100644 --- a/Resources/config/services/intl.yaml +++ b/Resources/config/services/intl.yaml @@ -3,6 +3,6 @@ parameters: services: darvin_utils.intl.twig_extension: - class: "%darvin_utils.intl.twig_extension.class%" + class: '%darvin_utils.intl.twig_extension.class%' tags: - { name: twig.extension } diff --git a/Resources/config/services/locale.yaml b/Resources/config/services/locale.yaml index bfe5fbf..590c726 100644 --- a/Resources/config/services/locale.yaml +++ b/Resources/config/services/locale.yaml @@ -3,8 +3,8 @@ parameters: services: darvin_utils.locale.provider: - class: "%darvin_utils.locale.provider.class%" + class: '%darvin_utils.locale.provider.class%' public: true arguments: - - "@request_stack" - - "%locale%" + - '@request_stack' + - '%locale%' diff --git a/Resources/config/services/mapping.yaml b/Resources/config/services/mapping.yaml index 3674e8a..863ecb9 100644 --- a/Resources/config/services/mapping.yaml +++ b/Resources/config/services/mapping.yaml @@ -23,65 +23,65 @@ parameters: services: darvin_utils.mapping.annotation_driver.abstract: - class: "%darvin_utils.mapping.annotation_driver.abstract.class%" + class: '%darvin_utils.mapping.annotation_driver.abstract.class%' abstract: true arguments: - - "@annotation_reader" + - '@annotation_reader' darvin_utils.mapping.annotation_driver.clonable: - class: "%darvin_utils.mapping.annotation_driver.clonable.class%" + class: '%darvin_utils.mapping.annotation_driver.clonable.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.custom_object: - class: "%darvin_utils.mapping.annotation_driver.custom_object.class%" + class: '%darvin_utils.mapping.annotation_driver.custom_object.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.default_value: - class: "%darvin_utils.mapping.annotation_driver.default_value.class%" + class: '%darvin_utils.mapping.annotation_driver.default_value.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.new_object_flag: - class: "%darvin_utils.mapping.annotation_driver.new_object_flag.class%" + class: '%darvin_utils.mapping.annotation_driver.new_object_flag.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.slug: - class: "%darvin_utils.mapping.annotation_driver.slug.class%" + class: '%darvin_utils.mapping.annotation_driver.slug.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.transliteratable: - class: "%darvin_utils.mapping.annotation_driver.transliteratable.class%" + class: '%darvin_utils.mapping.annotation_driver.transliteratable.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.updated_at: - class: "%darvin_utils.mapping.annotation_driver.updated_at.class%" + class: '%darvin_utils.mapping.annotation_driver.updated_at.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.annotation_driver.user: - class: "%darvin_utils.mapping.annotation_driver.user.class%" + class: '%darvin_utils.mapping.annotation_driver.user.class%' parent: darvin_utils.mapping.annotation_driver.abstract tags: - { name: darvin_utils.annotation_driver } darvin_utils.mapping.metadata_factory: - class: "%darvin_utils.mapping.metadata_factory.class%" + class: '%darvin_utils.mapping.metadata_factory.class%' arguments: - - "@darvin_utils.object_manager.provider" + - '@darvin_utils.object_manager.provider' darvin_utils.mapping.set_default_discriminator_listener: - class: "%darvin_utils.mapping.set_default_discriminator_listener.class%" + class: '%darvin_utils.mapping.set_default_discriminator_listener.class%' tags: - { name: doctrine.event_listener, event: postGenerateSchemaTable } diff --git a/Resources/config/services/new_object.yaml b/Resources/config/services/new_object.yaml index 5eb1eaf..0d33572 100644 --- a/Resources/config/services/new_object.yaml +++ b/Resources/config/services/new_object.yaml @@ -6,8 +6,8 @@ services: alias: darvin_utils.new_object.counter.entity darvin_utils.new_object.counter.entity: - class: "%darvin_utils.new_object.counter.entity.class%" + class: '%darvin_utils.new_object.counter.entity.class%' arguments: - - "@doctrine.orm.entity_manager" - - "@darvin_utils.mapping.metadata_factory" - - "@darvin_utils.user.query_builder_filterer" + - '@doctrine.orm.entity_manager' + - '@darvin_utils.mapping.metadata_factory' + - '@darvin_utils.user.query_builder_filterer' diff --git a/Resources/config/services/object_namer.yaml b/Resources/config/services/object_namer.yaml index 2dbc4dc..9419d45 100644 --- a/Resources/config/services/object_namer.yaml +++ b/Resources/config/services/object_namer.yaml @@ -5,11 +5,11 @@ parameters: services: darvin_utils.object_namer: - class: "%darvin_utils.object_namer.class%" + class: '%darvin_utils.object_namer.class%' darvin_utils.object_namer.twig_extension: - class: "%darvin_utils.object_namer.twig_extension.class%" + class: '%darvin_utils.object_namer.twig_extension.class%' arguments: - - "@darvin_utils.object_namer" + - '@darvin_utils.object_namer' tags: - { name: twig.extension } diff --git a/Resources/config/services/price.yaml b/Resources/config/services/price.yaml index e06176f..45d6a04 100644 --- a/Resources/config/services/price.yaml +++ b/Resources/config/services/price.yaml @@ -5,13 +5,13 @@ parameters: services: darvin_utils.price.formatter: - class: "%darvin_utils.price.formatter.class%" + class: '%darvin_utils.price.formatter.class%' arguments: - - "@darvin_utils.twig.provider" + - '@darvin_utils.twig.provider' darvin_utils.price.twig_extension: - class: "%darvin_utils.price.twig_extension.class%" + class: '%darvin_utils.price.twig_extension.class%' arguments: - - "@darvin_utils.price.formatter" + - '@darvin_utils.price.formatter' tags: - { name: twig.extension } diff --git a/Resources/config/services/routing.yaml b/Resources/config/services/routing.yaml index 0549910..63f055c 100644 --- a/Resources/config/services/routing.yaml +++ b/Resources/config/services/routing.yaml @@ -5,9 +5,9 @@ parameters: services: darvin_utils.routing.route_cache_warmer: - class: "%darvin_utils.routing.route_cache_warmer.class%" + class: '%darvin_utils.routing.route_cache_warmer.class%' arguments: - - "@darvin_utils.routing.route_manager.cached" + - '@darvin_utils.routing.route_manager.cached' tags: - { name: kernel.cache_warmer } @@ -15,10 +15,10 @@ services: alias: darvin_utils.routing.route_manager.cached darvin_utils.routing.route_manager.cached: - class: "%darvin_utils.routing.route_manager.cached.class%" + class: '%darvin_utils.routing.route_manager.cached.class%' arguments: - - "@darvin_utils.locale.provider" - - "@router.default" - - "%kernel.cache_dir%/darvin_utils/routes.php" - - "%kernel.debug%" - - "%locales%" + - '@darvin_utils.locale.provider' + - '@router.default' + - '%kernel.cache_dir%/darvin_utils/routes.php' + - '%kernel.debug%' + - '%locales%' diff --git a/Resources/config/services/security.yaml b/Resources/config/services/security.yaml index a50e84b..9f1f9f0 100644 --- a/Resources/config/services/security.yaml +++ b/Resources/config/services/security.yaml @@ -3,6 +3,6 @@ parameters: services: darvin_utils.security.accessibility_checker: - class: "%darvin_utils.security.accessibility_checker.class%" + class: '%darvin_utils.security.accessibility_checker.class%' arguments: - - "@darvin_utils.authorization_checker.provider" + - '@darvin_utils.authorization_checker.provider' diff --git a/Resources/config/services/service.yaml b/Resources/config/services/service.yaml index 11c43e9..64cb6ae 100644 --- a/Resources/config/services/service.yaml +++ b/Resources/config/services/service.yaml @@ -3,7 +3,7 @@ parameters: services: darvin_utils.service.abstract_provider: - class: "%darvin_utils.service.abstract_provider.class%" + class: '%darvin_utils.service.abstract_provider.class%' abstract: true calls: - - [ setContainer, [ "@service_container" ] ] + - [ setContainer, [ '@service_container' ] ] diff --git a/Resources/config/services/stringifier.yaml b/Resources/config/services/stringifier.yaml index b38a324..b84e09f 100644 --- a/Resources/config/services/stringifier.yaml +++ b/Resources/config/services/stringifier.yaml @@ -3,6 +3,6 @@ parameters: services: darvin_utils.stringifier.doctrine: - class: "%darvin_utils.stringifier.doctrine.class%" + class: '%darvin_utils.stringifier.doctrine.class%' arguments: - - "@translator" + - '@translator' diff --git a/Resources/config/services/tree.yaml b/Resources/config/services/tree.yaml index bb6c694..c88f96b 100644 --- a/Resources/config/services/tree.yaml +++ b/Resources/config/services/tree.yaml @@ -3,9 +3,9 @@ parameters: services: darvin_utils.tree.sorter: - class: "%darvin_utils.tree.sorter.class%" + class: '%darvin_utils.tree.sorter.class%' public: true arguments: - - "@doctrine.orm.entity_manager" - - "@property_accessor" - - "@stof_doctrine_extensions.listener.tree" + - '@doctrine.orm.entity_manager' + - '@property_accessor' + - '@stof_doctrine_extensions.listener.tree' diff --git a/Resources/config/services/user.yaml b/Resources/config/services/user.yaml index 7ef1eda..9993fe7 100644 --- a/Resources/config/services/user.yaml +++ b/Resources/config/services/user.yaml @@ -3,8 +3,8 @@ parameters: services: darvin_utils.user.query_builder_filterer: - class: "%darvin_utils.user.query_builder_filterer.class%" + class: '%darvin_utils.user.query_builder_filterer.class%' arguments: - - "@security.token_storage" - - "@security.authorization_checker" - - "@darvin_utils.mapping.metadata_factory" + - '@security.token_storage' + - '@security.authorization_checker' + - '@darvin_utils.mapping.metadata_factory' From 6117c419f0fc520099abf3ec6fa2b75ebe17c52a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 5 Dec 2019 08:40:19 +0300 Subject: [PATCH 093/192] Enable strict types. --- DependencyInjection/Compiler/AddAnnotationDriversPass.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Compiler/AddAnnotationDriversPass.php b/DependencyInjection/Compiler/AddAnnotationDriversPass.php index 1e61a3d..6edfbb3 100644 --- a/DependencyInjection/Compiler/AddAnnotationDriversPass.php +++ b/DependencyInjection/Compiler/AddAnnotationDriversPass.php @@ -1,7 +1,7 @@ - - * @copyright Copyright (c) 2015-2018, Darvin Studio + * @copyright Copyright (c) 2015-2019, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE @@ -22,7 +22,7 @@ class AddAnnotationDriversPass implements CompilerPassInterface /** * {@inheritdoc} */ - public function process(ContainerBuilder $container) + public function process(ContainerBuilder $container): void { $factory = $container->getDefinition('darvin_utils.mapping.metadata_factory'); From 3d2075c77e4ab59666c5ec099ddd9c7fb0347415 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 5 Dec 2019 09:49:15 +0300 Subject: [PATCH 094/192] inheritdoc => inheritDoc. --- DarvinUtilsBundle.php | 2 +- DependencyInjection/Compiler/AddAnnotationDriversPass.php | 2 +- DependencyInjection/Compiler/AddSlugHandlersPass.php | 2 +- DependencyInjection/Compiler/CreateServiceProvidersPass.php | 2 +- DependencyInjection/Compiler/OverrideEntitiesPass.php | 2 +- DependencyInjection/Configuration.php | 2 +- DependencyInjection/DarvinUtilsExtension.php | 4 ++-- Price/PriceFormatter.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index f4031bc..2c65db0 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -24,7 +24,7 @@ class DarvinUtilsBundle extends Bundle { /** - * {@inheritdoc} + * {@inheritDoc} */ public function build(ContainerBuilder $container): void { diff --git a/DependencyInjection/Compiler/AddAnnotationDriversPass.php b/DependencyInjection/Compiler/AddAnnotationDriversPass.php index 6edfbb3..087e98a 100644 --- a/DependencyInjection/Compiler/AddAnnotationDriversPass.php +++ b/DependencyInjection/Compiler/AddAnnotationDriversPass.php @@ -20,7 +20,7 @@ class AddAnnotationDriversPass implements CompilerPassInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function process(ContainerBuilder $container): void { diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index c09646c..5b0b673 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -21,7 +21,7 @@ class AddSlugHandlersPass implements CompilerPassInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function process(ContainerBuilder $container): void { diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 6974553..5e14fc8 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -31,7 +31,7 @@ class CreateServiceProvidersPass implements CompilerPassInterface ]; /** - * {@inheritdoc} + * {@inheritDoc} */ public function process(ContainerBuilder $container): void { diff --git a/DependencyInjection/Compiler/OverrideEntitiesPass.php b/DependencyInjection/Compiler/OverrideEntitiesPass.php index c121c42..96b070c 100644 --- a/DependencyInjection/Compiler/OverrideEntitiesPass.php +++ b/DependencyInjection/Compiler/OverrideEntitiesPass.php @@ -34,7 +34,7 @@ public function __construct() } /** - * {@inheritdoc} + * {@inheritDoc} */ public function process(ContainerBuilder $container): void { diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 87b5ad4..7d6c045 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -21,7 +21,7 @@ class Configuration implements ConfigurationInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function getConfigTreeBuilder(): TreeBuilder { diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index f306439..1601327 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -25,7 +25,7 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterface { /** - * {@inheritdoc} + * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container): void { @@ -67,7 +67,7 @@ public function load(array $configs, ContainerBuilder $container): void } /** - * {@inheritdoc} + * {@inheritDoc} */ public function prepend(ContainerBuilder $container): void { diff --git a/Price/PriceFormatter.php b/Price/PriceFormatter.php index 64c3ba0..71d39d5 100644 --- a/Price/PriceFormatter.php +++ b/Price/PriceFormatter.php @@ -33,7 +33,7 @@ public function __construct(ServiceProviderInterface $twigProvider) } /** - * {@inheritdoc} + * {@inheritDoc} */ public function format($price, array $options = []): string { From 22642043291938ddfc6fa0e071914838a95df447 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 6 Dec 2019 10:32:56 +0300 Subject: [PATCH 095/192] Register interfaces for autoconfiguration. --- CHANGELOG.md | 2 ++ DependencyInjection/Compiler/AddAnnotationDriversPass.php | 3 ++- DependencyInjection/DarvinUtilsExtension.php | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e172cd8..57774d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,3 +68,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Move service configs to "services" dir. - Use single quotes in YAML. + +7.1.9: Register interfaces for autoconfiguration. diff --git a/DependencyInjection/Compiler/AddAnnotationDriversPass.php b/DependencyInjection/Compiler/AddAnnotationDriversPass.php index 087e98a..0be6e4f 100644 --- a/DependencyInjection/Compiler/AddAnnotationDriversPass.php +++ b/DependencyInjection/Compiler/AddAnnotationDriversPass.php @@ -10,6 +10,7 @@ namespace Darvin\UtilsBundle\DependencyInjection\Compiler; +use Darvin\UtilsBundle\DependencyInjection\DarvinUtilsExtension; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -26,7 +27,7 @@ public function process(ContainerBuilder $container): void { $factory = $container->getDefinition('darvin_utils.mapping.metadata_factory'); - foreach (array_keys($container->findTaggedServiceIds('darvin_utils.annotation_driver')) as $id) { + foreach (array_keys($container->findTaggedServiceIds(DarvinUtilsExtension::TAG_ANNOTATION_DRIVER)) as $id) { $factory->addMethodCall('addAnnotationDriver', [new Reference($id)]); } } diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 1601327..b3a72d7 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -13,6 +13,8 @@ use Darvin\Utils\DependencyInjection\ConfigInjector; use Darvin\Utils\DependencyInjection\ConfigLoader; use Darvin\Utils\DependencyInjection\ExtensionConfigurator; +use Darvin\Utils\Mapping\AnnotationDriver\AnnotationDriverInterface; +use Darvin\Utils\Sluggable\SlugHandlerInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -24,11 +26,17 @@ */ class DarvinUtilsExtension extends Extension implements PrependExtensionInterface { + public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; + public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; + /** * {@inheritDoc} */ public function load(array $configs, ContainerBuilder $container): void { + $container->registerForAutoconfiguration(AnnotationDriverInterface::class)->addTag(self::TAG_ANNOTATION_DRIVER); + $container->registerForAutoconfiguration(SlugHandlerInterface::class)->addTag(self::TAG_SLUG_HANDLER); + $config = $this->processConfiguration(new Configuration(), $configs); (new ConfigInjector($container))->inject($config, $this->getAlias()); From 2f1354797cda95cdea2b6132003a80d20f3e02f9 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 6 Dec 2019 14:28:20 +0300 Subject: [PATCH 096/192] Alias services for autowiring. --- CHANGELOG.md | 2 + DarvinUtilsBundle.php | 2 + .../Compiler/AliasServicesPass.php | 66 +++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 DependencyInjection/Compiler/AliasServicesPass.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 57774d3..837ece2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,3 +70,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Use single quotes in YAML. 7.1.9: Register interfaces for autoconfiguration. + +7.2.0: Alias services for autowiring. diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 2c65db0..5477e63 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -12,6 +12,7 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddAnnotationDriversPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; +use Darvin\UtilsBundle\DependencyInjection\Compiler\AliasServicesPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; @@ -33,6 +34,7 @@ public function build(ContainerBuilder $container): void $container ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddSlugHandlersPass()) + ->addCompilerPass(new AliasServicesPass()) ->addCompilerPass(new CreateServiceProvidersPass()) ->addCompilerPass(new OverrideEntitiesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); } diff --git a/DependencyInjection/Compiler/AliasServicesPass.php b/DependencyInjection/Compiler/AliasServicesPass.php new file mode 100644 index 0000000..3d5eeb8 --- /dev/null +++ b/DependencyInjection/Compiler/AliasServicesPass.php @@ -0,0 +1,66 @@ + + * @copyright Copyright (c) 2019, Darvin Studio + * @link https://www.darvin-studio.ru + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Darvin\UtilsBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Alias; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +/** + * Alias services compiler pass + */ +class AliasServicesPass implements CompilerPassInterface +{ + /** + * {@inheritDoc} + */ + public function process(ContainerBuilder $container): void + { + $aliases = $ambiguous = []; + + $addAlias = function (string $alias, string $id, Definition $definition) use (&$aliases, &$ambiguous, $container) { + if ($container->hasDefinition($alias) || $container->hasAlias($alias)) { + return; + } + if (!isset($aliases[$alias])) { + $aliases[$alias] = new Alias($id, $definition->isPublic()); + } else { + $ambiguous[] = $alias; + } + }; + + foreach ($container->getDefinitions() as $id => $definition) { + if (0 !== strpos($id, 'darvin_')) { + continue; + } + + $class = $container->getParameterBag()->resolveValue($definition->getClass()); + + if (null === $class || !class_exists($class) || 0 !== strpos($class, 'Darvin\\')) { + continue; + } + + $addAlias($class, $id, $definition); + + foreach (class_implements($class) as $interface) { + if (0 === strpos($interface, 'Darvin\\')) { + $addAlias($interface, $id, $definition); + } + } + } + foreach ($ambiguous as $alias) { + unset($aliases[$alias]); + } + + $container->addAliases($aliases); + } +} From af5df0e6ba356ecda5d0eaf50ba5d4c04630ec37 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 6 Dec 2019 14:28:58 +0300 Subject: [PATCH 097/192] Alias services for autowiring. --- DependencyInjection/Compiler/AliasServicesPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Compiler/AliasServicesPass.php b/DependencyInjection/Compiler/AliasServicesPass.php index 3d5eeb8..519f1ff 100644 --- a/DependencyInjection/Compiler/AliasServicesPass.php +++ b/DependencyInjection/Compiler/AliasServicesPass.php @@ -27,7 +27,7 @@ public function process(ContainerBuilder $container): void { $aliases = $ambiguous = []; - $addAlias = function (string $alias, string $id, Definition $definition) use (&$aliases, &$ambiguous, $container) { + $addAlias = function (string $alias, string $id, Definition $definition) use (&$aliases, &$ambiguous, $container): void { if ($container->hasDefinition($alias) || $container->hasAlias($alias)) { return; } From a117beabf7e4bc4e7d879eb9dc06c6482e72f613 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 9 Dec 2019 09:23:54 +0300 Subject: [PATCH 098/192] Add generic stringifier. --- CHANGELOG.md | 2 ++ Resources/config/services/stringifier.yaml | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 837ece2..28254f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,3 +72,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.1.9: Register interfaces for autoconfiguration. 7.2.0: Alias services for autowiring. + +7.2.1: Add generic stringifier. diff --git a/Resources/config/services/stringifier.yaml b/Resources/config/services/stringifier.yaml index b84e09f..5c3c83d 100644 --- a/Resources/config/services/stringifier.yaml +++ b/Resources/config/services/stringifier.yaml @@ -1,7 +1,17 @@ parameters: + darvin_utils.stringifier.class: Darvin\Utils\Strings\Stringifier\Stringifier + darvin_utils.stringifier.doctrine.class: Darvin\Utils\Strings\Stringifier\DoctrineStringifier services: + Darvin\Utils\Strings\Stringifier\StringifierInterface: '@darvin_utils.stringifier' + Darvin\Utils\Strings\Stringifier\DoctrineStringifierInterface: '@darvin_utils.stringifier.doctrine' + + darvin_utils.stringifier: + class: '%darvin_utils.stringifier.class%' + arguments: + - '@translator' + darvin_utils.stringifier.doctrine: class: '%darvin_utils.stringifier.doctrine.class%' arguments: From ee4d0708017fd23ca13b9b74b1ccb2718f393ec8 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 18 Dec 2019 15:49:33 +0300 Subject: [PATCH 099/192] Allow to disable form component. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 1 + DependencyInjection/DarvinUtilsExtension.php | 18 ++++++++++++++---- Resources/config/services/anti_spam.yaml | 8 -------- Resources/config/services/form.yaml | 19 +++++++++++++------ 5 files changed, 30 insertions(+), 18 deletions(-) delete mode 100644 Resources/config/services/anti_spam.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 28254f5..ee462e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -74,3 +74,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.0: Alias services for autowiring. 7.2.1: Add generic stringifier. + +7.3.0: Allow to disable form component. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7d6c045..b31683a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -35,6 +35,7 @@ public function getConfigTreeBuilder(): TreeBuilder // more information on that topic. $root ->children() + ->arrayNode('form')->canBeDisabled()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index b3a72d7..27efb13 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -42,12 +42,10 @@ public function load(array $configs, ContainerBuilder $container): void (new ConfigInjector($container))->inject($config, $this->getAlias()); (new ConfigLoader($container, __DIR__.'/../Resources/config/services'))->load([ - 'anti_spam', 'cloner', 'custom_object', 'default_value', 'flash', - 'form', 'homepage', 'intl', 'locale', @@ -64,13 +62,17 @@ public function load(array $configs, ContainerBuilder $container): void 'transliteratable', 'user', - 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], + 'dev/translation' => ['env' => 'dev'], - 'dev/translation' => ['env' => 'dev'], + 'form' => ['callback' => function () use ($config) { + return $config['form']['enabled']; + }], 'response/compress' => ['callback' => function () use ($config) { return $config['response']['compress']; }], + + 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], ]); } @@ -79,6 +81,14 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { + if (!class_exists('Symfony\Component\Form\AbstractType')) { + $container->prependExtensionConfig($this->getAlias(), [ + 'form' => [ + 'enabled' => false, + ], + ]); + } + (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', 'stof_doctrine_extensions', diff --git a/Resources/config/services/anti_spam.yaml b/Resources/config/services/anti_spam.yaml deleted file mode 100644 index 76ac867..0000000 --- a/Resources/config/services/anti_spam.yaml +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - darvin_utils.anti_spam.form_type.class: Darvin\Utils\Form\Type\AntiSpamType - -services: - darvin_utils.anti_spam.form_type: - class: '%darvin_utils.anti_spam.form_type.class%' - tags: - - { name: form.type } diff --git a/Resources/config/services/form.yaml b/Resources/config/services/form.yaml index 98eb210..7e3a8a8 100644 --- a/Resources/config/services/form.yaml +++ b/Resources/config/services/form.yaml @@ -1,15 +1,22 @@ parameters: - darvin_utils.form.integer_type_extension.class: Darvin\Utils\Form\Extension\IntegerTypeExtension + darvin_utils.form.extension.integer.class: Darvin\Utils\Form\Extension\IntegerTypeExtension - darvin_utils.form.number_type_extension.class: Darvin\Utils\Form\Extension\NumberTypeExtension + darvin_utils.form.extension.number.class: Darvin\Utils\Form\Extension\NumberTypeExtension + + darvin_utils.form.type.anti_spam.class: Darvin\Utils\Form\Type\AntiSpamType services: - darvin_utils.form.integer_type_extension: - class: '%darvin_utils.form.integer_type_extension.class%' + darvin_utils.form.extension.integer: + class: '%darvin_utils.form.extension.integer.class%' tags: - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\IntegerType } - darvin_utils.form.number_type_extension: - class: '%darvin_utils.form.number_type_extension.class%' + darvin_utils.form.extension.number: + class: '%darvin_utils.form.extension.number.class%' tags: - { name: form.type_extension, extended_type: Symfony\Component\Form\Extension\Core\Type\NumberType } + + darvin_utils.form.type.anti_spam: + class: '%darvin_utils.form.type.anti_spam.class%' + tags: + - { name: form.type } From 489a41749eb4579da73eca7a7af42f892c6acddf Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 18 Dec 2019 15:53:37 +0300 Subject: [PATCH 100/192] Allow to disable form component. --- DependencyInjection/DarvinUtilsExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 27efb13..4256569 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -81,7 +81,7 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { - if (!class_exists('Symfony\Component\Form\AbstractType')) { + if (!class_exists('Symfony\Component\Form\FormInterface')) { $container->prependExtensionConfig($this->getAlias(), [ 'form' => [ 'enabled' => false, From 2ee40bdede7955b2f328df9f4a23b4ef89584a86 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 18 Dec 2019 16:25:58 +0300 Subject: [PATCH 101/192] Allow to disable security component. --- CHANGELOG.md | 2 +- .../Compiler/CreateServiceProvidersPass.php | 3 +++ DependencyInjection/Configuration.php | 1 + DependencyInjection/DarvinUtilsExtension.php | 13 +++++++++++-- Resources/config/services/security.yaml | 9 +++++++++ Resources/config/services/user.yaml | 10 ---------- 6 files changed, 25 insertions(+), 13 deletions(-) delete mode 100644 Resources/config/services/user.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index ee462e0..850e408 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,4 +75,4 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.1: Add generic stringifier. -7.3.0: Allow to disable form component. +7.3.0: Allow to disable form, security components. diff --git a/DependencyInjection/Compiler/CreateServiceProvidersPass.php b/DependencyInjection/Compiler/CreateServiceProvidersPass.php index 5e14fc8..427b3fa 100644 --- a/DependencyInjection/Compiler/CreateServiceProvidersPass.php +++ b/DependencyInjection/Compiler/CreateServiceProvidersPass.php @@ -44,6 +44,9 @@ public function process(ContainerBuilder $container): void $definitions = []; foreach ($ids as $providerId => $id) { + if (!$container->hasDefinition($id)) { + continue; + } if ($container->hasDefinition($providerId)) { throw new \RuntimeException( sprintf('Unable to create provider for service "%s": service "%s" already exists.', $id, $providerId) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index b31683a..2328dc3 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -36,6 +36,7 @@ public function getConfigTreeBuilder(): TreeBuilder $root ->children() ->arrayNode('form')->canBeDisabled()->end() + ->arrayNode('security')->canBeDisabled()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 4256569..caf9e77 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -55,12 +55,10 @@ public function load(array $configs, ContainerBuilder $container): void 'orm', 'price', 'routing', - 'security', 'service', 'sluggable', 'stringifier', 'transliteratable', - 'user', 'dev/translation' => ['env' => 'dev'], @@ -72,6 +70,10 @@ public function load(array $configs, ContainerBuilder $container): void return $config['response']['compress']; }], + 'security' => ['callback' => function () use ($config) { + return $config['security']['enabled']; + }], + 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], ]); } @@ -88,6 +90,13 @@ public function prepend(ContainerBuilder $container): void ], ]); } + if (!class_exists('Symfony\Component\Security\Core\User\UserInterface')) { + $container->prependExtensionConfig($this->getAlias(), [ + 'security' => [ + 'enabled' => false, + ], + ]); + } (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', diff --git a/Resources/config/services/security.yaml b/Resources/config/services/security.yaml index 9f1f9f0..4cc5d7a 100644 --- a/Resources/config/services/security.yaml +++ b/Resources/config/services/security.yaml @@ -1,8 +1,17 @@ parameters: darvin_utils.security.accessibility_checker.class: Darvin\Utils\Security\Authorization\AccessibilityChecker + darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer + services: darvin_utils.security.accessibility_checker: class: '%darvin_utils.security.accessibility_checker.class%' arguments: - '@darvin_utils.authorization_checker.provider' + + darvin_utils.user.query_builder_filterer: + class: '%darvin_utils.user.query_builder_filterer.class%' + arguments: + - '@security.token_storage' + - '@security.authorization_checker' + - '@darvin_utils.mapping.metadata_factory' diff --git a/Resources/config/services/user.yaml b/Resources/config/services/user.yaml deleted file mode 100644 index 9993fe7..0000000 --- a/Resources/config/services/user.yaml +++ /dev/null @@ -1,10 +0,0 @@ -parameters: - darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer - -services: - darvin_utils.user.query_builder_filterer: - class: '%darvin_utils.user.query_builder_filterer.class%' - arguments: - - '@security.token_storage' - - '@security.authorization_checker' - - '@darvin_utils.mapping.metadata_factory' From 5ca15b0bc329155469ef475ac5cd21e9b52de6f9 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 18 Dec 2019 16:31:48 +0300 Subject: [PATCH 102/192] Fix extension. --- DependencyInjection/DarvinUtilsExtension.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index caf9e77..4447a1f 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -83,14 +83,14 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { - if (!class_exists('Symfony\Component\Form\FormInterface')) { + if (!interface_exists('Symfony\Component\Form\FormInterface')) { $container->prependExtensionConfig($this->getAlias(), [ 'form' => [ 'enabled' => false, ], ]); } - if (!class_exists('Symfony\Component\Security\Core\User\UserInterface')) { + if (!interface_exists('Symfony\Component\Security\Core\User\UserInterface')) { $container->prependExtensionConfig($this->getAlias(), [ 'security' => [ 'enabled' => false, From 4abe7eadf9db83ed8b7b96f25ea45373d0833d39 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 18 Dec 2019 16:36:51 +0300 Subject: [PATCH 103/192] Update changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 850e408..772b28a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,4 +75,4 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.1: Add generic stringifier. -7.3.0: Allow to disable form, security components. +7.2.2: Allow to disable form, security components. From ce67e72c4b025956a39704036f09598bfda5452a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:32:06 +0300 Subject: [PATCH 104/192] Add "symfony/orm-pack" to requirements. --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e051980..c2d1f75 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,9 @@ } ], "require": { - "twig/extensions": "^1.5", - "darvinstudio/darvin-utils": "*" + "darvinstudio/darvin-utils": "*", + "symfony/orm-pack": "*", + "twig/extensions": "^1.5" }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } From d32f99f532581adaad0943c2cdc4e8e33c00d03a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:33:50 +0300 Subject: [PATCH 105/192] Add "symfony/property-access" to requirements. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index c2d1f75..033b5df 100644 --- a/composer.json +++ b/composer.json @@ -14,6 +14,7 @@ "require": { "darvinstudio/darvin-utils": "*", "symfony/orm-pack": "*", + "symfony/property-access": "*", "twig/extensions": "^1.5" }, "autoload": { From 8e0ae148fff452a1aecae1721cdfef4dd880cc48 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:35:53 +0300 Subject: [PATCH 106/192] Define suggested packages. --- composer.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/composer.json b/composer.json index 033b5df..b8efb38 100644 --- a/composer.json +++ b/composer.json @@ -17,6 +17,10 @@ "symfony/property-access": "*", "twig/extensions": "^1.5" }, + "suggest": { + "symfony/form": "Allows to use form components", + "symfony/security-core": "Allows to use security components" + }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } } From 86be2213fe096419118a494f0887f84fd6482f61 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:38:05 +0300 Subject: [PATCH 107/192] Alias security services. --- Resources/config/services/security.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Resources/config/services/security.yaml b/Resources/config/services/security.yaml index 4cc5d7a..e68ed6e 100644 --- a/Resources/config/services/security.yaml +++ b/Resources/config/services/security.yaml @@ -4,6 +4,9 @@ parameters: darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer services: + Darvin\Utils\Security\Authorization\AccessibilityCheckerInterface: '@darvin_utils.security.accessibility_checker' + Darvin\Utils\User\UserQueryBuilderFiltererInterface: '@darvin_utils.user.query_builder_filterer' + darvin_utils.security.accessibility_checker: class: '%darvin_utils.security.accessibility_checker.class%' arguments: From 13502be9ac0843a11b3c8e337450be440ddd5f2b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:42:28 +0300 Subject: [PATCH 108/192] Make user query builder filterer optional in new entity counter. --- Resources/config/services/new_object.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Resources/config/services/new_object.yaml b/Resources/config/services/new_object.yaml index 0d33572..f311949 100644 --- a/Resources/config/services/new_object.yaml +++ b/Resources/config/services/new_object.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.new_object.counter.entity.class: Darvin\Utils\NewObject\NewEntityCounter services: + Darvin\Utils\NewObject\NewObjectCounterInterface: '@darvin_utils.new_object.counter.entity' + darvin_utils.new_object.counter: alias: darvin_utils.new_object.counter.entity @@ -10,4 +12,4 @@ services: arguments: - '@doctrine.orm.entity_manager' - '@darvin_utils.mapping.metadata_factory' - - '@darvin_utils.user.query_builder_filterer' + - '@?darvin_utils.user.query_builder_filterer' From dd0c12cccc48460766f670f8c3fb321275e3414e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:53:33 +0300 Subject: [PATCH 109/192] Move user services to separate config. --- DependencyInjection/Configuration.php | 1 + DependencyInjection/DarvinUtilsExtension.php | 11 ++++++++++- Resources/config/services/security.yaml | 10 ---------- Resources/config/services/user.yaml | 12 ++++++++++++ 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 Resources/config/services/user.yaml diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2328dc3..d1a32a6 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -37,6 +37,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->arrayNode('form')->canBeDisabled()->end() ->arrayNode('security')->canBeDisabled()->end() + ->arrayNode('user')->canBeDisabled()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 4447a1f..f0ea898 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -83,6 +83,8 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { + $securityCore = interface_exists('Symfony\Component\Security\Core\User\UserInterface'); + if (!interface_exists('Symfony\Component\Form\FormInterface')) { $container->prependExtensionConfig($this->getAlias(), [ 'form' => [ @@ -90,13 +92,20 @@ public function prepend(ContainerBuilder $container): void ], ]); } - if (!interface_exists('Symfony\Component\Security\Core\User\UserInterface')) { + if (!$securityCore) { $container->prependExtensionConfig($this->getAlias(), [ 'security' => [ 'enabled' => false, ], ]); } + if (!$securityCore) { + $container->prependExtensionConfig($this->getAlias(), [ + 'user' => [ + 'enabled' => false, + ], + ]); + } (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', diff --git a/Resources/config/services/security.yaml b/Resources/config/services/security.yaml index e68ed6e..dd97a44 100644 --- a/Resources/config/services/security.yaml +++ b/Resources/config/services/security.yaml @@ -1,20 +1,10 @@ parameters: darvin_utils.security.accessibility_checker.class: Darvin\Utils\Security\Authorization\AccessibilityChecker - darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer - services: Darvin\Utils\Security\Authorization\AccessibilityCheckerInterface: '@darvin_utils.security.accessibility_checker' - Darvin\Utils\User\UserQueryBuilderFiltererInterface: '@darvin_utils.user.query_builder_filterer' darvin_utils.security.accessibility_checker: class: '%darvin_utils.security.accessibility_checker.class%' arguments: - '@darvin_utils.authorization_checker.provider' - - darvin_utils.user.query_builder_filterer: - class: '%darvin_utils.user.query_builder_filterer.class%' - arguments: - - '@security.token_storage' - - '@security.authorization_checker' - - '@darvin_utils.mapping.metadata_factory' diff --git a/Resources/config/services/user.yaml b/Resources/config/services/user.yaml new file mode 100644 index 0000000..a6052ab --- /dev/null +++ b/Resources/config/services/user.yaml @@ -0,0 +1,12 @@ +parameters: + darvin_utils.user.query_builder_filterer.class: Darvin\Utils\User\UserQueryBuilderFilterer + +services: + Darvin\Utils\User\UserQueryBuilderFiltererInterface: '@darvin_utils.user.query_builder_filterer' + + darvin_utils.user.query_builder_filterer: + class: '%darvin_utils.user.query_builder_filterer.class%' + arguments: + - '@security.token_storage' + - '@security.authorization_checker' + - '@darvin_utils.mapping.metadata_factory' From 47134952badbfc5e9966c66452312fb5bb5274c7 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Dec 2019 08:54:37 +0300 Subject: [PATCH 110/192] Fix extension. --- DependencyInjection/DarvinUtilsExtension.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index f0ea898..d31e83b 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -75,6 +75,10 @@ public function load(array $configs, ContainerBuilder $container): void }], 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], + + 'user' => ['callback' => function () use ($config) { + return $config['user']['enabled']; + }], ]); } From 4bf2b93cf5012c7de168950ad66c36c863879c2b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 20 Dec 2019 16:09:22 +0300 Subject: [PATCH 111/192] Remove Intl Twig functions. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 1 - Resources/config/services/intl.yaml | 8 -------- composer.json | 3 +-- 4 files changed, 3 insertions(+), 11 deletions(-) delete mode 100644 Resources/config/services/intl.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 772b28a..ba841c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,3 +76,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.1: Add generic stringifier. 7.2.2: Allow to disable form, security components. + +7.?.?: Remove Intl Twig functions. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index d31e83b..7727c08 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -47,7 +47,6 @@ public function load(array $configs, ContainerBuilder $container): void 'default_value', 'flash', 'homepage', - 'intl', 'locale', 'mapping', 'new_object', diff --git a/Resources/config/services/intl.yaml b/Resources/config/services/intl.yaml deleted file mode 100644 index 3cc434b..0000000 --- a/Resources/config/services/intl.yaml +++ /dev/null @@ -1,8 +0,0 @@ -parameters: - darvin_utils.intl.twig_extension.class: Twig_Extensions_Extension_Intl - -services: - darvin_utils.intl.twig_extension: - class: '%darvin_utils.intl.twig_extension.class%' - tags: - - { name: twig.extension } diff --git a/composer.json b/composer.json index b8efb38..fc317e7 100644 --- a/composer.json +++ b/composer.json @@ -14,8 +14,7 @@ "require": { "darvinstudio/darvin-utils": "*", "symfony/orm-pack": "*", - "symfony/property-access": "*", - "twig/extensions": "^1.5" + "symfony/property-access": "*" }, "suggest": { "symfony/form": "Allows to use form components", From 67933cb65090514c3e83a876c878dede5911e677 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 20 Dec 2019 16:36:20 +0300 Subject: [PATCH 112/192] Refactor extension. --- DependencyInjection/DarvinUtilsExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 7727c08..e2e4e0c 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -88,7 +88,7 @@ public function prepend(ContainerBuilder $container): void { $securityCore = interface_exists('Symfony\Component\Security\Core\User\UserInterface'); - if (!interface_exists('Symfony\Component\Form\FormInterface')) { + if (!class_exists('Symfony\Component\Form\Form')) { $container->prependExtensionConfig($this->getAlias(), [ 'form' => [ 'enabled' => false, From 82e12e70fbbdfdd73f6a1a4f12f11a8e9c3e55cc Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 20 Dec 2019 16:38:46 +0300 Subject: [PATCH 113/192] Refactor extension. --- DependencyInjection/DarvinUtilsExtension.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index e2e4e0c..b6be7af 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -86,23 +86,24 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { - $securityCore = interface_exists('Symfony\Component\Security\Core\User\UserInterface'); + $formInstalled = class_exists('Symfony\Component\Form\Form'); + $securityInstalled = class_exists('Symfony\Component\Security\Core\Security'); - if (!class_exists('Symfony\Component\Form\Form')) { + if (!$formInstalled) { $container->prependExtensionConfig($this->getAlias(), [ 'form' => [ 'enabled' => false, ], ]); } - if (!$securityCore) { + if (!$securityInstalled) { $container->prependExtensionConfig($this->getAlias(), [ 'security' => [ 'enabled' => false, ], ]); } - if (!$securityCore) { + if (!$securityInstalled) { $container->prependExtensionConfig($this->getAlias(), [ 'user' => [ 'enabled' => false, From 4cd949682a31ea6e97b9391db3fbe392efb41e2e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 08:36:27 +0300 Subject: [PATCH 114/192] Refactor extension. --- DependencyInjection/Configuration.php | 3 -- DependencyInjection/DarvinUtilsExtension.php | 40 +++----------------- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index d1a32a6..7d6c045 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -35,9 +35,6 @@ public function getConfigTreeBuilder(): TreeBuilder // more information on that topic. $root ->children() - ->arrayNode('form')->canBeDisabled()->end() - ->arrayNode('security')->canBeDisabled()->end() - ->arrayNode('user')->canBeDisabled()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index b6be7af..287cf1f 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -29,6 +29,9 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; + private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; + private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; + /** * {@inheritDoc} */ @@ -61,23 +64,17 @@ public function load(array $configs, ContainerBuilder $container): void 'dev/translation' => ['env' => 'dev'], - 'form' => ['callback' => function () use ($config) { - return $config['form']['enabled']; - }], + 'form' => ['class' => self::COMPONENT_FORM], 'response/compress' => ['callback' => function () use ($config) { return $config['response']['compress']; }], - 'security' => ['callback' => function () use ($config) { - return $config['security']['enabled']; - }], + 'security' => ['class' => self::COMPONENT_SECURITY], 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], - 'user' => ['callback' => function () use ($config) { - return $config['user']['enabled']; - }], + 'user' => ['class' => self::COMPONENT_SECURITY], ]); } @@ -86,31 +83,6 @@ public function load(array $configs, ContainerBuilder $container): void */ public function prepend(ContainerBuilder $container): void { - $formInstalled = class_exists('Symfony\Component\Form\Form'); - $securityInstalled = class_exists('Symfony\Component\Security\Core\Security'); - - if (!$formInstalled) { - $container->prependExtensionConfig($this->getAlias(), [ - 'form' => [ - 'enabled' => false, - ], - ]); - } - if (!$securityInstalled) { - $container->prependExtensionConfig($this->getAlias(), [ - 'security' => [ - 'enabled' => false, - ], - ]); - } - if (!$securityInstalled) { - $container->prependExtensionConfig($this->getAlias(), [ - 'user' => [ - 'enabled' => false, - ], - ]); - } - (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', 'stof_doctrine_extensions', From 9e6262b447750b3c3937a032c454abc31bed6567 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 08:39:19 +0300 Subject: [PATCH 115/192] Update changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba841c1..857acc5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,4 +77,4 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.2: Allow to disable form, security components. -7.?.?: Remove Intl Twig functions. +7.2.4: Remove Intl Twig functions. From 34499bd8379f98a771d59515c1ae46e7867f59b2 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 09:47:45 +0300 Subject: [PATCH 116/192] Make Twig optional. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 7 +++++-- Resources/config/services/object_namer/common.yaml | 8 ++++++++ .../{object_namer.yaml => object_namer/twig.yaml} | 5 ----- Resources/config/services/price.yaml | 2 ++ composer.json | 5 +++-- 6 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 Resources/config/services/object_namer/common.yaml rename Resources/config/services/{object_namer.yaml => object_namer/twig.yaml} (68%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 857acc5..f312ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,3 +78,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.2: Allow to disable form, security components. 7.2.4: Remove Intl Twig functions. + +7.2.5: Make Twig optional. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 287cf1f..2eb8d75 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -53,9 +53,8 @@ public function load(array $configs, ContainerBuilder $container): void 'locale', 'mapping', 'new_object', - 'object_namer', + 'object_namer/common', 'orm', - 'price', 'routing', 'service', 'sluggable', @@ -66,6 +65,10 @@ public function load(array $configs, ContainerBuilder $container): void 'form' => ['class' => self::COMPONENT_FORM], + 'object_namer/twig' => ['bundle' => 'TwigBundle'], + + 'price' => ['bundle' => 'TwigBundle'], + 'response/compress' => ['callback' => function () use ($config) { return $config['response']['compress']; }], diff --git a/Resources/config/services/object_namer/common.yaml b/Resources/config/services/object_namer/common.yaml new file mode 100644 index 0000000..e5359f5 --- /dev/null +++ b/Resources/config/services/object_namer/common.yaml @@ -0,0 +1,8 @@ +parameters: + darvin_utils.object_namer.class: Darvin\Utils\ObjectNamer\ObjectNamer + +services: + Darvin\Utils\ObjectNamer\ObjectNamerInterface: '@darvin_utils.object_namer' + + darvin_utils.object_namer: + class: '%darvin_utils.object_namer.class%' diff --git a/Resources/config/services/object_namer.yaml b/Resources/config/services/object_namer/twig.yaml similarity index 68% rename from Resources/config/services/object_namer.yaml rename to Resources/config/services/object_namer/twig.yaml index 9419d45..22b16e8 100644 --- a/Resources/config/services/object_namer.yaml +++ b/Resources/config/services/object_namer/twig.yaml @@ -1,12 +1,7 @@ parameters: - darvin_utils.object_namer.class: Darvin\Utils\ObjectNamer\ObjectNamer - darvin_utils.object_namer.twig_extension.class: Darvin\Utils\Twig\Extension\ObjectNamerExtension services: - darvin_utils.object_namer: - class: '%darvin_utils.object_namer.class%' - darvin_utils.object_namer.twig_extension: class: '%darvin_utils.object_namer.twig_extension.class%' arguments: diff --git a/Resources/config/services/price.yaml b/Resources/config/services/price.yaml index 45d6a04..fc20e17 100644 --- a/Resources/config/services/price.yaml +++ b/Resources/config/services/price.yaml @@ -4,6 +4,8 @@ parameters: darvin_utils.price.twig_extension.class: Darvin\Utils\Twig\Extension\PriceExtension services: + Darvin\Utils\Price\PriceFormatterInterface: '@darvin_utils.price.formatter' + darvin_utils.price.formatter: class: '%darvin_utils.price.formatter.class%' arguments: diff --git a/composer.json b/composer.json index fc317e7..a6a139e 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,9 @@ "symfony/property-access": "*" }, "suggest": { - "symfony/form": "Allows to use form components", - "symfony/security-core": "Allows to use security components" + "symfony/form": "Allows to use form dependent components", + "symfony/security-core": "Allows to use security dependent components", + "symfony/twig-bundle": "Allows to use Twig dependent components" }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } From cdab699c0a915aeb7e644e96ca95716aad72ef91 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:00:13 +0300 Subject: [PATCH 117/192] Make translation component optional. --- DependencyInjection/DarvinUtilsExtension.php | 8 +++++--- composer.json | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 2eb8d75..3893e1a 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -29,8 +29,9 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; - private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; - private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; + private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; + private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; + private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; /** * {@inheritDoc} @@ -58,7 +59,6 @@ public function load(array $configs, ContainerBuilder $container): void 'routing', 'service', 'sluggable', - 'stringifier', 'transliteratable', 'dev/translation' => ['env' => 'dev'], @@ -75,6 +75,8 @@ public function load(array $configs, ContainerBuilder $container): void 'security' => ['class' => self::COMPONENT_SECURITY], + 'stringifier' => ['class' => self::COMPONENT_TRANSLATION], + 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], 'user' => ['class' => self::COMPONENT_SECURITY], diff --git a/composer.json b/composer.json index a6a139e..92e0396 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,7 @@ "suggest": { "symfony/form": "Allows to use form dependent components", "symfony/security-core": "Allows to use security dependent components", + "symfony/translation": "Allows to use translation dependent components", "symfony/twig-bundle": "Allows to use Twig dependent components" }, "autoload": { From c1638eecf7d6c7dc5f75f2f79cd7d791f74ca75d Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:24:40 +0300 Subject: [PATCH 118/192] Make PropertyAccess component optional. --- .../Compiler/AddSlugHandlersPass.php | 8 ++++++- DependencyInjection/DarvinUtilsExtension.php | 23 ++++++++++++------- Resources/config/services/cloner.yaml | 2 ++ Resources/config/services/custom_object.yaml | 2 ++ Resources/config/services/sluggable.yaml | 2 ++ .../config/services/transliteratable.yaml | 17 -------------- .../services/transliteratable/common.yaml | 8 +++++++ .../services/transliteratable/subscriber.yaml | 12 ++++++++++ composer.json | 12 +++++----- 9 files changed, 54 insertions(+), 32 deletions(-) delete mode 100644 Resources/config/services/transliteratable.yaml create mode 100644 Resources/config/services/transliteratable/common.yaml create mode 100644 Resources/config/services/transliteratable/subscriber.yaml diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index 5b0b673..033694a 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -20,12 +20,18 @@ */ class AddSlugHandlersPass implements CompilerPassInterface { + private const ID = 'darvin_utils.sluggable.manager.entity'; + /** * {@inheritDoc} */ public function process(ContainerBuilder $container): void { - $manager = $container->getDefinition('darvin_utils.sluggable.manager.entity'); + if (!$container->hasDefinition(self::ID)) { + return; + } + + $manager = $container->getDefinition(self::ID); foreach (array_keys((new ServiceSorter())->sort($container->findTaggedServiceIds('darvin_utils.slug_handler'))) as $id) { $manager->addMethodCall('addSlugHandler', [new Reference($id)]); diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 3893e1a..a08d9f6 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -29,9 +29,10 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; - private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; - private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; - private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; + private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; + private const COMPONENT_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; + private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; + private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; /** * {@inheritDoc} @@ -46,9 +47,6 @@ public function load(array $configs, ContainerBuilder $container): void (new ConfigInjector($container))->inject($config, $this->getAlias()); (new ConfigLoader($container, __DIR__.'/../Resources/config/services'))->load([ - 'cloner', - 'custom_object', - 'default_value', 'flash', 'homepage', 'locale', @@ -58,8 +56,13 @@ public function load(array $configs, ContainerBuilder $container): void 'orm', 'routing', 'service', - 'sluggable', - 'transliteratable', + 'transliteratable/common', + + 'cloner' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + + 'custom_object' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + + 'default_value' => ['class' => self::COMPONENT_PROPERTY_ACCESS], 'dev/translation' => ['env' => 'dev'], @@ -75,8 +78,12 @@ public function load(array $configs, ContainerBuilder $container): void 'security' => ['class' => self::COMPONENT_SECURITY], + 'sluggable' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'stringifier' => ['class' => self::COMPONENT_TRANSLATION], + 'transliteratable/subscriber' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], 'user' => ['class' => self::COMPONENT_SECURITY], diff --git a/Resources/config/services/cloner.yaml b/Resources/config/services/cloner.yaml index e66b082..51d7569 100644 --- a/Resources/config/services/cloner.yaml +++ b/Resources/config/services/cloner.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.cloner.class: Darvin\Utils\Cloner\Cloner services: + Darvin\Utils\Cloner\ClonerInterface: '@darvin_utils.cloner' + darvin_utils.cloner: class: '%darvin_utils.cloner.class%' arguments: diff --git a/Resources/config/services/custom_object.yaml b/Resources/config/services/custom_object.yaml index d12022a..0e89116 100644 --- a/Resources/config/services/custom_object.yaml +++ b/Resources/config/services/custom_object.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.custom_object.loader.entity.class: Darvin\Utils\CustomObject\CustomEntityLoader services: + Darvin\Utils\CustomObject\CustomObjectLoaderInterface: '@darvin_utils.custom_object.loader.entity' + darvin_utils.custom_object.loader: alias: darvin_utils.custom_object.loader.entity diff --git a/Resources/config/services/sluggable.yaml b/Resources/config/services/sluggable.yaml index 2206249..5a14bc4 100644 --- a/Resources/config/services/sluggable.yaml +++ b/Resources/config/services/sluggable.yaml @@ -4,6 +4,8 @@ parameters: darvin_utils.sluggable.slugify_event_subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber services: + Darvin\Utils\Sluggable\SluggableManagerInterface: '@darvin_utils.sluggable.manager.entity' + darvin_utils.sluggable.manager: alias: darvin_utils.sluggable.manager.entity diff --git a/Resources/config/services/transliteratable.yaml b/Resources/config/services/transliteratable.yaml deleted file mode 100644 index bb92634..0000000 --- a/Resources/config/services/transliteratable.yaml +++ /dev/null @@ -1,17 +0,0 @@ -parameters: - darvin_utils.transliteratable.transliterate_event_subscriber.class: Darvin\Utils\EventListener\TransliterateSubscriber - - darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator - -services: - darvin_utils.transliteratable.transliterate_event_subscriber: - class: '%darvin_utils.transliteratable.transliterate_event_subscriber.class%' - arguments: - - '@darvin_utils.mapping.metadata_factory' - - '@property_accessor' - - '@darvin_utils.transliteratable.transliterator' - tags: - - { name: doctrine.event_subscriber, priority: 300 } - - darvin_utils.transliteratable.transliterator: - class: '%darvin_utils.transliteratable.transliterator.class%' diff --git a/Resources/config/services/transliteratable/common.yaml b/Resources/config/services/transliteratable/common.yaml new file mode 100644 index 0000000..c72b37f --- /dev/null +++ b/Resources/config/services/transliteratable/common.yaml @@ -0,0 +1,8 @@ +parameters: + darvin_utils.transliteratable.transliterator.class: Darvin\Utils\Transliteratable\Transliterator + +services: + Darvin\Utils\Transliteratable\TransliteratorInterface: '@darvin_utils.transliteratable.transliterator' + + darvin_utils.transliteratable.transliterator: + class: '%darvin_utils.transliteratable.transliterator.class%' diff --git a/Resources/config/services/transliteratable/subscriber.yaml b/Resources/config/services/transliteratable/subscriber.yaml new file mode 100644 index 0000000..b715a6a --- /dev/null +++ b/Resources/config/services/transliteratable/subscriber.yaml @@ -0,0 +1,12 @@ +parameters: + darvin_utils.transliteratable.subscriber.class: Darvin\Utils\EventListener\TransliterateSubscriber + +services: + darvin_utils.transliteratable.subscriber: + class: '%darvin_utils.transliteratable.subscriber.class%' + arguments: + - '@darvin_utils.mapping.metadata_factory' + - '@property_accessor' + - '@darvin_utils.transliteratable.transliterator' + tags: + - { name: doctrine.event_subscriber, priority: 300 } diff --git a/composer.json b/composer.json index 92e0396..35520b7 100644 --- a/composer.json +++ b/composer.json @@ -13,14 +13,14 @@ ], "require": { "darvinstudio/darvin-utils": "*", - "symfony/orm-pack": "*", - "symfony/property-access": "*" + "symfony/orm-pack": "*" }, "suggest": { - "symfony/form": "Allows to use form dependent components", - "symfony/security-core": "Allows to use security dependent components", - "symfony/translation": "Allows to use translation dependent components", - "symfony/twig-bundle": "Allows to use Twig dependent components" + "symfony/form": "Allows to use Form dependent components", + "symfony/property-access": "Allows to use PropertyAccess dependent components", + "symfony/security-core": "Allows to use Security dependent components", + "symfony/translation": "Allows to use Translation dependent components", + "symfony/twig-bundle": "Allows to use Twig dependent components" }, "autoload": { "psr-4": { "Darvin\\UtilsBundle\\": "" } From 5ff897eab691bc3dd798497c15970d3c44eb8f4e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:25:26 +0300 Subject: [PATCH 119/192] Update changelog. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f312ebf..39c3817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,4 +79,4 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.4: Remove Intl Twig functions. -7.2.5: Make Twig optional. +7.2.5: Make Twig, Translation and PropertyAccess components optional. From 90dc9ec92c9e273e8ab68e75950f0449b216e30f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:33:58 +0300 Subject: [PATCH 120/192] Fix deps. --- DependencyInjection/DarvinUtilsExtension.php | 5 ++--- composer.json | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index a08d9f6..83d0e81 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -31,7 +31,6 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; private const COMPONENT_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; - private const COMPONENT_SECURITY = 'Symfony\Component\Security\Core\Security'; private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; /** @@ -76,7 +75,7 @@ public function load(array $configs, ContainerBuilder $container): void return $config['response']['compress']; }], - 'security' => ['class' => self::COMPONENT_SECURITY], + 'security' => ['bundle' => 'SecurityBundle'], 'sluggable' => ['class' => self::COMPONENT_PROPERTY_ACCESS], @@ -86,7 +85,7 @@ public function load(array $configs, ContainerBuilder $container): void 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], - 'user' => ['class' => self::COMPONENT_SECURITY], + 'user' => ['bundle' => 'SecurityBundle'], ]); } diff --git a/composer.json b/composer.json index 35520b7..833240f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "suggest": { "symfony/form": "Allows to use Form dependent components", "symfony/property-access": "Allows to use PropertyAccess dependent components", - "symfony/security-core": "Allows to use Security dependent components", + "symfony/security-bundle": "Allows to use Security dependent components", "symfony/translation": "Allows to use Translation dependent components", "symfony/twig-bundle": "Allows to use Twig dependent components" }, From 828d4cc416eda080135d619f0d30e19a0ad5a092 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:38:35 +0300 Subject: [PATCH 121/192] Refactor extension. --- DependencyInjection/DarvinUtilsExtension.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 83d0e81..738b424 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -29,6 +29,10 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; + private const BUNDLE_DOCTRINE_EXTENSIONS = 'StofDoctrineExtensionsBundle'; + private const BUNDLE_SECURITY = 'SecurityBundle'; + private const BUNDLE_TWIG = 'TwigBundle'; + private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; private const COMPONENT_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; @@ -67,15 +71,15 @@ public function load(array $configs, ContainerBuilder $container): void 'form' => ['class' => self::COMPONENT_FORM], - 'object_namer/twig' => ['bundle' => 'TwigBundle'], + 'object_namer/twig' => ['bundle' => self::BUNDLE_TWIG], - 'price' => ['bundle' => 'TwigBundle'], + 'price' => ['bundle' => self::BUNDLE_TWIG], 'response/compress' => ['callback' => function () use ($config) { return $config['response']['compress']; }], - 'security' => ['bundle' => 'SecurityBundle'], + 'security' => ['bundle' => self::BUNDLE_SECURITY], 'sluggable' => ['class' => self::COMPONENT_PROPERTY_ACCESS], @@ -83,9 +87,9 @@ public function load(array $configs, ContainerBuilder $container): void 'transliteratable/subscriber' => ['class' => self::COMPONENT_PROPERTY_ACCESS], - 'tree' => ['bundle' => 'StofDoctrineExtensionsBundle'], + 'tree' => ['bundle' => self::BUNDLE_DOCTRINE_EXTENSIONS, 'class' => self::COMPONENT_PROPERTY_ACCESS], - 'user' => ['bundle' => 'SecurityBundle'], + 'user' => ['bundle' => self::BUNDLE_SECURITY], ]); } From 76fc19f1b37d0136df63448e2262bd5bf639978d Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 11:43:01 +0300 Subject: [PATCH 122/192] Refactor extension. --- DependencyInjection/DarvinUtilsExtension.php | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 738b424..1662392 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -33,9 +33,9 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac private const BUNDLE_SECURITY = 'SecurityBundle'; private const BUNDLE_TWIG = 'TwigBundle'; - private const COMPONENT_FORM = 'Symfony\Component\Form\Form'; - private const COMPONENT_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; - private const COMPONENT_TRANSLATION = 'Symfony\Component\Translation\Translator'; + private const CLASS_FORM = 'Symfony\Component\Form\Form'; + private const CLASS_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; + private const CLASS_TRANSLATION = 'Symfony\Component\Translation\Translator'; /** * {@inheritDoc} @@ -61,15 +61,15 @@ public function load(array $configs, ContainerBuilder $container): void 'service', 'transliteratable/common', - 'cloner' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'cloner' => ['class' => self::CLASS_PROPERTY_ACCESS], - 'custom_object' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'custom_object' => ['class' => self::CLASS_PROPERTY_ACCESS], - 'default_value' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'default_value' => ['class' => self::CLASS_PROPERTY_ACCESS], 'dev/translation' => ['env' => 'dev'], - 'form' => ['class' => self::COMPONENT_FORM], + 'form' => ['class' => self::CLASS_FORM], 'object_namer/twig' => ['bundle' => self::BUNDLE_TWIG], @@ -81,13 +81,13 @@ public function load(array $configs, ContainerBuilder $container): void 'security' => ['bundle' => self::BUNDLE_SECURITY], - 'sluggable' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'sluggable' => ['class' => self::CLASS_PROPERTY_ACCESS], - 'stringifier' => ['class' => self::COMPONENT_TRANSLATION], + 'stringifier' => ['class' => self::CLASS_TRANSLATION], - 'transliteratable/subscriber' => ['class' => self::COMPONENT_PROPERTY_ACCESS], + 'transliteratable/subscriber' => ['class' => self::CLASS_PROPERTY_ACCESS], - 'tree' => ['bundle' => self::BUNDLE_DOCTRINE_EXTENSIONS, 'class' => self::COMPONENT_PROPERTY_ACCESS], + 'tree' => ['bundle' => self::BUNDLE_DOCTRINE_EXTENSIONS, 'class' => self::CLASS_PROPERTY_ACCESS], 'user' => ['bundle' => self::BUNDLE_SECURITY], ]); From 010869463dfb262313564216f7e08eec25e237b0 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 13:36:13 +0300 Subject: [PATCH 123/192] Alias services. --- Resources/config/services/flash.yaml | 2 ++ Resources/config/services/homepage.yaml | 3 +++ Resources/config/services/locale.yaml | 2 ++ Resources/config/services/mapping.yaml | 2 ++ Resources/config/services/new_object.yaml | 2 +- Resources/config/services/orm.yaml | 2 ++ Resources/config/services/routing.yaml | 18 ++++++++++-------- 7 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Resources/config/services/flash.yaml b/Resources/config/services/flash.yaml index 48859d8..d3f88a6 100644 --- a/Resources/config/services/flash.yaml +++ b/Resources/config/services/flash.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.flash.notifier.class: Darvin\Utils\Flash\FlashNotifier services: + Darvin\Utils\Flash\FlashNotifierInterface: '@darvin_utils.flash.notifier' + darvin_utils.flash.notifier: class: '%darvin_utils.flash.notifier.class%' arguments: diff --git a/Resources/config/services/homepage.yaml b/Resources/config/services/homepage.yaml index d57bdf3..3d08221 100644 --- a/Resources/config/services/homepage.yaml +++ b/Resources/config/services/homepage.yaml @@ -4,6 +4,9 @@ parameters: darvin_utils.homepage.dummy_router.class: Darvin\Utils\Homepage\DummyHomepageRouter services: + Darvin\Utils\Homepage\HomepageProviderInterface: '@darvin_utils.homepage.provider' + Darvin\Utils\Homepage\HomepageRouterInterface: '@darvin_utils.homepage.router' + darvin_utils.homepage.provider: alias: darvin_utils.homepage.dummy_provider diff --git a/Resources/config/services/locale.yaml b/Resources/config/services/locale.yaml index 590c726..5d25752 100644 --- a/Resources/config/services/locale.yaml +++ b/Resources/config/services/locale.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.locale.provider.class: Darvin\Utils\Locale\LocaleProvider services: + Darvin\Utils\Locale\LocaleProviderInterface: '@darvin_utils.locale.provider' + darvin_utils.locale.provider: class: '%darvin_utils.locale.provider.class%' public: true diff --git a/Resources/config/services/mapping.yaml b/Resources/config/services/mapping.yaml index 863ecb9..1f751d1 100644 --- a/Resources/config/services/mapping.yaml +++ b/Resources/config/services/mapping.yaml @@ -22,6 +22,8 @@ parameters: darvin_utils.mapping.set_default_discriminator_listener.class: Darvin\Utils\EventListener\SetDefaultDiscriminatorListener services: + Darvin\Utils\Mapping\MetadataFactoryInterface: '@darvin_utils.mapping.metadata_factory' + darvin_utils.mapping.annotation_driver.abstract: class: '%darvin_utils.mapping.annotation_driver.abstract.class%' abstract: true diff --git a/Resources/config/services/new_object.yaml b/Resources/config/services/new_object.yaml index f311949..5b2733d 100644 --- a/Resources/config/services/new_object.yaml +++ b/Resources/config/services/new_object.yaml @@ -2,7 +2,7 @@ parameters: darvin_utils.new_object.counter.entity.class: Darvin\Utils\NewObject\NewEntityCounter services: - Darvin\Utils\NewObject\NewObjectCounterInterface: '@darvin_utils.new_object.counter.entity' + Darvin\Utils\NewObject\NewObjectCounterInterface: '@darvin_utils.new_object.counter' darvin_utils.new_object.counter: alias: darvin_utils.new_object.counter.entity diff --git a/Resources/config/services/orm.yaml b/Resources/config/services/orm.yaml index 55b2ce9..b664e14 100644 --- a/Resources/config/services/orm.yaml +++ b/Resources/config/services/orm.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.orm.entity_resolver.class: Darvin\Utils\ORM\EntityResolver services: + Darvin\Utils\ORM\EntityResolverInterface: '@darvin_utils.orm.entity_resolver' + darvin_utils.orm.entity_resolver: class: '%darvin_utils.orm.entity_resolver.class%' public: true diff --git a/Resources/config/services/routing.yaml b/Resources/config/services/routing.yaml index 63f055c..619b928 100644 --- a/Resources/config/services/routing.yaml +++ b/Resources/config/services/routing.yaml @@ -1,15 +1,10 @@ parameters: - darvin_utils.routing.route_cache_warmer.class: Darvin\Utils\Routing\RouteCacheWarmer - darvin_utils.routing.route_manager.cached.class: Darvin\Utils\Routing\CachedRouteManager + darvin_utils.routing.route_cache_warmer.class: Darvin\Utils\Routing\RouteCacheWarmer + services: - darvin_utils.routing.route_cache_warmer: - class: '%darvin_utils.routing.route_cache_warmer.class%' - arguments: - - '@darvin_utils.routing.route_manager.cached' - tags: - - { name: kernel.cache_warmer } + Darvin\Utils\Routing\RouteManagerInterface: '@darvin_utils.routing.route_manager' darvin_utils.routing.route_manager: alias: darvin_utils.routing.route_manager.cached @@ -22,3 +17,10 @@ services: - '%kernel.cache_dir%/darvin_utils/routes.php' - '%kernel.debug%' - '%locales%' + + darvin_utils.routing.route_cache_warmer: + class: '%darvin_utils.routing.route_cache_warmer.class%' + arguments: + - '@darvin_utils.routing.route_manager.cached' + tags: + - { name: kernel.cache_warmer } From 34da19cc1547976b74dc65d98837eff41c3203eb Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 13:40:24 +0300 Subject: [PATCH 124/192] Alias services. --- Resources/config/services/custom_object.yaml | 2 +- Resources/config/services/default_value.yaml | 6 +++--- Resources/config/services/response/compress.yaml | 6 +++--- Resources/config/services/sluggable.yaml | 8 ++++---- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Resources/config/services/custom_object.yaml b/Resources/config/services/custom_object.yaml index 0e89116..d15221e 100644 --- a/Resources/config/services/custom_object.yaml +++ b/Resources/config/services/custom_object.yaml @@ -2,7 +2,7 @@ parameters: darvin_utils.custom_object.loader.entity.class: Darvin\Utils\CustomObject\CustomEntityLoader services: - Darvin\Utils\CustomObject\CustomObjectLoaderInterface: '@darvin_utils.custom_object.loader.entity' + Darvin\Utils\CustomObject\CustomObjectLoaderInterface: '@darvin_utils.custom_object.loader' darvin_utils.custom_object.loader: alias: darvin_utils.custom_object.loader.entity diff --git a/Resources/config/services/default_value.yaml b/Resources/config/services/default_value.yaml index 763b60c..170f658 100644 --- a/Resources/config/services/default_value.yaml +++ b/Resources/config/services/default_value.yaml @@ -1,9 +1,9 @@ parameters: - darvin_utils.default_value.set_event_subscriber.class: Darvin\Utils\EventListener\SetDefaultValuesSubscriber + darvin_utils.default_value.subscriber.class: Darvin\Utils\EventListener\SetDefaultValuesSubscriber services: - darvin_utils.default_value.set_event_subscriber: - class: '%darvin_utils.default_value.set_event_subscriber.class%' + darvin_utils.default_value.subscriber: + class: '%darvin_utils.default_value.subscriber.class%' arguments: - '@darvin_utils.mapping.metadata_factory' - '@property_accessor' diff --git a/Resources/config/services/response/compress.yaml b/Resources/config/services/response/compress.yaml index 8d78c9b..9ae88c5 100644 --- a/Resources/config/services/response/compress.yaml +++ b/Resources/config/services/response/compress.yaml @@ -1,8 +1,8 @@ parameters: - darvin_utils.response.compress.event_subscriber.class: Darvin\Utils\EventListener\CompressResponseSubscriber + darvin_utils.response.compress.subscriber.class: Darvin\Utils\EventListener\CompressResponseSubscriber services: - darvin_utils.response.compress.event_subscriber: - class: '%darvin_utils.response.compress.event_subscriber.class%' + darvin_utils.response.compress.subscriber: + class: '%darvin_utils.response.compress.subscriber.class%' tags: - { name: kernel.event_subscriber } diff --git a/Resources/config/services/sluggable.yaml b/Resources/config/services/sluggable.yaml index 5a14bc4..242f247 100644 --- a/Resources/config/services/sluggable.yaml +++ b/Resources/config/services/sluggable.yaml @@ -1,10 +1,10 @@ parameters: darvin_utils.sluggable.manager.entity.class: Darvin\Utils\Sluggable\SluggableEntityManager - darvin_utils.sluggable.slugify_event_subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber + darvin_utils.sluggable.subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber services: - Darvin\Utils\Sluggable\SluggableManagerInterface: '@darvin_utils.sluggable.manager.entity' + Darvin\Utils\Sluggable\SluggableManagerInterface: '@darvin_utils.sluggable.manager' darvin_utils.sluggable.manager: alias: darvin_utils.sluggable.manager.entity @@ -17,8 +17,8 @@ services: - '@darvin_utils.mapping.metadata_factory' - '@property_accessor' - darvin_utils.sluggable.slugify_event_subscriber: - class: '%darvin_utils.sluggable.slugify_event_subscriber.class%' + darvin_utils.sluggable.subscriber: + class: '%darvin_utils.sluggable.subscriber.class%' arguments: - '@darvin_utils.entity_manager.provider' - '@darvin_utils.sluggable.manager' From c34cc8603e4d4d6cab194626bce7d85c05878cb6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 13:44:07 +0300 Subject: [PATCH 125/192] Rename services. --- Resources/config/services/homepage.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Resources/config/services/homepage.yaml b/Resources/config/services/homepage.yaml index 3d08221..a59d2c4 100644 --- a/Resources/config/services/homepage.yaml +++ b/Resources/config/services/homepage.yaml @@ -1,20 +1,20 @@ parameters: - darvin_utils.homepage.dummy_provider.class: Darvin\Utils\Homepage\DummyHomepageProvider + darvin_utils.homepage.provider.dummy.class: Darvin\Utils\Homepage\DummyHomepageProvider - darvin_utils.homepage.dummy_router.class: Darvin\Utils\Homepage\DummyHomepageRouter + darvin_utils.homepage.router.dummy.class: Darvin\Utils\Homepage\DummyHomepageRouter services: Darvin\Utils\Homepage\HomepageProviderInterface: '@darvin_utils.homepage.provider' Darvin\Utils\Homepage\HomepageRouterInterface: '@darvin_utils.homepage.router' darvin_utils.homepage.provider: - alias: darvin_utils.homepage.dummy_provider + alias: darvin_utils.homepage.provider.dummy - darvin_utils.homepage.dummy_provider: - class: '%darvin_utils.homepage.dummy_provider.class%' + darvin_utils.homepage.provider.dummy: + class: '%darvin_utils.homepage.provider.dummy.class%' darvin_utils.homepage.router: - alias: darvin_utils.homepage.dummy_router + alias: darvin_utils.homepage.router.dummy - darvin_utils.homepage.dummy_router: - class: '%darvin_utils.homepage.dummy_router.class%' + darvin_utils.homepage.router.dummy: + class: '%darvin_utils.homepage.router.dummy.class%' From 1132e1dd273ca14604aa41bcf287875a713fb26a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 23 Dec 2019 13:54:11 +0300 Subject: [PATCH 126/192] Alias services. --- Resources/config/services/sluggable.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Resources/config/services/sluggable.yaml b/Resources/config/services/sluggable.yaml index 242f247..12e6ef9 100644 --- a/Resources/config/services/sluggable.yaml +++ b/Resources/config/services/sluggable.yaml @@ -4,7 +4,8 @@ parameters: darvin_utils.sluggable.subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber services: - Darvin\Utils\Sluggable\SluggableManagerInterface: '@darvin_utils.sluggable.manager' + Darvin\Utils\Sluggable\SluggableManagerInterface: '@darvin_utils.sluggable.manager' + Darvin\Utils\EventListener\SlugifySubscriberInterface: '@darvin_utils.sluggable.subscriber' darvin_utils.sluggable.manager: alias: darvin_utils.sluggable.manager.entity From 94a6a7c021ceb5845dc23ec9ba6a2fa46e882f28 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 24 Dec 2019 14:38:39 +0300 Subject: [PATCH 127/192] Add callback runner. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/services/callback.yaml | 10 ++++++++++ 3 files changed, 13 insertions(+) create mode 100644 Resources/config/services/callback.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 39c3817..548cbbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,3 +80,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.4: Remove Intl Twig functions. 7.2.5: Make Twig, Translation and PropertyAccess components optional. + +7.2.6: Add callback runner. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 1662392..8f54f74 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -50,6 +50,7 @@ public function load(array $configs, ContainerBuilder $container): void (new ConfigInjector($container))->inject($config, $this->getAlias()); (new ConfigLoader($container, __DIR__.'/../Resources/config/services'))->load([ + 'callback', 'flash', 'homepage', 'locale', diff --git a/Resources/config/services/callback.yaml b/Resources/config/services/callback.yaml new file mode 100644 index 0000000..8744b75 --- /dev/null +++ b/Resources/config/services/callback.yaml @@ -0,0 +1,10 @@ +parameters: + darvin_utils.callback.runner.class: Darvin\Utils\Callback\CallbackRunner + +services: + Darvin\Utils\Callback\CallbackRunnerInterface: '@darvin_utils.callback.runner' + + darvin_utils.callback.runner: + class: '%darvin_utils.callback.runner.class%' + arguments: + - '@service_container' From a7da86c375797c5a3fe390b591c29ecd4786ad26 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 08:18:32 +0300 Subject: [PATCH 128/192] Register override command. --- DependencyInjection/DarvinUtilsExtension.php | 2 ++ Resources/config/services/dev/override.yaml | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 Resources/config/services/dev/override.yaml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 8f54f74..93360e0 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -68,6 +68,8 @@ public function load(array $configs, ContainerBuilder $container): void 'default_value' => ['class' => self::CLASS_PROPERTY_ACCESS], + 'dev/override' => ['env' => 'dev'], + 'dev/translation' => ['env' => 'dev'], 'form' => ['class' => self::CLASS_FORM], diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml new file mode 100644 index 0000000..45859cb --- /dev/null +++ b/Resources/config/services/dev/override.yaml @@ -0,0 +1,11 @@ +parameters: + darvin_utils.override.command.class: Darvin\Utils\Command\OverrideCommand + darvin_utils.override.command.name: darvin:utils:override + +services: + darvin_utils.override.command: + class: '%darvin_utils.override.command.class%' + arguments: + - '%darvin_utils.override.command.name%' + tags: + - { name: console.command } From 9ed7212968005c04df86ad194ebef07ff555bbce Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 08:29:27 +0300 Subject: [PATCH 129/192] Register overrider. --- Resources/config/services/dev/override.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 45859cb..8f1060c 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -2,10 +2,16 @@ parameters: darvin_utils.override.command.class: Darvin\Utils\Command\OverrideCommand darvin_utils.override.command.name: darvin:utils:override + darvin_utils.override.overrider.class: Darvin\Utils\Override\Overrider + services: darvin_utils.override.command: class: '%darvin_utils.override.command.class%' arguments: - '%darvin_utils.override.command.name%' + - '@darvin_utils.override.overrider' tags: - { name: console.command } + + darvin_utils.override.overrider: + class: '%darvin_utils.override.overrider.class%' From df0dc097a7aae17cf5f0ce4bf2001a727d375222 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 08:46:30 +0300 Subject: [PATCH 130/192] Define dummy override configuration. --- DependencyInjection/Configuration.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 7d6c045..b87e84a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -10,6 +10,7 @@ namespace Darvin\UtilsBundle\DependencyInjection; +use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; @@ -35,6 +36,7 @@ public function getConfigTreeBuilder(): TreeBuilder // more information on that topic. $root ->children() + ->append($this->buildOverrideNode()) ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() @@ -42,4 +44,15 @@ public function getConfigTreeBuilder(): TreeBuilder return $builder; } + + /** + * @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition + */ + private function buildOverrideNode(): ArrayNodeDefinition + { + $root = (new TreeBuilder('override'))->getRootNode(); + $root->addDefaultsIfNotSet(); + + return $root; + } } From 918e32eb73caf5094d1db8237676ee655010ce48 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 08:59:47 +0300 Subject: [PATCH 131/192] Define override configuration. --- DependencyInjection/Configuration.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index b87e84a..1b66776 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -51,7 +51,15 @@ public function getConfigTreeBuilder(): TreeBuilder private function buildOverrideNode(): ArrayNodeDefinition { $root = (new TreeBuilder('override'))->getRootNode(); - $root->addDefaultsIfNotSet(); + $root->addDefaultsIfNotSet() + ->children() + ->arrayNode('bundles')->useAttributeAsKey('name') + ->prototype('array') + ->children() + ->arrayNode('subjects')->useAttributeAsKey('name') + ->prototype('array') + ->children() + ->arrayNode('entities')->prototype('scalar')->cannotBeEmpty(); return $root; } From 0d8035b42d2cfb5c77fa76e164b5b2afffa7ec8a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 09:04:41 +0300 Subject: [PATCH 132/192] Define override configuration. --- DependencyInjection/Configuration.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 1b66776..b2c29b8 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -59,7 +59,14 @@ private function buildOverrideNode(): ArrayNodeDefinition ->arrayNode('subjects')->useAttributeAsKey('name') ->prototype('array') ->children() - ->arrayNode('entities')->prototype('scalar')->cannotBeEmpty(); + ->arrayNode('entities') + ->prototype('scalar') + ->cannotBeEmpty() + ->validate() + ->ifTrue(function ($entity): bool { + return !class_exists((string)$entity); + }) + ->thenInvalid('Entity %s does not exist.'); return $root; } From 15109605262c9b17baac9b1de5dc566d35d3a89d Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 09:12:43 +0300 Subject: [PATCH 133/192] Define override functionality. --- DependencyInjection/Configuration.php | 1 + 1 file changed, 1 insertion(+) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index b2c29b8..03c575a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -59,6 +59,7 @@ private function buildOverrideNode(): ArrayNodeDefinition ->arrayNode('subjects')->useAttributeAsKey('name') ->prototype('array') ->children() + ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty()->end()->end() ->arrayNode('entities') ->prototype('scalar') ->cannotBeEmpty() From 20325906a453335892b6ea128aff1147cfa42f15 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 09:43:46 +0300 Subject: [PATCH 134/192] Inject configuration to overrider. --- Resources/config/services/dev/override.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 8f1060c..45a7f89 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -15,3 +15,5 @@ services: darvin_utils.override.overrider: class: '%darvin_utils.override.overrider.class%' + arguments: + - '%darvin_utils.override.bundles%' From fc10aca68589005235849f7c62eebd4295b0c405 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 09:54:25 +0300 Subject: [PATCH 135/192] Validate override configuration. --- DependencyInjection/Configuration.php | 27 ++++++++++++++++++++ DependencyInjection/DarvinUtilsExtension.php | 11 +++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 03c575a..d3b58b4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -21,6 +21,19 @@ */ class Configuration implements ConfigurationInterface { + /** + * @var array + */ + private $bundles; + + /** + * @param array $bundles Bundles + */ + public function __construct(array $bundles) + { + $this->bundles = $bundles; + } + /** * {@inheritDoc} */ @@ -50,10 +63,24 @@ public function getConfigTreeBuilder(): TreeBuilder */ private function buildOverrideNode(): ArrayNodeDefinition { + $existingBundles = $this->bundles; + $root = (new TreeBuilder('override'))->getRootNode(); $root->addDefaultsIfNotSet() ->children() ->arrayNode('bundles')->useAttributeAsKey('name') + ->validate() + ->ifTrue(function (array $bundles) use ($existingBundles): bool { + foreach (array_keys($bundles) as $bundle) { + if (!isset($existingBundles[$bundle])) { + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); + } + } + + return false; + }) + ->thenInvalid('') + ->end() ->prototype('array') ->children() ->arrayNode('subjects')->useAttributeAsKey('name') diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 93360e0..0677f24 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -15,6 +15,7 @@ use Darvin\Utils\DependencyInjection\ExtensionConfigurator; use Darvin\Utils\Mapping\AnnotationDriver\AnnotationDriverInterface; use Darvin\Utils\Sluggable\SlugHandlerInterface; +use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -45,7 +46,7 @@ public function load(array $configs, ContainerBuilder $container): void $container->registerForAutoconfiguration(AnnotationDriverInterface::class)->addTag(self::TAG_ANNOTATION_DRIVER); $container->registerForAutoconfiguration(SlugHandlerInterface::class)->addTag(self::TAG_SLUG_HANDLER); - $config = $this->processConfiguration(new Configuration(), $configs); + $config = $this->processConfiguration(new Configuration($container->getParameter('kernel.bundles')), $configs); (new ConfigInjector($container))->inject($config, $this->getAlias()); @@ -106,4 +107,12 @@ public function prepend(ContainerBuilder $container): void 'stof_doctrine_extensions', ]); } + + /** + * {@inheritDoc} + */ + public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface + { + return new Configuration($container->getParameter('kernel.bundles')); + } } From f1595b891f3c7938dc3c459fb1550c946ea7adc5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 10:32:15 +0300 Subject: [PATCH 136/192] Validate override configuration. --- DependencyInjection/Configuration.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index d3b58b4..817333c 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -71,9 +71,23 @@ private function buildOverrideNode(): ArrayNodeDefinition ->arrayNode('bundles')->useAttributeAsKey('name') ->validate() ->ifTrue(function (array $bundles) use ($existingBundles): bool { - foreach (array_keys($bundles) as $bundle) { - if (!isset($existingBundles[$bundle])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); + foreach ($bundles as $bundleName => $bundleAttr) { + if (!isset($existingBundles[$bundleName])) { + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundleName)); + } + + $basePath = dirname((new \ReflectionClass($existingBundles[$bundleName]))->getFileName()); + + foreach ($bundleAttr['subjects'] as $subjectName => $subjectAttr) { + foreach ($subjectAttr['templates'] as $relativePath) { + $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); + + if (!file_exists($absolutePath)) { + throw new \InvalidArgumentException( + sprintf('Template directory or file "%s" does not exist.', $absolutePath) + ); + } + } } } From 52ae2c440e7d10b9b74b1df8e164d13aaf4f5f08 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 10:32:57 +0300 Subject: [PATCH 137/192] Validate override configuration. --- DependencyInjection/Configuration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 817333c..4d66111 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -82,9 +82,9 @@ private function buildOverrideNode(): ArrayNodeDefinition foreach ($subjectAttr['templates'] as $relativePath) { $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); - if (!file_exists($absolutePath)) { + if (!is_readable($absolutePath)) { throw new \InvalidArgumentException( - sprintf('Template directory or file "%s" does not exist.', $absolutePath) + sprintf('Template directory or file "%s" is not readable.', $absolutePath) ); } } From e3e3f2666c3baf8ab79fe0fed965901621a5056a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 10:35:42 +0300 Subject: [PATCH 138/192] Validate override configuration. --- DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 4d66111..e2bf5a1 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -78,7 +78,7 @@ private function buildOverrideNode(): ArrayNodeDefinition $basePath = dirname((new \ReflectionClass($existingBundles[$bundleName]))->getFileName()); - foreach ($bundleAttr['subjects'] as $subjectName => $subjectAttr) { + foreach ($bundleAttr['subjects'] as $subjectAttr) { foreach ($subjectAttr['templates'] as $relativePath) { $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); From b4101fcfd6b72aa215ef58d23556c1c364a17f2e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 10:44:13 +0300 Subject: [PATCH 139/192] Simplify override configuration. --- DependencyInjection/Configuration.php | 70 ++++++++++----------- Resources/config/services/dev/override.yaml | 2 +- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e2bf5a1..a18b5ca 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -66,49 +66,45 @@ private function buildOverrideNode(): ArrayNodeDefinition $existingBundles = $this->bundles; $root = (new TreeBuilder('override'))->getRootNode(); - $root->addDefaultsIfNotSet() - ->children() - ->arrayNode('bundles')->useAttributeAsKey('name') - ->validate() - ->ifTrue(function (array $bundles) use ($existingBundles): bool { - foreach ($bundles as $bundleName => $bundleAttr) { - if (!isset($existingBundles[$bundleName])) { - throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundleName)); - } + $root->useAttributeAsKey('bundle') + ->validate() + ->ifTrue(function (array $bundles) use ($existingBundles): bool { + foreach ($bundles as $bundle => $subjects) { + if (!isset($existingBundles[$bundle])) { + throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); + } - $basePath = dirname((new \ReflectionClass($existingBundles[$bundleName]))->getFileName()); + $basePath = dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName()); - foreach ($bundleAttr['subjects'] as $subjectAttr) { - foreach ($subjectAttr['templates'] as $relativePath) { - $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); + foreach ($subjects as $subjectAttr) { + foreach ($subjectAttr['templates'] as $relativePath) { + $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); - if (!is_readable($absolutePath)) { - throw new \InvalidArgumentException( - sprintf('Template directory or file "%s" is not readable.', $absolutePath) - ); - } - } + if (!is_readable($absolutePath)) { + throw new \InvalidArgumentException( + sprintf('Template directory or file "%s" is not readable.', $absolutePath) + ); } } + } + } - return false; - }) - ->thenInvalid('') - ->end() - ->prototype('array') - ->children() - ->arrayNode('subjects')->useAttributeAsKey('name') - ->prototype('array') - ->children() - ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty()->end()->end() - ->arrayNode('entities') - ->prototype('scalar') - ->cannotBeEmpty() - ->validate() - ->ifTrue(function ($entity): bool { - return !class_exists((string)$entity); - }) - ->thenInvalid('Entity %s does not exist.'); + return false; + }) + ->thenInvalid('') + ->end() + ->prototype('array')->useAttributeAsKey('subject') + ->prototype('array') + ->children() + ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty()->end()->end() + ->arrayNode('entities') + ->prototype('scalar') + ->cannotBeEmpty() + ->validate() + ->ifTrue(function ($entity): bool { + return !class_exists((string)$entity); + }) + ->thenInvalid('Entity %s does not exist.'); return $root; } diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 45a7f89..3e44621 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -16,4 +16,4 @@ services: darvin_utils.override.overrider: class: '%darvin_utils.override.overrider.class%' arguments: - - '%darvin_utils.override.bundles%' + - '%darvin_utils.override%' From 789b7e8685447f60ca453c7672c71581576298a7 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 14:17:02 +0300 Subject: [PATCH 140/192] Extract override config service. --- Resources/config/services/dev/override.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 3e44621..f2a5829 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -2,6 +2,8 @@ parameters: darvin_utils.override.command.class: Darvin\Utils\Command\OverrideCommand darvin_utils.override.command.name: darvin:utils:override + darvin_utils.override.config.class: Darvin\Utils\Override\Config\OverrideConfig + darvin_utils.override.overrider.class: Darvin\Utils\Override\Overrider services: @@ -13,7 +15,12 @@ services: tags: - { name: console.command } + darvin_utils.override.config: + class: '%darvin_utils.override.config.class%' + arguments: + - '%darvin_utils.override%' + darvin_utils.override.overrider: class: '%darvin_utils.override.overrider.class%' arguments: - - '%darvin_utils.override%' + - '@darvin_utils.override.config' From 6f2a51d697b2cbbe3f1a1d8b295415cda006afd6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 14:27:09 +0300 Subject: [PATCH 141/192] Add dummy subject model. --- DependencyInjection/Configuration.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a18b5ca..b3f3b7a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -76,8 +76,8 @@ private function buildOverrideNode(): ArrayNodeDefinition $basePath = dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName()); - foreach ($subjects as $subjectAttr) { - foreach ($subjectAttr['templates'] as $relativePath) { + foreach ($subjects as $subject) { + foreach ($subject['templates'] as $relativePath) { $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); if (!is_readable($absolutePath)) { From 58f8665b3fa54ecbd281f7b4cebe7795dbcea3b6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 14:48:43 +0300 Subject: [PATCH 142/192] Simplify override configuration. --- DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index b3f3b7a..0ed11f4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -74,7 +74,7 @@ private function buildOverrideNode(): ArrayNodeDefinition throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); } - $basePath = dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName()); + $basePath = sprintf('%s/Resources/views', dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName())); foreach ($subjects as $subject) { foreach ($subject['templates'] as $relativePath) { From cc25ba93d75cc8512ae5389327dd5fdad5c84cd5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 15:04:33 +0300 Subject: [PATCH 143/192] Simplify override configuration. --- DependencyInjection/Configuration.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0ed11f4..60734d6 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -74,9 +74,17 @@ private function buildOverrideNode(): ArrayNodeDefinition throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); } - $basePath = sprintf('%s/Resources/views', dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName())); + $baseNamespace = preg_replace('/\\\[^\\\]+$/', '', $existingBundles[$bundle]); + $basePath = sprintf('%s/Resources/views', dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName())); foreach ($subjects as $subject) { + foreach ($subject['entities'] as $entity) { + $class = sprintf('%s\Entity\%s', $baseNamespace, $entity); + + if (!class_exists($class)) { + throw new \InvalidArgumentException(sprintf('Entity class "%s" does not exist.', $class)); + } + } foreach ($subject['templates'] as $relativePath) { $absolutePath = implode(DIRECTORY_SEPARATOR, [$basePath, $relativePath]); @@ -96,15 +104,8 @@ private function buildOverrideNode(): ArrayNodeDefinition ->prototype('array')->useAttributeAsKey('subject') ->prototype('array') ->children() - ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty()->end()->end() - ->arrayNode('entities') - ->prototype('scalar') - ->cannotBeEmpty() - ->validate() - ->ifTrue(function ($entity): bool { - return !class_exists((string)$entity); - }) - ->thenInvalid('Entity %s does not exist.'); + ->arrayNode('entities')->prototype('scalar')->cannotBeEmpty()->end()->end() + ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty(); return $root; } From 5db042f4a56c90e9d5a1b7f75abbf430805ffd4c Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 15:09:29 +0300 Subject: [PATCH 144/192] Rename overrider to overrider pool. --- Resources/config/services/dev/override.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index f2a5829..67aeab0 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -4,14 +4,14 @@ parameters: darvin_utils.override.config.class: Darvin\Utils\Override\Config\OverrideConfig - darvin_utils.override.overrider.class: Darvin\Utils\Override\Overrider + darvin_utils.override.overrider_pool.class: Darvin\Utils\Override\OverriderPool services: darvin_utils.override.command: class: '%darvin_utils.override.command.class%' arguments: - '%darvin_utils.override.command.name%' - - '@darvin_utils.override.overrider' + - '@darvin_utils.override.overrider_pool' tags: - { name: console.command } @@ -20,7 +20,7 @@ services: arguments: - '%darvin_utils.override%' - darvin_utils.override.overrider: - class: '%darvin_utils.override.overrider.class%' + darvin_utils.override.overrider_pool: + class: '%darvin_utils.override.overrider_pool.class%' arguments: - '@darvin_utils.override.config' From cc92ad8805d9f9296d36ae12d90c88aba1f9d40d Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 15:34:29 +0300 Subject: [PATCH 145/192] Implement dummy template overrider. --- DarvinUtilsBundle.php | 2 + .../Compiler/AddOverridersPass.php | 39 +++++++++++++++++++ Resources/config/services/dev/override.yaml | 7 ++++ 3 files changed, 48 insertions(+) create mode 100644 DependencyInjection/Compiler/AddOverridersPass.php diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 5477e63..dee0d20 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -11,6 +11,7 @@ namespace Darvin\UtilsBundle; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddAnnotationDriversPass; +use Darvin\UtilsBundle\DependencyInjection\Compiler\AddOverridersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AliasServicesPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; @@ -33,6 +34,7 @@ public function build(ContainerBuilder $container): void $container ->addCompilerPass(new AddAnnotationDriversPass()) + ->addCompilerPass(new AddOverridersPass()) ->addCompilerPass(new AddSlugHandlersPass()) ->addCompilerPass(new AliasServicesPass()) ->addCompilerPass(new CreateServiceProvidersPass()) diff --git a/DependencyInjection/Compiler/AddOverridersPass.php b/DependencyInjection/Compiler/AddOverridersPass.php new file mode 100644 index 0000000..6985038 --- /dev/null +++ b/DependencyInjection/Compiler/AddOverridersPass.php @@ -0,0 +1,39 @@ + + * @copyright Copyright (c) 2019, Darvin Studio + * @link https://www.darvin-studio.ru + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Darvin\UtilsBundle\DependencyInjection\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; + +/** + * Add overriders to pool compiler pass + */ +class AddOverridersPass implements CompilerPassInterface +{ + private const POOL = 'darvin_utils.override.overrider_pool'; + + /** + * {@inheritDoc} + */ + public function process(ContainerBuilder $container): void + { + if (!$container->hasDefinition(self::POOL)) { + return; + } + + $pool = $container->getDefinition(self::POOL); + + foreach (array_keys($container->findTaggedServiceIds('darvin_utils.overrider')) as $id) { + $pool->addMethodCall('addOverrider', [new Reference($id)]); + } + } +} diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 67aeab0..f0b1278 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -4,6 +4,8 @@ parameters: darvin_utils.override.config.class: Darvin\Utils\Override\Config\OverrideConfig + darvin_utils.override.overrider.template.class: Darvin\Utils\Override\Overrider\TemplateOverrider + darvin_utils.override.overrider_pool.class: Darvin\Utils\Override\OverriderPool services: @@ -20,6 +22,11 @@ services: arguments: - '%darvin_utils.override%' + darvin_utils.override.overrider.template: + class: '%darvin_utils.override.overrider.template.class%' + tags: + - { name: darvin_utils.overrider } + darvin_utils.override.overrider_pool: class: '%darvin_utils.override.overrider_pool.class%' arguments: From ec30c4cf0fbee034a67f20e0526688ef8f2a5cfa Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 30 Dec 2019 15:36:08 +0300 Subject: [PATCH 146/192] Implement dummy entity overrider. --- Resources/config/services/dev/override.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index f0b1278..fed7e2d 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -4,6 +4,8 @@ parameters: darvin_utils.override.config.class: Darvin\Utils\Override\Config\OverrideConfig + darvin_utils.override.overrider.entity.class: Darvin\Utils\Override\Overrider\EntityOverrider + darvin_utils.override.overrider.template.class: Darvin\Utils\Override\Overrider\TemplateOverrider darvin_utils.override.overrider_pool.class: Darvin\Utils\Override\OverriderPool @@ -22,6 +24,11 @@ services: arguments: - '%darvin_utils.override%' + darvin_utils.override.overrider.entity: + class: '%darvin_utils.override.overrider.entity.class%' + tags: + - { name: darvin_utils.overrider } + darvin_utils.override.overrider.template: class: '%darvin_utils.override.overrider.template.class%' tags: From 5d846e196bc8b68883183956ea75c40240bf6210 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 14:41:21 +0300 Subject: [PATCH 147/192] Refactor configuration. --- DependencyInjection/Configuration.php | 18 +++++++++--------- DependencyInjection/DarvinUtilsExtension.php | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 60734d6..61b6a28 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -24,14 +24,14 @@ class Configuration implements ConfigurationInterface /** * @var array */ - private $bundles; + private $bundlesMeta; /** - * @param array $bundles Bundles + * @param array $bundlesMeta Bundles metadata */ - public function __construct(array $bundles) + public function __construct(array $bundlesMeta) { - $this->bundles = $bundles; + $this->bundlesMeta = $bundlesMeta; } /** @@ -63,19 +63,19 @@ public function getConfigTreeBuilder(): TreeBuilder */ private function buildOverrideNode(): ArrayNodeDefinition { - $existingBundles = $this->bundles; + $bundlesMeta = $this->bundlesMeta; $root = (new TreeBuilder('override'))->getRootNode(); $root->useAttributeAsKey('bundle') ->validate() - ->ifTrue(function (array $bundles) use ($existingBundles): bool { + ->ifTrue(function (array $bundles) use ($bundlesMeta): bool { foreach ($bundles as $bundle => $subjects) { - if (!isset($existingBundles[$bundle])) { + if (!isset($bundlesMeta[$bundle])) { throw new \InvalidArgumentException(sprintf('Bundle "%s" does not exist.', $bundle)); } - $baseNamespace = preg_replace('/\\\[^\\\]+$/', '', $existingBundles[$bundle]); - $basePath = sprintf('%s/Resources/views', dirname((new \ReflectionClass($existingBundles[$bundle]))->getFileName())); + $baseNamespace = $bundlesMeta[$bundle]['namespace']; + $basePath = sprintf('%s/Resources/views', $bundlesMeta[$bundle]['path']); foreach ($subjects as $subject) { foreach ($subject['entities'] as $entity) { diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 0677f24..f58f8e9 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -46,7 +46,7 @@ public function load(array $configs, ContainerBuilder $container): void $container->registerForAutoconfiguration(AnnotationDriverInterface::class)->addTag(self::TAG_ANNOTATION_DRIVER); $container->registerForAutoconfiguration(SlugHandlerInterface::class)->addTag(self::TAG_SLUG_HANDLER); - $config = $this->processConfiguration(new Configuration($container->getParameter('kernel.bundles')), $configs); + $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); (new ConfigInjector($container))->inject($config, $this->getAlias()); @@ -113,6 +113,6 @@ public function prepend(ContainerBuilder $container): void */ public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface { - return new Configuration($container->getParameter('kernel.bundles')); + return new Configuration($container->getParameter('kernel.bundles_metadata')); } } From 36ecd5ff46ed109cde13db687c4681a49a4eb944 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 14:55:08 +0300 Subject: [PATCH 148/192] Implement entity overrider. --- Resources/config/services/dev/override.yaml | 3 +++ Resources/views/override/entity.php.twig | 29 +++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Resources/views/override/entity.php.twig diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index fed7e2d..9666dc4 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -26,6 +26,9 @@ services: darvin_utils.override.overrider.entity: class: '%darvin_utils.override.overrider.entity.class%' + arguments: + - '@twig' + - '%kernel.bundles_metadata%' tags: - { name: darvin_utils.overrider } diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig new file mode 100644 index 0000000..7a05e6d --- /dev/null +++ b/Resources/views/override/entity.php.twig @@ -0,0 +1,29 @@ + Date: Thu, 9 Jan 2020 15:37:10 +0300 Subject: [PATCH 149/192] Implement entity overrider. --- Resources/views/override/entity.php.twig | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index 7a05e6d..e8bfed6 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -1,27 +1,27 @@ Date: Thu, 9 Jan 2020 15:52:00 +0300 Subject: [PATCH 150/192] Implement entity overrider. --- Resources/config/services/dev/override.yaml | 1 + Resources/views/override/entity.php.twig | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 9666dc4..7173001 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -27,6 +27,7 @@ services: darvin_utils.override.overrider.entity: class: '%darvin_utils.override.overrider.entity.class%' arguments: + - '@doctrine.orm.entity_manager' - '@twig' - '%kernel.bundles_metadata%' tags: diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index e8bfed6..5ca260c 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -9,13 +9,15 @@ namespace App\Entity\{{ package_namespace }}{% if entity_namespace %}\{{ entity_namespace }}{% endif %}; -use {{ bundle_namespace }}\Entity{% if entity_namespace %}\{{ entity_namespace }}{% endif %}\{{ class }}; +use {{ fqcn }}; use Doctrine\ORM\Mapping as ORM; /** * {{ class }} +{% if repository_class %} * - * @ORM\Entity(repositoryClass="Darvin\PageBundle\Repository\HomepageRepository") + * @ORM\Entity(repositoryClass="{{ repository_class }}") +{% endif %} */ class App{{ class }} extends {{ class }} { From 34362cf06191b6a99d2b8bd40e49f6f4bbdc0ebe Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 16:20:00 +0300 Subject: [PATCH 151/192] Implement entity overrider. --- Resources/config/services/dev/override.yaml | 1 + Resources/views/override/entity.php.twig | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 7173001..ccd6b02 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -28,6 +28,7 @@ services: class: '%darvin_utils.override.overrider.entity.class%' arguments: - '@doctrine.orm.entity_manager' + - '@darvin_content.translatable.manager' - '@twig' - '%kernel.bundles_metadata%' tags: diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index 5ca260c..a65e24d 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -21,11 +21,13 @@ use Doctrine\ORM\Mapping as ORM; */ class App{{ class }} extends {{ class }} { +{% if translation_class %} /** - * @return string + * {@inheritDoc} */ - public static function getTranslationEntityClass() + public static function getTranslationEntityClass(): string { - return AppHomepageTranslation::class; + return {{ translation_class }}::class; } +{% endif %} } From 6b933254f3c2fb1ed9b1cf6c26885b5668f92b55 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 16:31:05 +0300 Subject: [PATCH 152/192] Implement entity overrider. --- Resources/views/override/entity.php.twig | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index a65e24d..cab1e3e 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -14,20 +14,29 @@ use Doctrine\ORM\Mapping as ORM; /** * {{ class }} -{% if repository_class %} +{% if repository %} * - * @ORM\Entity(repositoryClass="{{ repository_class }}") + * @ORM\Entity(repositoryClass="{{ repository }}") {% endif %} */ class App{{ class }} extends {{ class }} { -{% if translation_class %} +{% if translatable %} + /** + * {@inheritDoc} + */ + public static function getTranslatableEntityClass(): string + { + return {{ translatable }}::class; + } +{% endif %} +{% if translation %} /** * {@inheritDoc} */ public static function getTranslationEntityClass(): string { - return {{ translation_class }}::class; + return {{ translation }}::class; } {% endif %} } From 49eadc6ea94d796f565aa7fbabc1e2c8b8a7541b Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 16:35:47 +0300 Subject: [PATCH 153/192] Implement entity overrider. --- Resources/views/override/entity.php.twig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index cab1e3e..c3ef76a 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -13,11 +13,10 @@ use {{ fqcn }}; use Doctrine\ORM\Mapping as ORM; /** - * {{ class }} -{% if repository %} + * {{ class|humanize }} * - * @ORM\Entity(repositoryClass="{{ repository }}") -{% endif %} + * @ORM\Entity{% if repository %}(repositoryClass="{{ repository }}"){% endif %} + */ class App{{ class }} extends {{ class }} { From 16f6ade9bf5c999a825fe7380893d0e924c8038a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 9 Jan 2020 16:53:13 +0300 Subject: [PATCH 154/192] Implement entity overrider. --- Resources/config/services/dev/override.yaml | 2 ++ Resources/views/override/entity.php.twig | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index ccd6b02..914fefb 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -28,9 +28,11 @@ services: class: '%darvin_utils.override.overrider.entity.class%' arguments: - '@doctrine.orm.entity_manager' + - '@filesystem' - '@darvin_content.translatable.manager' - '@twig' - '%kernel.bundles_metadata%' + - '%kernel.project_dir%' tags: - { name: darvin_utils.overrider } diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig index c3ef76a..b40cac0 100644 --- a/Resources/views/override/entity.php.twig +++ b/Resources/views/override/entity.php.twig @@ -26,7 +26,7 @@ class App{{ class }} extends {{ class }} */ public static function getTranslatableEntityClass(): string { - return {{ translatable }}::class; + return App{{ translatable }}::class; } {% endif %} {% if translation %} @@ -35,7 +35,7 @@ class App{{ class }} extends {{ class }} */ public static function getTranslationEntityClass(): string { - return {{ translation }}::class; + return App{{ translation }}::class; } {% endif %} } From b574c9fb239c6a6e2406c92103d55269d3f7a1a3 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 10 Jan 2020 14:46:04 +0300 Subject: [PATCH 155/192] Move override templates from Utils bundle to Utils package. --- DependencyInjection/DarvinUtilsExtension.php | 10 +++++ Resources/views/override/entity.php.twig | 41 -------------------- 2 files changed, 10 insertions(+), 41 deletions(-) delete mode 100644 Resources/views/override/entity.php.twig diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index f58f8e9..ca500b9 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -106,6 +106,16 @@ public function prepend(ContainerBuilder $container): void 'doctrine', 'stof_doctrine_extensions', ]); + + if ($container->hasExtension('twig')) { + $path = sprintf('%s/../Resources/views', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); + + $container->prependExtensionConfig('twig', [ + 'paths' => [ + $path => 'DarvinUtils', + ], + ]); + } } /** diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig deleted file mode 100644 index b40cac0..0000000 --- a/Resources/views/override/entity.php.twig +++ /dev/null @@ -1,41 +0,0 @@ - Date: Fri, 10 Jan 2020 14:55:19 +0300 Subject: [PATCH 156/192] Specify override functionality's deps. --- DependencyInjection/DarvinUtilsExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index ca500b9..839c1e8 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -30,10 +30,12 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; + private const BUNDLE_CONTENT = 'DarvinContentBundle'; private const BUNDLE_DOCTRINE_EXTENSIONS = 'StofDoctrineExtensionsBundle'; private const BUNDLE_SECURITY = 'SecurityBundle'; private const BUNDLE_TWIG = 'TwigBundle'; + private const CLASS_FILESYSTEM = 'Symfony\Component\Filesystem\Filesystem'; private const CLASS_FORM = 'Symfony\Component\Form\Form'; private const CLASS_PROPERTY_ACCESS = 'Symfony\Component\PropertyAccess\PropertyAccessor'; private const CLASS_TRANSLATION = 'Symfony\Component\Translation\Translator'; @@ -69,7 +71,11 @@ public function load(array $configs, ContainerBuilder $container): void 'default_value' => ['class' => self::CLASS_PROPERTY_ACCESS], - 'dev/override' => ['env' => 'dev'], + 'dev/override' => [ + 'env' => 'dev', + 'class' => self::CLASS_FILESYSTEM, + 'bundle' => [self::BUNDLE_CONTENT, self::BUNDLE_TWIG], + ], 'dev/translation' => ['env' => 'dev'], From d330aa0fd7a34872be5c9039512e9bb447423578 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 13 Jan 2020 10:51:45 +0300 Subject: [PATCH 157/192] Implement template overrider. --- Resources/config/services/dev/override.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 914fefb..16288bf 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -38,6 +38,10 @@ services: darvin_utils.override.overrider.template: class: '%darvin_utils.override.overrider.template.class%' + arguments: + - '@filesystem' + - '%kernel.bundles_metadata%' + - '%kernel.project_dir%' tags: - { name: darvin_utils.overrider } From 1b9fc57197a5b180ada4ec735a9f1fcaacb25014 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 13 Jan 2020 10:53:40 +0300 Subject: [PATCH 158/192] Implement template overrider. --- DependencyInjection/Configuration.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 61b6a28..699af61 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -90,7 +90,7 @@ private function buildOverrideNode(): ArrayNodeDefinition if (!is_readable($absolutePath)) { throw new \InvalidArgumentException( - sprintf('Template directory or file "%s" is not readable.', $absolutePath) + sprintf('Template file or directory "%s" is not readable.', $absolutePath) ); } } From 813855dafc8899272a1893917fd32e661747ae98 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 13 Jan 2020 11:16:29 +0300 Subject: [PATCH 159/192] Add dummy admin overrider. --- Resources/config/services/dev/override.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 16288bf..b44f672 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -4,6 +4,8 @@ parameters: darvin_utils.override.config.class: Darvin\Utils\Override\Config\OverrideConfig + darvin_utils.override.overrider.admin.class: Darvin\Utils\Override\Overrider\AdminOverrider + darvin_utils.override.overrider.entity.class: Darvin\Utils\Override\Overrider\EntityOverrider darvin_utils.override.overrider.template.class: Darvin\Utils\Override\Overrider\TemplateOverrider @@ -24,6 +26,11 @@ services: arguments: - '%darvin_utils.override%' + darvin_utils.override.overrider.admin: + class: '%darvin_utils.override.overrider.admin.class%' + tags: + - { name: darvin_utils.overrider } + darvin_utils.override.overrider.entity: class: '%darvin_utils.override.overrider.entity.class%' arguments: From 1d40cdcf0b5e6be640f6d5a355e8c109715ac5c0 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Mon, 13 Jan 2020 11:37:13 +0300 Subject: [PATCH 160/192] Implement admin overrider. --- DependencyInjection/DarvinUtilsExtension.php | 3 ++- Resources/config/services/dev/override.yaml | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 839c1e8..d56d97a 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -30,6 +30,7 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac public const TAG_ANNOTATION_DRIVER = 'darvin_utils.annotation_driver'; public const TAG_SLUG_HANDLER = 'darvin_utils.slug_handler'; + private const BUNDLE_ADMIN = 'DarvinAdminBundle'; private const BUNDLE_CONTENT = 'DarvinContentBundle'; private const BUNDLE_DOCTRINE_EXTENSIONS = 'StofDoctrineExtensionsBundle'; private const BUNDLE_SECURITY = 'SecurityBundle'; @@ -74,7 +75,7 @@ public function load(array $configs, ContainerBuilder $container): void 'dev/override' => [ 'env' => 'dev', 'class' => self::CLASS_FILESYSTEM, - 'bundle' => [self::BUNDLE_CONTENT, self::BUNDLE_TWIG], + 'bundle' => [self::BUNDLE_ADMIN, self::BUNDLE_CONTENT, self::BUNDLE_TWIG], ], 'dev/translation' => ['env' => 'dev'], diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index b44f672..d9c0456 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -28,6 +28,8 @@ services: darvin_utils.override.overrider.admin: class: '%darvin_utils.override.overrider.admin.class%' + arguments: + - '@darvin_admin.configuration.section' tags: - { name: darvin_utils.overrider } From d6972f10de569b774891b743c11a3303ccd5b3b5 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 09:33:52 +0300 Subject: [PATCH 161/192] Implement admin overrider. --- Resources/config/services/dev/override.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index d9c0456..9ba7136 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -30,6 +30,7 @@ services: class: '%darvin_utils.override.overrider.admin.class%' arguments: - '@darvin_admin.configuration.section' + - '%kernel.bundles_metadata%' tags: - { name: darvin_utils.overrider } From adf2dac70833d066648869eca2f9854ddceb6676 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 10:38:19 +0300 Subject: [PATCH 162/192] Implement admin overrider. --- Resources/config/services/dev/override.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 9ba7136..2bf21f9 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -29,8 +29,10 @@ services: darvin_utils.override.overrider.admin: class: '%darvin_utils.override.overrider.admin.class%' arguments: + - '@filesystem' - '@darvin_admin.configuration.section' - '%kernel.bundles_metadata%' + - '%kernel.project_dir%' tags: - { name: darvin_utils.overrider } From ec8d81999a6a5e015846cce734ee597bb2c3025f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 11:24:59 +0300 Subject: [PATCH 163/192] Update copyrights. --- DependencyInjection/Configuration.php | 2 +- DependencyInjection/DarvinUtilsExtension.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 699af61..afd7304 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2019, Darvin Studio + * @copyright Copyright (c) 2015-2020, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index d56d97a..3411e57 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2019, Darvin Studio + * @copyright Copyright (c) 2015-2020, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE From 0e4bca220e0ce050c6b55b40ed2ce17ebc31f8e2 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 11:33:40 +0300 Subject: [PATCH 164/192] Move price formatter from utils bundle to utils lib. --- Price/PriceFormatter.php | 57 ---------------------------- Resources/config/services/price.yaml | 2 +- Resources/views/price.html.twig | 1 - 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 Price/PriceFormatter.php delete mode 100644 Resources/views/price.html.twig diff --git a/Price/PriceFormatter.php b/Price/PriceFormatter.php deleted file mode 100644 index 71d39d5..0000000 --- a/Price/PriceFormatter.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @copyright Copyright (c) 2018-2019, Darvin Studio - * @link https://www.darvin-studio.ru - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Darvin\UtilsBundle\Price; - -use Darvin\Utils\Price\PriceFormatterInterface; -use Darvin\Utils\Service\ServiceProviderInterface; -use Twig\Environment; - -/** - * Price formatter - */ -class PriceFormatter implements PriceFormatterInterface -{ - /** - * @var \Darvin\Utils\Service\ServiceProviderInterface - */ - private $twigProvider; - - /** - * @param \Darvin\Utils\Service\ServiceProviderInterface $twigProvider Twig service provider - */ - public function __construct(ServiceProviderInterface $twigProvider) - { - $this->twigProvider = $twigProvider; - } - - /** - * {@inheritDoc} - */ - public function format($price, array $options = []): string - { - if (!isset($options['format'])) { - $options['format'] = 'default'; - } - - return $this->getTwig()->render(isset($options['template']) ? $options['template'] : '@DarvinUtils/price.html.twig', [ - 'price' => $price, - 'options' => $options, - ]); - } - - /** - * @return \Twig\Environment - */ - final protected function getTwig(): Environment - { - return $this->twigProvider->getService(); - } -} diff --git a/Resources/config/services/price.yaml b/Resources/config/services/price.yaml index fc20e17..b3e6221 100644 --- a/Resources/config/services/price.yaml +++ b/Resources/config/services/price.yaml @@ -1,5 +1,5 @@ parameters: - darvin_utils.price.formatter.class: Darvin\UtilsBundle\Price\PriceFormatter + darvin_utils.price.formatter.class: Darvin\Utils\Price\PriceFormatter darvin_utils.price.twig_extension.class: Darvin\Utils\Twig\Extension\PriceExtension diff --git a/Resources/views/price.html.twig b/Resources/views/price.html.twig deleted file mode 100644 index 1e3179e..0000000 --- a/Resources/views/price.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ ('price.' ~ options.format)|trans({'%price%': price|number_format(0, null, ' ')})|raw }} From ae151221444dce34585d35ae217e0c6b816843ef Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 11:36:17 +0300 Subject: [PATCH 165/192] Move macros template from utils bundle to utils lib. --- Resources/views/macros.html.twig | 139 ------------------------------- 1 file changed, 139 deletions(-) delete mode 100644 Resources/views/macros.html.twig diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig deleted file mode 100644 index fb6ef8f..0000000 --- a/Resources/views/macros.html.twig +++ /dev/null @@ -1,139 +0,0 @@ -{% macro div_data(data, trans_prefix, trans_domain) %} - - {% import _self as that %} - - {% for name, value in data %} - {{ that.div_property(name, trans_prefix ~ name, value, trans_domain) }} - {% endfor %} -{% endmacro %} - -{% macro table_data(data, trans_prefix, trans_domain) %} - - {% import _self as that %} - - {% if data is not empty %} - - {% for name, value in data %} - {{ that.table_property(name, trans_prefix ~ name, value, trans_domain) }} - {% endfor %} -
    - {% endif %} -{% endmacro %} - -{% macro div_property(name, title, value, trans_domain) %} - {% if value is not same as(null) and value is not same as('') and not (value is iterable and value is empty) %} - - {% import _self as that %} - - {% if trans_domain is defined %} - - {% trans_default_domain trans_domain %} - - {% endif %} - -
    - {% if name %} - - {% if value is iterable %} - {{ (title ~ '.title')|trans }} - {% else %} - {{ title|trans }} - {% endif %} - - {% endif %} - - {% if value is iterable %} - - {% set keys = value|keys %} - - {% if keys is same as(keys|keys) %} -
      - {% for item_name, item_value in value %} -
    1. {{ that.div_property(null, title, item_value, trans_domain) }}
    2. - {% endfor %} -
    - {% else %} -
      - {% for item_name, item_value in value %} -
    • {{ that.div_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }}
    • - {% endfor %} -
    - {% endif %} - {% elseif value is same as(true) or value is same as(false) %} - {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} - {% elseif 'email' in name|lower %} - - {{ value }} - - {% elseif 'phone' in name|lower %} - - {{ value }} - - {% else %} - {{ value|trans|raw }} - {% endif %} -
    -
    - {% endif %} -{% endmacro %} - -{% macro table_property(name, title, value, trans_domain) %} - {% if value is not same as(null) and value is not same as('') and not (value is iterable and value is empty) %} - - {% import _self as that %} - - {% if trans_domain is defined %} - - {% trans_default_domain trans_domain %} - - {% endif %} - - - {% if name %} - - {% if value is iterable %} - {{ (title ~ '.title')|trans }} - {% else %} - {{ title|trans }} - {% endif %} - - {% endif %} - - {% if value is iterable %} - - - {% set keys = value|keys %} - - {% if keys is same as(keys|keys) %} - {% for item_name, item_value in value %} - {{ that.table_property(null, title, item_value, trans_domain) }} - {% endfor %} - {% else %} - {% for item_name, item_value in value %} - {{ that.table_property(item_name, title ~ '.item.' ~ item_name, item_value, trans_domain) }} - {% endfor %} - {% endif %} -
    - {% elseif value is same as(true) or value is same as(false) %} - {{ ('boolean.' ~ (value ? 'yes' : 'no'))|trans }} - {% elseif 'email' in name|lower %} - - {{ value }} - - {% elseif 'phone' in name|lower %} - - {{ value }} - - {% else %} - {{ value|trans|raw }} - {% endif %} - - - {% endif %} -{% endmacro %} From ea5ab491cb9a257334f1a7d35f56780dc7e5a7b6 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 11:38:53 +0300 Subject: [PATCH 166/192] Update changelog. --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 548cbbd..38971f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,3 +82,11 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.2.5: Make Twig, Translation and PropertyAccess components optional. 7.2.6: Add callback runner. + +7.3.0: + +- Add override command. + +- Move price formatter to utils lib. + +- Move macros template to utils lib. From 5458c74ccd51610c7fbf9f1eadd1ab00fbd101f1 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 13:47:49 +0300 Subject: [PATCH 167/192] Move translations from utils bundle to utils lib. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 27 ++++++++++++++------ Resources/translations/messages.ar.yaml | 9 ------- Resources/translations/messages.en.yaml | 11 -------- Resources/translations/messages.fr.yaml | 9 ------- Resources/translations/messages.ru.yaml | 11 -------- Resources/translations/messages.zh.yaml | 9 ------- Resources/translations/validators.ar.yaml | 2 -- Resources/translations/validators.en.yaml | 2 -- Resources/translations/validators.fr.yaml | 2 -- Resources/translations/validators.ru.yaml | 2 -- Resources/translations/validators.zh.yaml | 2 -- 12 files changed, 21 insertions(+), 67 deletions(-) delete mode 100644 Resources/translations/messages.ar.yaml delete mode 100644 Resources/translations/messages.en.yaml delete mode 100644 Resources/translations/messages.fr.yaml delete mode 100644 Resources/translations/messages.ru.yaml delete mode 100644 Resources/translations/messages.zh.yaml delete mode 100644 Resources/translations/validators.ar.yaml delete mode 100644 Resources/translations/validators.en.yaml delete mode 100644 Resources/translations/validators.fr.yaml delete mode 100644 Resources/translations/validators.ru.yaml delete mode 100644 Resources/translations/validators.zh.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 38971f1..76cfa25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,3 +90,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Move price formatter to utils lib. - Move macros template to utils lib. + +- Move translations to utils lib. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 3411e57..59c391c 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -114,14 +114,25 @@ public function prepend(ContainerBuilder $container): void 'stof_doctrine_extensions', ]); - if ($container->hasExtension('twig')) { - $path = sprintf('%s/../Resources/views', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); - - $container->prependExtensionConfig('twig', [ - 'paths' => [ - $path => 'DarvinUtils', - ], - ]); + if ($container->hasExtension('framework') || $container->hasExtension('twig')) { + $dir = sprintf('%s/../Resources', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); + + if ($container->hasExtension('framework')) { + $container->prependExtensionConfig('framework', [ + 'translator' => [ + 'paths' => [ + sprintf('%s/translations', $dir), + ], + ], + ]); + } + if ($container->hasExtension('twig')) { + $container->prependExtensionConfig('twig', [ + 'paths' => [ + sprintf('%s/views', $dir) => 'DarvinUtils', + ], + ]); + } } } diff --git a/Resources/translations/messages.ar.yaml b/Resources/translations/messages.ar.yaml deleted file mode 100644 index 7c9af5e..0000000 --- a/Resources/translations/messages.ar.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: 'غير محدد' - 'no': لا - 'yes': نعم -flash: - error: - form: 'شكل الأخطاء المكتشفة. اصلاحها وإعادة تشكيل' -price: - default: AED %price% diff --git a/Resources/translations/messages.en.yaml b/Resources/translations/messages.en.yaml deleted file mode 100644 index 3b22dc3..0000000 --- a/Resources/translations/messages.en.yaml +++ /dev/null @@ -1,11 +0,0 @@ -boolean: - indeterminate: Indeterminate - no: No - yes: Yes - -flash: - error: - form: Form Errors Detected. Fix Them and Resubmit Form - -price: - default: $%price% diff --git a/Resources/translations/messages.fr.yaml b/Resources/translations/messages.fr.yaml deleted file mode 100644 index 0a68160..0000000 --- a/Resources/translations/messages.fr.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: Indéterminée - 'no': 'Pas de' - 'yes': Oui -flash: - error: - form: 'Des Erreurs Détectées. Les corriger et de soumettre à nouveau le Formulaire' -price: - default: '%price% €' diff --git a/Resources/translations/messages.ru.yaml b/Resources/translations/messages.ru.yaml deleted file mode 100644 index cfe7ef7..0000000 --- a/Resources/translations/messages.ru.yaml +++ /dev/null @@ -1,11 +0,0 @@ -boolean: - indeterminate: Не определено - no: Нет - yes: Да - -flash: - error: - form: При обработке формы были обнаружены ошибки. Исправьте их и повторите отправку - -price: - default: '%price% руб.' diff --git a/Resources/translations/messages.zh.yaml b/Resources/translations/messages.zh.yaml deleted file mode 100644 index 5127d35..0000000 --- a/Resources/translations/messages.zh.yaml +++ /dev/null @@ -1,9 +0,0 @@ -boolean: - indeterminate: 不确定 - 'no': 没有 - 'yes': 是的 -flash: - error: - form: '形成的错误检测。 解决这些问题,并重新提交形式' -price: - default: ¥%price% diff --git a/Resources/translations/validators.ar.yaml b/Resources/translations/validators.ar.yaml deleted file mode 100644 index d6f4979..0000000 --- a/Resources/translations/validators.ar.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 'هذه القيمة غير صالحة رقم الهاتف.' diff --git a/Resources/translations/validators.en.yaml b/Resources/translations/validators.en.yaml deleted file mode 100644 index 33ef3f7..0000000 --- a/Resources/translations/validators.en.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: This value is not valid phone number. diff --git a/Resources/translations/validators.fr.yaml b/Resources/translations/validators.fr.yaml deleted file mode 100644 index 98b4740..0000000 --- a/Resources/translations/validators.fr.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 'Cette valeur n''est pas valide, numéro de téléphone.' diff --git a/Resources/translations/validators.ru.yaml b/Resources/translations/validators.ru.yaml deleted file mode 100644 index a6fd19d..0000000 --- a/Resources/translations/validators.ru.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: Номер телефона указан в неверном формате. diff --git a/Resources/translations/validators.zh.yaml b/Resources/translations/validators.zh.yaml deleted file mode 100644 index d2272d1..0000000 --- a/Resources/translations/validators.zh.yaml +++ /dev/null @@ -1,2 +0,0 @@ -phone: - regex: 这种价值是不是有效的电话号码。 From 73446acbb1e84c1adf471b65fdf4d0499b67c436 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 13:59:53 +0300 Subject: [PATCH 168/192] Add override doc. --- Resources/doc/override.md | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Resources/doc/override.md diff --git a/Resources/doc/override.md b/Resources/doc/override.md new file mode 100644 index 0000000..bc0af96 --- /dev/null +++ b/Resources/doc/override.md @@ -0,0 +1,41 @@ +Override +======== + +## Configuration + +```yaml +darvin_utils: + override: + DarvinECommerceBundle: + order: + entities: + - Order\Order + templates: + - admin/order + - order + product: + entities: + - Product + templates: + - product +``` + +## Usage + +### Override all functionality + +```shell script +$ bin/console darvin:utils:override product +``` + +### Override specific functionality + +```shell script +$ bin/console darvin:utils:override product admin +``` + +### Specify bundle if subject name is ambiguous + +```shell script +$ bin/console darvin:utils:override product -b DarvinECommerceBundle +``` From 199b95a7b2d30e98d55c39f28ce7fea8b55de245 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 14 Jan 2020 15:52:18 +0300 Subject: [PATCH 169/192] Simplify override configuration. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 76cfa25..456d0fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -92,3 +92,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Move macros template to utils lib. - Move translations to utils lib. + +7.3.1: Simplify override configuration. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index afd7304..4f249e8 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -104,8 +104,13 @@ private function buildOverrideNode(): ArrayNodeDefinition ->prototype('array')->useAttributeAsKey('subject') ->prototype('array') ->children() - ->arrayNode('entities')->prototype('scalar')->cannotBeEmpty()->end()->end() - ->arrayNode('templates')->prototype('scalar')->cannotBeEmpty(); + ->arrayNode('entities') + ->prototype('scalar')->cannotBeEmpty()->end() + ->beforeNormalization()->castToArray()->end() + ->end() + ->arrayNode('templates') + ->prototype('scalar')->cannotBeEmpty()->end() + ->beforeNormalization()->castToArray(); return $root; } From 93185d4d209281650ce2f9398d582aa2c948466c Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 22 Jan 2020 09:23:55 +0300 Subject: [PATCH 170/192] Rename "Sluggable entity manager" => "Sluggable manager". --- CHANGELOG.md | 2 ++ DependencyInjection/Compiler/AddSlugHandlersPass.php | 2 +- Resources/config/services/sluggable.yaml | 7 ++----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 456d0fb..40782a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -94,3 +94,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case - Move translations to utils lib. 7.3.1: Simplify override configuration. + +7.3.2: Rename "Sluggable entity manager" => "Sluggable manager". diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index 033694a..c9655f6 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -20,7 +20,7 @@ */ class AddSlugHandlersPass implements CompilerPassInterface { - private const ID = 'darvin_utils.sluggable.manager.entity'; + private const ID = 'darvin_utils.sluggable.manager'; /** * {@inheritDoc} diff --git a/Resources/config/services/sluggable.yaml b/Resources/config/services/sluggable.yaml index 12e6ef9..f577d26 100644 --- a/Resources/config/services/sluggable.yaml +++ b/Resources/config/services/sluggable.yaml @@ -1,5 +1,5 @@ parameters: - darvin_utils.sluggable.manager.entity.class: Darvin\Utils\Sluggable\SluggableEntityManager + darvin_utils.sluggable.manager.class: Darvin\Utils\Sluggable\SluggableManager darvin_utils.sluggable.subscriber.class: Darvin\Utils\EventListener\SlugifySubscriber @@ -8,10 +8,7 @@ services: Darvin\Utils\EventListener\SlugifySubscriberInterface: '@darvin_utils.sluggable.subscriber' darvin_utils.sluggable.manager: - alias: darvin_utils.sluggable.manager.entity - - darvin_utils.sluggable.manager.entity: - class: '%darvin_utils.sluggable.manager.entity.class%' + class: '%darvin_utils.sluggable.manager.class%' arguments: - '@darvin_utils.entity_manager.provider' - '@event_dispatcher' From 887ccd1cd6914463f81e1e6ae4b2d1706973d039 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 31 Jan 2020 08:28:23 +0300 Subject: [PATCH 171/192] Disable alias services compiler pass. --- CHANGELOG.md | 2 ++ DarvinUtilsBundle.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40782a0..f5322a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,3 +96,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.1: Simplify override configuration. 7.3.2: Rename "Sluggable entity manager" => "Sluggable manager". + +7.3.3: Disable alias services compiler pass. diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index dee0d20..0a67dd8 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -13,7 +13,7 @@ use Darvin\UtilsBundle\DependencyInjection\Compiler\AddAnnotationDriversPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddOverridersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\AddSlugHandlersPass; -use Darvin\UtilsBundle\DependencyInjection\Compiler\AliasServicesPass; +//use Darvin\UtilsBundle\DependencyInjection\Compiler\AliasServicesPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\CreateServiceProvidersPass; use Darvin\UtilsBundle\DependencyInjection\Compiler\OverrideEntitiesPass; use Symfony\Component\DependencyInjection\Compiler\PassConfig; @@ -36,7 +36,7 @@ public function build(ContainerBuilder $container): void ->addCompilerPass(new AddAnnotationDriversPass()) ->addCompilerPass(new AddOverridersPass()) ->addCompilerPass(new AddSlugHandlersPass()) - ->addCompilerPass(new AliasServicesPass()) +// ->addCompilerPass(new AliasServicesPass()) ->addCompilerPass(new CreateServiceProvidersPass()) ->addCompilerPass(new OverrideEntitiesPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION, 10); } From f20b48890743bfe841e828ee604d311bfd682739 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 4 Feb 2020 13:32:03 +0300 Subject: [PATCH 172/192] Add antispam form theme. --- CHANGELOG.md | 2 ++ DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/app/twig.yaml | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 Resources/config/app/twig.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index f5322a4..c0645eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -98,3 +98,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.2: Rename "Sluggable entity manager" => "Sluggable manager". 7.3.3: Disable alias services compiler pass. + +7.3.4: Add antispam form theme. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 59c391c..3511b10 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -112,6 +112,7 @@ public function prepend(ContainerBuilder $container): void (new ExtensionConfigurator($container, __DIR__.'/../Resources/config/app'))->configure([ 'doctrine', 'stof_doctrine_extensions', + 'twig', ]); if ($container->hasExtension('framework') || $container->hasExtension('twig')) { diff --git a/Resources/config/app/twig.yaml b/Resources/config/app/twig.yaml new file mode 100644 index 0000000..f88682b --- /dev/null +++ b/Resources/config/app/twig.yaml @@ -0,0 +1,3 @@ +twig: + form_themes: + - '@DarvinUtils/fields.html.twig' From 77b474d84883068cbb7c9a524611dc1b185b3388 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 12 Mar 2020 09:30:08 +0300 Subject: [PATCH 173/192] Add copy cloned uploadables event subscriber. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 1 + DependencyInjection/DarvinUtilsExtension.php | 4 +++- .../services/{cloner.yaml => cloner/common.yaml} | 0 Resources/config/services/cloner/uploadable.yaml | 16 ++++++++++++++++ 5 files changed, 22 insertions(+), 1 deletion(-) rename Resources/config/services/{cloner.yaml => cloner/common.yaml} (100%) create mode 100644 Resources/config/services/cloner/uploadable.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index c0645eb..5ce82c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,3 +100,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.3: Disable alias services compiler pass. 7.3.4: Add antispam form theme. + +7.3.5: Add copy cloned uploadables event subscriber. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 4f249e8..436a8ac 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -50,6 +50,7 @@ public function getConfigTreeBuilder(): TreeBuilder $root ->children() ->append($this->buildOverrideNode()) + ->scalarNode('tmp_dir')->defaultValue(sprintf('%s/darvin/utils', sys_get_temp_dir()))->cannotBeEmpty()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 3511b10..38ccc2e 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -35,6 +35,7 @@ class DarvinUtilsExtension extends Extension implements PrependExtensionInterfac private const BUNDLE_DOCTRINE_EXTENSIONS = 'StofDoctrineExtensionsBundle'; private const BUNDLE_SECURITY = 'SecurityBundle'; private const BUNDLE_TWIG = 'TwigBundle'; + private const BUNDLE_UPLOADER = 'VichUploaderBundle'; private const CLASS_FILESYSTEM = 'Symfony\Component\Filesystem\Filesystem'; private const CLASS_FORM = 'Symfony\Component\Form\Form'; @@ -66,7 +67,8 @@ public function load(array $configs, ContainerBuilder $container): void 'service', 'transliteratable/common', - 'cloner' => ['class' => self::CLASS_PROPERTY_ACCESS], + 'cloner/common' => ['class' => self::CLASS_PROPERTY_ACCESS], + 'cloner/uploadable' => ['class' => [self::CLASS_PROPERTY_ACCESS, self::CLASS_FILESYSTEM], 'bundle' => self::BUNDLE_UPLOADER], 'custom_object' => ['class' => self::CLASS_PROPERTY_ACCESS], diff --git a/Resources/config/services/cloner.yaml b/Resources/config/services/cloner/common.yaml similarity index 100% rename from Resources/config/services/cloner.yaml rename to Resources/config/services/cloner/common.yaml diff --git a/Resources/config/services/cloner/uploadable.yaml b/Resources/config/services/cloner/uploadable.yaml new file mode 100644 index 0000000..6e9674e --- /dev/null +++ b/Resources/config/services/cloner/uploadable.yaml @@ -0,0 +1,16 @@ +parameters: + darvin_utils.cloner.uploadable.tmp_dir: '%darvin_utils.tmp_dir%/cloner/uploadable' + + darvin_utils.cloner.uploadable.copy_event_subscriber.class: Darvin\Utils\EventListener\Cloner\CopyUploadablesSubscriber + +services: + darvin_utils.cloner.uploadable.copy_event_subscriber: + class: '%darvin_utils.cloner.uploadable.copy_event_subscriber.class%' + arguments: + - '@filesystem' + - '@vich_uploader.metadata_reader' + - '@property_accessor' + - '@vich_uploader.storage' + - '%darvin_utils.cloner.uploadable.tmp_dir%' + tags: + - { name: kernel.event_subscriber } From 569c3042744f406fcc9bcdf89c296e4dd3180a97 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Mar 2020 14:26:54 +0300 Subject: [PATCH 174/192] Register JSON encoder service. --- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/services/json.yaml | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 Resources/config/services/json.yaml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 38ccc2e..1ab15aa 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -58,6 +58,7 @@ public function load(array $configs, ContainerBuilder $container): void 'callback', 'flash', 'homepage', + 'json', 'locale', 'mapping', 'new_object', diff --git a/Resources/config/services/json.yaml b/Resources/config/services/json.yaml new file mode 100644 index 0000000..21b51c8 --- /dev/null +++ b/Resources/config/services/json.yaml @@ -0,0 +1,10 @@ +parameters: + darvin_utils.json.encoder.class: Darvin\Utils\Json\JsonEncoder + +services: + Darvin\Utils\Json\JsonEncoderInterface: '@darvin_utils.json.encoder' + + darvin_utils.json.encoder: + class: '%darvin_utils.json.encoder.class%' + arguments: + - '%kernel.debug%' From a6b7b025cf8e2c8094aec42927a0d87066929302 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 19 Mar 2020 14:27:55 +0300 Subject: [PATCH 175/192] Update changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce82c1..27fa9df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -102,3 +102,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.4: Add antispam form theme. 7.3.5: Add copy cloned uploadables event subscriber. + +7.3.6: Add JSON encoder. From 84c4377c211811b39dd61b2f486f0d96183e17ef Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 29 Apr 2020 16:30:44 +0300 Subject: [PATCH 176/192] Change temporary files directory from "/tmp" to "%kernel.project_dir%/var/tmp". --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27fa9df..d4a3635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -104,3 +104,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.5: Add copy cloned uploadables event subscriber. 7.3.6: Add JSON encoder. + +7.3.7: Change temporary files directory from "/tmp" to "%kernel.project_dir%/var/tmp". diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 436a8ac..529e7f9 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -50,7 +50,7 @@ public function getConfigTreeBuilder(): TreeBuilder $root ->children() ->append($this->buildOverrideNode()) - ->scalarNode('tmp_dir')->defaultValue(sprintf('%s/darvin/utils', sys_get_temp_dir()))->cannotBeEmpty()->end() + ->scalarNode('tmp_dir')->defaultValue('%kernel.project_dir%/var/tmp/darvin/utils')->cannotBeEmpty()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() From e07ba426a66a9c3fc5772736404893d35a70e4b2 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 13 Aug 2020 10:07:57 +0300 Subject: [PATCH 177/192] Add HTTP cache clear command. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 9 +++++++++ DependencyInjection/DarvinUtilsExtension.php | 4 ++++ Resources/config/services/cache/http.yaml | 13 +++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 Resources/config/services/cache/http.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index d4a3635..c69c2cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -106,3 +106,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.6: Add JSON encoder. 7.3.7: Change temporary files directory from "/tmp" to "%kernel.project_dir%/var/tmp". + +7.3.8: Add HTTP cache clear command. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 529e7f9..0e898a2 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -52,6 +52,15 @@ public function getConfigTreeBuilder(): TreeBuilder ->append($this->buildOverrideNode()) ->scalarNode('tmp_dir')->defaultValue('%kernel.project_dir%/var/tmp/darvin/utils')->cannotBeEmpty()->end() ->scalarNode('yandex_translate_api_key')->defaultNull()->end() + ->arrayNode('cache')->addDefaultsIfNotSet() + ->children() + ->arrayNode('http')->canBeEnabled() + ->children() + ->scalarNode('dir')->defaultValue('%kernel.cache_dir%/http_cache')->cannotBeEmpty()->end() + ->end() + ->end() + ->end() + ->end() ->arrayNode('response')->addDefaultsIfNotSet() ->children() ->booleanNode('compress')->defaultFalse(); diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 1ab15aa..7bb126d 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -68,6 +68,10 @@ public function load(array $configs, ContainerBuilder $container): void 'service', 'transliteratable/common', + 'cache/http' => ['callback' => function () use ($config): bool { + return $config['cache']['http']['enabled']; + }], + 'cloner/common' => ['class' => self::CLASS_PROPERTY_ACCESS], 'cloner/uploadable' => ['class' => [self::CLASS_PROPERTY_ACCESS, self::CLASS_FILESYSTEM], 'bundle' => self::BUNDLE_UPLOADER], diff --git a/Resources/config/services/cache/http.yaml b/Resources/config/services/cache/http.yaml new file mode 100644 index 0000000..f28d9ba --- /dev/null +++ b/Resources/config/services/cache/http.yaml @@ -0,0 +1,13 @@ +parameters: + darvin_utils.cache.http.clear.command.class: Darvin\Utils\Command\Cache\Http\ClearCommand + darvin_utils.cache.http.clear.command.name: darvin:utils:http-cache:clear + +services: + darvin_utils.cache.http.clear.command: + class: '%darvin_utils.cache.http.clear.command.class%' + arguments: + - '%darvin_utils.cache.http.clear.command.name%' + - '@filesystem' + - '%darvin_utils.cache.http.dir%' + tags: + - { name: console.command } From 15b7865c92836929177e68a34dd88b4feb929891 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 4 Sep 2020 15:31:12 +0300 Subject: [PATCH 178/192] Remove integration with yandex translate API. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 1 - Resources/config/services/dev/translation.yaml | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c69c2cc..78e04d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,3 +108,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.7: Change temporary files directory from "/tmp" to "%kernel.project_dir%/var/tmp". 7.3.8: Add HTTP cache clear command. + +7.3.9: Remove integration with yandex translate API. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0e898a2..c757d68 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -51,7 +51,6 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->append($this->buildOverrideNode()) ->scalarNode('tmp_dir')->defaultValue('%kernel.project_dir%/var/tmp/darvin/utils')->cannotBeEmpty()->end() - ->scalarNode('yandex_translate_api_key')->defaultNull()->end() ->arrayNode('cache')->addDefaultsIfNotSet() ->children() ->arrayNode('http')->canBeEnabled() diff --git a/Resources/config/services/dev/translation.yaml b/Resources/config/services/dev/translation.yaml index 80f1882..98c9834 100644 --- a/Resources/config/services/dev/translation.yaml +++ b/Resources/config/services/dev/translation.yaml @@ -21,6 +21,5 @@ services: class: '%darvin_utils.translation.translate_command.class%' arguments: - '%darvin_utils.translation.translate_command.name%' - - '%darvin_utils.yandex_translate_api_key%' tags: - { name: console.command } From f783aebafa9824d151e2b3319d08f78ff53b2988 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 10 Sep 2020 15:09:21 +0300 Subject: [PATCH 179/192] Add Varnish cache clear command. --- CHANGELOG.md | 2 ++ DependencyInjection/Configuration.php | 7 +++++++ DependencyInjection/DarvinUtilsExtension.php | 4 ++++ Resources/config/services/cache/varnish.yaml | 21 ++++++++++++++++++++ 4 files changed, 34 insertions(+) create mode 100644 Resources/config/services/cache/varnish.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 78e04d3..55f8478 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -110,3 +110,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.8: Add HTTP cache clear command. 7.3.9: Remove integration with yandex translate API. + +7.3.10: Add Varnish cache clear command. diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c757d68..51b035a 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -58,6 +58,13 @@ public function getConfigTreeBuilder(): TreeBuilder ->scalarNode('dir')->defaultValue('%kernel.cache_dir%/http_cache')->cannotBeEmpty()->end() ->end() ->end() + ->arrayNode('varnish')->canBeEnabled() + ->children() + ->scalarNode('url')->isRequired()->cannotBeEmpty()->end() + ->scalarNode('method')->defaultValue('XCGFULLBAN')->cannotBeEmpty()->end() + ->integerNode('timeout')->defaultValue(3)->min(1)->end() + ->end() + ->end() ->end() ->end() ->arrayNode('response')->addDefaultsIfNotSet() diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 7bb126d..dad58e8 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -72,6 +72,10 @@ public function load(array $configs, ContainerBuilder $container): void return $config['cache']['http']['enabled']; }], + 'cache/varnish' => ['extension' => 'curl', 'callback' => function () use ($config): bool { + return $config['cache']['varnish']['enabled']; + }], + 'cloner/common' => ['class' => self::CLASS_PROPERTY_ACCESS], 'cloner/uploadable' => ['class' => [self::CLASS_PROPERTY_ACCESS, self::CLASS_FILESYSTEM], 'bundle' => self::BUNDLE_UPLOADER], diff --git a/Resources/config/services/cache/varnish.yaml b/Resources/config/services/cache/varnish.yaml new file mode 100644 index 0000000..6c0c978 --- /dev/null +++ b/Resources/config/services/cache/varnish.yaml @@ -0,0 +1,21 @@ +parameters: + darvin_utils.cache.varnish.clear.clearer.class: Darvin\Utils\Cache\Varnish\VarnishCacheClearer + + darvin_utils.cache.varnish.clear.command.class: Darvin\Utils\Command\Cache\Varnish\ClearCommand + darvin_utils.cache.varnish.clear.command.name: darvin:utils:varnish-cache:clear + +services: + darvin_utils.cache.varnish.clear.clearer: + class: '%darvin_utils.cache.varnish.clear.clearer.class%' + arguments: + - '%darvin_utils.cache.varnish.url%' + - '%darvin_utils.cache.varnish.method%' + - '%darvin_utils.cache.varnish.timeout%' + + darvin_utils.cache.varnish.clear.command: + class: '%darvin_utils.cache.varnish.clear.command.class%' + arguments: + - '%darvin_utils.cache.varnish.clear.command.name%' + - '@darvin_utils.cache.varnish.clear.clearer' + tags: + - { name: console.command } From 938b1ccb898c67f727779796b052363c93dc9ade Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 20 Nov 2020 08:35:01 +0300 Subject: [PATCH 180/192] Update copyrights. --- DarvinUtilsBundle.php | 2 +- DependencyInjection/Compiler/AddSlugHandlersPass.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/DarvinUtilsBundle.php b/DarvinUtilsBundle.php index 0a67dd8..34ffbc8 100644 --- a/DarvinUtilsBundle.php +++ b/DarvinUtilsBundle.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2019, Darvin Studio + * @copyright Copyright (c) 2015-2020, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE diff --git a/DependencyInjection/Compiler/AddSlugHandlersPass.php b/DependencyInjection/Compiler/AddSlugHandlersPass.php index c9655f6..a1ff950 100644 --- a/DependencyInjection/Compiler/AddSlugHandlersPass.php +++ b/DependencyInjection/Compiler/AddSlugHandlersPass.php @@ -1,7 +1,7 @@ - * @copyright Copyright (c) 2015-2019, Darvin Studio + * @copyright Copyright (c) 2015-2020, Darvin Studio * @link https://www.darvin-studio.ru * * For the full copyright and license information, please view the LICENSE From 71e229d125c9fec06068eb62712d7ae1fe142978 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Fri, 11 Dec 2020 08:40:22 +0300 Subject: [PATCH 181/192] Replace deprecated method calls. --- Resources/config/services/dev/override.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/Resources/config/services/dev/override.yaml b/Resources/config/services/dev/override.yaml index 2bf21f9..49e12fc 100644 --- a/Resources/config/services/dev/override.yaml +++ b/Resources/config/services/dev/override.yaml @@ -41,7 +41,6 @@ services: arguments: - '@doctrine.orm.entity_manager' - '@filesystem' - - '@darvin_content.translatable.manager' - '@twig' - '%kernel.bundles_metadata%' - '%kernel.project_dir%' From 8fee47c14157ec1966a163fe6092fd1841bf0b25 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 16 Feb 2021 16:00:21 +0300 Subject: [PATCH 182/192] Add data view factory. --- DependencyInjection/DarvinUtilsExtension.php | 1 + Resources/config/services/view.yaml | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 Resources/config/services/view.yaml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index dad58e8..9bcc8eb 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -67,6 +67,7 @@ public function load(array $configs, ContainerBuilder $container): void 'routing', 'service', 'transliteratable/common', + 'view', 'cache/http' => ['callback' => function () use ($config): bool { return $config['cache']['http']['enabled']; diff --git a/Resources/config/services/view.yaml b/Resources/config/services/view.yaml new file mode 100644 index 0000000..0c0cc2f --- /dev/null +++ b/Resources/config/services/view.yaml @@ -0,0 +1,10 @@ +parameters: + darvin_utils.view.data.factory.class: Darvin\Utils\View\Data\Factory\DataViewFactory + +services: + Darvin\Utils\View\Data\Factory\DataViewFactoryInterface: '@darvin_utils.view.data.factory' + + darvin_utils.view.data.factory: + class: '%darvin_utils.view.data.factory.class%' + arguments: + - '@darvin_utils.stringifier' From 9813fc5dfafd167626efcebc8944d3405cb5969f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 16 Feb 2021 16:09:41 +0300 Subject: [PATCH 183/192] Add data view factory. --- DependencyInjection/DarvinUtilsExtension.php | 2 +- Resources/config/services/data.yaml | 10 ++++++++++ Resources/config/services/view.yaml | 10 ---------- 3 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 Resources/config/services/data.yaml delete mode 100644 Resources/config/services/view.yaml diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 9bcc8eb..40e68de 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -56,6 +56,7 @@ public function load(array $configs, ContainerBuilder $container): void (new ConfigLoader($container, __DIR__.'/../Resources/config/services'))->load([ 'callback', + 'data', 'flash', 'homepage', 'json', @@ -67,7 +68,6 @@ public function load(array $configs, ContainerBuilder $container): void 'routing', 'service', 'transliteratable/common', - 'view', 'cache/http' => ['callback' => function () use ($config): bool { return $config['cache']['http']['enabled']; diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml new file mode 100644 index 0000000..83d6316 --- /dev/null +++ b/Resources/config/services/data.yaml @@ -0,0 +1,10 @@ +parameters: + darvin_utils.data.view.factory.class: Darvin\Utils\Data\View\Factory\DataViewFactory + +services: + Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' + + darvin_utils.data.view.factory: + class: '%darvin_utils.data.view.factory.class%' + arguments: + - '@darvin_utils.stringifier' diff --git a/Resources/config/services/view.yaml b/Resources/config/services/view.yaml deleted file mode 100644 index 0c0cc2f..0000000 --- a/Resources/config/services/view.yaml +++ /dev/null @@ -1,10 +0,0 @@ -parameters: - darvin_utils.view.data.factory.class: Darvin\Utils\View\Data\Factory\DataViewFactory - -services: - Darvin\Utils\View\Data\Factory\DataViewFactoryInterface: '@darvin_utils.view.data.factory' - - darvin_utils.view.data.factory: - class: '%darvin_utils.view.data.factory.class%' - arguments: - - '@darvin_utils.stringifier' From 45b9766a87cb5a27139186be3a97af961bce7c2a Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Tue, 16 Feb 2021 16:54:52 +0300 Subject: [PATCH 184/192] Implement data view factory. --- Resources/config/services/data.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index 83d6316..b477cb7 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -8,3 +8,4 @@ services: class: '%darvin_utils.data.view.factory.class%' arguments: - '@darvin_utils.stringifier' + - '@translator' From d7268e8e33f31fa8d372ac2c022b36cfbb2d0185 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 17 Feb 2021 09:05:04 +0300 Subject: [PATCH 185/192] Add "utils_data_to_view" Twig filter. --- Resources/config/services/data.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index b477cb7..a4fdee3 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -1,6 +1,8 @@ parameters: darvin_utils.data.view.factory.class: Darvin\Utils\Data\View\Factory\DataViewFactory + darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\ViewExtension + services: Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' @@ -9,3 +11,10 @@ services: arguments: - '@darvin_utils.stringifier' - '@translator' + + darvin_utils.data.view.twig.extension: + class: '%darvin_utils.data.view.twig.extension.class%' + arguments: + - '@darvin_utils.data.view.factory' + tags: + - { name: twig.extension } From abef4954005e47b986ed399fe2684df4b62797e3 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 17 Feb 2021 13:23:40 +0300 Subject: [PATCH 186/192] Add data view renderer. --- Resources/config/services/data.yaml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index a4fdee3..d72a199 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -1,10 +1,13 @@ parameters: darvin_utils.data.view.factory.class: Darvin\Utils\Data\View\Factory\DataViewFactory + darvin_utils.data.view.renderer.class: Darvin\Utils\Data\View\Renderer\DataViewRenderer + darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\ViewExtension services: - Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' + Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' + Darvin\Utils\Data\View\Renderer\DataViewRendererInterface: '@darvin_utils.data.view.renderer' darvin_utils.data.view.factory: class: '%darvin_utils.data.view.factory.class%' @@ -12,6 +15,12 @@ services: - '@darvin_utils.stringifier' - '@translator' + darvin_utils.data.view.renderer: + class: '%darvin_utils.data.view.renderer.class%' + arguments: + - '@darvin_utils.data.view.factory' + - '@twig' + darvin_utils.data.view.twig.extension: class: '%darvin_utils.data.view.twig.extension.class%' arguments: From d44047e8a6e1364412e5fe0f8721038bd0fecb2f Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 17 Feb 2021 13:36:31 +0300 Subject: [PATCH 187/192] Use data view renderer in Twig extension. --- Resources/config/services/data.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index d72a199..1fe1c40 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -3,7 +3,7 @@ parameters: darvin_utils.data.view.renderer.class: Darvin\Utils\Data\View\Renderer\DataViewRenderer - darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\ViewExtension + darvin_utils.data.view.renderer.twig.extension.class: Darvin\Utils\Twig\Extension\Data\View\RendererExtension services: Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' @@ -21,9 +21,9 @@ services: - '@darvin_utils.data.view.factory' - '@twig' - darvin_utils.data.view.twig.extension: - class: '%darvin_utils.data.view.twig.extension.class%' + darvin_utils.data.view.renderer.twig.extension: + class: '%darvin_utils.data.view.renderer.twig.extension.class%' arguments: - - '@darvin_utils.data.view.factory' + - '@darvin_utils.data.view.renderer' tags: - { name: twig.extension } From 8bb0356bf61aa6293e4337866ef38a93eeba874c Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 17 Feb 2021 14:54:45 +0300 Subject: [PATCH 188/192] Replace data view renderer Twig extension with data view Twig extension. --- Resources/config/services/data.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index 1fe1c40..2041da0 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -3,7 +3,7 @@ parameters: darvin_utils.data.view.renderer.class: Darvin\Utils\Data\View\Renderer\DataViewRenderer - darvin_utils.data.view.renderer.twig.extension.class: Darvin\Utils\Twig\Extension\Data\View\RendererExtension + darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\ViewExtension services: Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' @@ -18,12 +18,12 @@ services: darvin_utils.data.view.renderer: class: '%darvin_utils.data.view.renderer.class%' arguments: - - '@darvin_utils.data.view.factory' - '@twig' - darvin_utils.data.view.renderer.twig.extension: - class: '%darvin_utils.data.view.renderer.twig.extension.class%' + darvin_utils.data.view.twig.extension: + class: '%darvin_utils.data.view.twig.extension.class%' arguments: + - '@darvin_utils.data.view.factory' - '@darvin_utils.data.view.renderer' tags: - { name: twig.extension } From cc7bc7b3661bfc252c1df07d999e25a3d1c80f11 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 18 Feb 2021 08:47:11 +0300 Subject: [PATCH 189/192] Update changelog. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 55f8478..a252639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -112,3 +112,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.9: Remove integration with yandex translate API. 7.3.10: Add Varnish cache clear command. + +7.4.0: Add data view services. From 02b31a88a32c0c7b63b992985ba0b0fdf7c21358 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 18 Feb 2021 11:13:43 +0300 Subject: [PATCH 190/192] Reorganize data view renderer. --- Resources/config/services/data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index 2041da0..438d01b 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -3,7 +3,7 @@ parameters: darvin_utils.data.view.renderer.class: Darvin\Utils\Data\View\Renderer\DataViewRenderer - darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\ViewExtension + darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\View\ViewExtension services: Darvin\Utils\Data\View\Factory\DataViewFactoryInterface: '@darvin_utils.data.view.factory' From 91a164e8c02e4dd18affe54b87184140f238929e Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Thu, 18 Feb 2021 11:17:12 +0300 Subject: [PATCH 191/192] Add data view renderer Twig extension. --- Resources/config/services/data.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Resources/config/services/data.yaml b/Resources/config/services/data.yaml index 438d01b..c2d5da4 100644 --- a/Resources/config/services/data.yaml +++ b/Resources/config/services/data.yaml @@ -3,6 +3,8 @@ parameters: darvin_utils.data.view.renderer.class: Darvin\Utils\Data\View\Renderer\DataViewRenderer + darvin_utils.data.view.renderer.twig.extension.class: Darvin\Utils\Twig\Extension\Data\View\RendererExtension + darvin_utils.data.view.twig.extension.class: Darvin\Utils\Twig\Extension\Data\View\ViewExtension services: @@ -20,6 +22,13 @@ services: arguments: - '@twig' + darvin_utils.data.view.renderer.twig.extension: + class: '%darvin_utils.data.view.renderer.twig.extension.class%' + arguments: + - '@darvin_utils.data.view.renderer' + tags: + - { name: twig.extension } + darvin_utils.data.view.twig.extension: class: '%darvin_utils.data.view.twig.extension.class%' arguments: From ccba9dcd7c0681f1e0b36582dca7b5242ae42ec0 Mon Sep 17 00:00:00 2001 From: Igor Nikolaev Date: Wed, 28 Jul 2021 09:40:34 +0300 Subject: [PATCH 192/192] Move templates from Utils lib to make them overridable. --- CHANGELOG.md | 2 + DependencyInjection/DarvinUtilsExtension.php | 23 ++----- Resources/views/data/view/block.html.twig | 63 ++++++++++++++++++++ Resources/views/data/view/table.html.twig | 63 ++++++++++++++++++++ Resources/views/data/view/text.txt.twig | 33 ++++++++++ Resources/views/fields.html.twig | 3 + Resources/views/macros.html.twig | 5 ++ Resources/views/override/entity.php.twig | 41 +++++++++++++ Resources/views/override/repository.php.twig | 19 ++++++ Resources/views/price.html.twig | 5 ++ 10 files changed, 240 insertions(+), 17 deletions(-) create mode 100644 Resources/views/data/view/block.html.twig create mode 100644 Resources/views/data/view/table.html.twig create mode 100644 Resources/views/data/view/text.txt.twig create mode 100644 Resources/views/fields.html.twig create mode 100644 Resources/views/macros.html.twig create mode 100644 Resources/views/override/entity.php.twig create mode 100644 Resources/views/override/repository.php.twig create mode 100644 Resources/views/price.html.twig diff --git a/CHANGELOG.md b/CHANGELOG.md index a252639..1c29641 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -114,3 +114,5 @@ $ /usr/bin/env php bin/console darvin:utils:translations:title-case 7.3.10: Add Varnish cache clear command. 7.4.0: Add data view services. + +7.5.0: Move templates from Utils lib to make them overridable. diff --git a/DependencyInjection/DarvinUtilsExtension.php b/DependencyInjection/DarvinUtilsExtension.php index 40e68de..a4e563e 100644 --- a/DependencyInjection/DarvinUtilsExtension.php +++ b/DependencyInjection/DarvinUtilsExtension.php @@ -127,25 +127,14 @@ public function prepend(ContainerBuilder $container): void 'twig', ]); - if ($container->hasExtension('framework') || $container->hasExtension('twig')) { - $dir = sprintf('%s/../Resources', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName())); - - if ($container->hasExtension('framework')) { - $container->prependExtensionConfig('framework', [ - 'translator' => [ - 'paths' => [ - sprintf('%s/translations', $dir), - ], - ], - ]); - } - if ($container->hasExtension('twig')) { - $container->prependExtensionConfig('twig', [ + if ($container->hasExtension('framework')) { + $container->prependExtensionConfig('framework', [ + 'translator' => [ 'paths' => [ - sprintf('%s/views', $dir) => 'DarvinUtils', + sprintf('%s/translations', sprintf('%s/../Resources', dirname((new \ReflectionClass(ExtensionConfigurator::class))->getFileName()))), ], - ]); - } + ], + ]); } } diff --git a/Resources/views/data/view/block.html.twig b/Resources/views/data/view/block.html.twig new file mode 100644 index 0000000..43506ae --- /dev/null +++ b/Resources/views/data/view/block.html.twig @@ -0,0 +1,63 @@ +{% macro block(view, show_title = true) %} +
    + + {% if show_title and view.hasTitle %} + + {{ view.title }} + + {% endif %} + + + + {% if view.empty %} + — + {% else %} + + {% if view.hasChildren %} + + {% if view.associative %} +
      + + {% for child in view.children %} +
    • {{ _self.block(child) }}
    • + {% endfor %} + +
    + {% else %} +
      + + {% for child in view.children %} +
    1. {{ _self.block(child) }}
    2. + {% endfor %} + +
    + {% endif %} + + {% endif %} + + {% if view.hasValue %} + + {% if view.hasUrl %} + + {{ view.value }} + + {% else %} + {{ view.value|raw }} + {% endif %} + + {% endif %} + + {% endif %} + +
    +
    +{% endmacro %} + +{% if view %} + + {{ _self.block(view, false) }} + +{% endif %} diff --git a/Resources/views/data/view/table.html.twig b/Resources/views/data/view/table.html.twig new file mode 100644 index 0000000..1b07a36 --- /dev/null +++ b/Resources/views/data/view/table.html.twig @@ -0,0 +1,63 @@ +{% macro row(view, show_title = true) %} + + + {% if show_title and view.hasTitle %} + {{ view.title }} + {% endif %} + + + + {% if view.empty %} + — + {% else %} + + {% if view.hasChildren %} + + + {% for child in view.children %} + + {{ _self.row(child) }} + + {% endfor %} + +
    + {% endif %} + + {% if view.hasValue %} + + {% if view.hasUrl %} + + {{ view.value }} + + {% else %} + {{ view.value|raw }} + {% endif %} + + {% endif %} + + {% endif %} + + + +{% endmacro %} + +{% if view %} + + + {% if view.hasChildren %} + + {% for child in view.children %} + + {{ _self.row(child) }} + + {% endfor %} + + {% else %} + + {{ _self.row(view, false) }} + + {% endif %} + +
    +{% endif %} diff --git a/Resources/views/data/view/text.txt.twig b/Resources/views/data/view/text.txt.twig new file mode 100644 index 0000000..3810385 --- /dev/null +++ b/Resources/views/data/view/text.txt.twig @@ -0,0 +1,33 @@ +{%- macro text(view, level = 0) -%} + + {%- if level > 0 and view.hasTitle -%} + {{- view.title ~ ': ' -}} + {%- endif -%} + + {%- if view.empty -%} + - + {%- else -%} + + {%- if view.hasChildren -%} + + {%- for child in view.children %} + +{% if level > 0 %}{% for i in 1..level %}{{ ' ' }}{% endfor %}{% endif %}{{ _self.text(child, level + 1) -}} + + {%- endfor -%} + + {%- endif -%} + + {%- if view.hasValue -%} + {{- view.value|striptags -}} + {%- endif -%} + + {%- endif -%} + +{%- endmacro -%} + +{%- if view -%} + + {{- _self.text(view) -}} + +{%- endif -%} diff --git a/Resources/views/fields.html.twig b/Resources/views/fields.html.twig new file mode 100644 index 0000000..0ec628a --- /dev/null +++ b/Resources/views/fields.html.twig @@ -0,0 +1,3 @@ +{%- block darvin_utils_anti_spam_row -%} + {{- form_widget(form) -}} +{%- endblock darvin_utils_anti_spam_row -%} diff --git a/Resources/views/macros.html.twig b/Resources/views/macros.html.twig new file mode 100644 index 0000000..63c1f4d --- /dev/null +++ b/Resources/views/macros.html.twig @@ -0,0 +1,5 @@ +{% macro div_data(data, name, trans_domain = 'messages') %}{{ utils_data_render('block', data, name, trans_domain) }}{% endmacro %} + +{% macro plain_data(data, name, trans_domain = 'messages') %}{{ utils_data_render('text', data, name, trans_domain) }}{% endmacro %} + +{% macro table_data(data, name, trans_domain = 'messages') %}{{ utils_data_render('table', data, name, trans_domain) }}{% endmacro %} diff --git a/Resources/views/override/entity.php.twig b/Resources/views/override/entity.php.twig new file mode 100644 index 0000000..e984bf5 --- /dev/null +++ b/Resources/views/override/entity.php.twig @@ -0,0 +1,41 @@ + 0 or options.allow_empty %} + {{ ('price.value.' ~ options.format)|trans({'%price%': price|number_format(0, null, options.thousands_separator), '%count%': price|number_format(0, '', '')})|raw }} +{% else %} + {{ ('price.empty.' ~ options.empty_format)|trans|raw }} +{% endif %}