From cf11999943b97a82773a716f9d6e122615d8d4d3 Mon Sep 17 00:00:00 2001 From: Mikael Paris Date: Fri, 15 Dec 2017 22:01:01 +0100 Subject: [PATCH 1/7] add support sf4 --- composer.json | 2 +- .../Compiler/ModelPass.php | 7 ++++- .../lib/DependencyInjection/PommExtension.php | 2 ++ .../lib/Resources/config/services/pomm.yml | 27 ++++++++++++++++++- .../Resources/config/services/profiler.yml | 3 +++ tests/behat.yml.dist | 2 +- tests/composer.json | 6 ++--- .../Controller/AutowireController.php | 26 ++++++++++++++++++ .../AppBundle/Resources/config/routing.yml | 5 ++++ .../AppBundle/Resources/config/services.yml | 4 +++ tests/tests/Features/autowire.feature | 5 ++++ 11 files changed, 82 insertions(+), 7 deletions(-) create mode 100644 tests/src/AppBundle/Controller/AutowireController.php create mode 100644 tests/tests/Features/autowire.feature diff --git a/composer.json b/composer.json index ce5dfca..8fdc286 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "jdorn/sql-formatter": "~1.2", "pomm-project/model-manager": "~2.0", "pomm-project/cli": "~2.0", - "pomm-project/pomm-symfony-bridge": "~2.4", + "pomm-project/pomm-symfony-bridge": "~2.5", "symfony/framework-bundle": "~2.8|~3.0|~4.0" }, "require-dev": { diff --git a/sources/lib/DependencyInjection/Compiler/ModelPass.php b/sources/lib/DependencyInjection/Compiler/ModelPass.php index 4f70752..7c1d4dd 100644 --- a/sources/lib/DependencyInjection/Compiler/ModelPass.php +++ b/sources/lib/DependencyInjection/Compiler/ModelPass.php @@ -64,8 +64,13 @@ private function addTagged(DI\ContainerBuilder $container, $tag, $defaultService $container->register($id, $old->getClass()) ->setFactory([new DI\Reference($sessionId), $method]) ->addArgument($old->getClass()) - ->setAutowiringTypes([$old->getClass()]) //set this one as a default for autowire ; + + if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '>=')) { + $container->setAlias($class, $id); + } else { + $container->addAutowiringType($old->getClass()); + } } } } diff --git a/sources/lib/DependencyInjection/PommExtension.php b/sources/lib/DependencyInjection/PommExtension.php index 79d6225..0f4e6ab 100644 --- a/sources/lib/DependencyInjection/PommExtension.php +++ b/sources/lib/DependencyInjection/PommExtension.php @@ -10,6 +10,7 @@ namespace PommProject\PommBundle\DependencyInjection; use Symfony\Component\Config\FileLocator; +use Symfony\Component\DependencyInjection\Alias; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -60,6 +61,7 @@ public function configure(array $config, ContainerBuilder $container) { $definition = $container->getDefinition('pomm'); + $container->setAlias('PommProject\Foundation\Pomm', new Alias('pomm', false)); $container->setParameter('pomm.configuration', $config['configuration']); if (isset($config['logger']['service'])) { diff --git a/sources/lib/Resources/config/services/pomm.yml b/sources/lib/Resources/config/services/pomm.yml index 2b1ea77..5d7c5b7 100644 --- a/sources/lib/Resources/config/services/pomm.yml +++ b/sources/lib/Resources/config/services/pomm.yml @@ -2,52 +2,62 @@ services: pomm: class: 'PommProject\Foundation\Pomm' configurator: ['@pomm.session_builder.configurator_chain', configure] + public: true pomm.converter.entity: class: 'PommProject\PommBundle\Request\ParamConverter\EntityParamConverter' arguments: ['@pomm'] tags: - { name: request.param_converter, converter: pomm.entity } + public: true pomm.serializer.normalizer: class: 'PommProject\SymfonyBridge\Serializer\Normalizer\FlexibleEntityNormalizer' tags: - { name: serializer.normalizer, priority: 10 } + public: true + pomm.serializer.denormalizer: class: 'PommProject\SymfonyBridge\Serializer\Normalizer\FlexibleEntityDenormalizer' arguments: ['@pomm'] tags: - { name: serializer.normalizer, priority: 10 } + public: true pomm.property_list_info: class: 'PommProject\SymfonyBridge\PropertyInfo\Extractor\ListExtractor' arguments: ['@pomm'] tags: - { name: "property_info.list_extractor" } + public: true pomm.property_type_info: class: 'PommProject\SymfonyBridge\PropertyInfo\Extractor\TypeExtractor' arguments: ['@pomm'] tags: - { name: "property_info.type_extractor" } + public: true # @deprecated pomm.property_info: class: 'PommProject\SymfonyBridge\PropertyInfo\Extractor\PommExtractor' arguments: ['@pomm'] tags: - { name: "property_info.type_extractor" } - + public: true pomm.session_builder: class: 'PommProject\Foundation\SessionBuilder' pomm.model_manager.session_builder: class: 'PommProject\ModelManager\SessionBuilder' + public: true pomm.session_builder.configurator: class: 'PommProject\PommBundle\Model\Configurator' arguments: [null] + public: true pomm.session_builder.configurator_chain: class: 'PommProject\PommBundle\Model\ChainConfigurator' arguments: [['@pomm.session_builder.configurator', '@?pomm.data_collector.configurator']] + public: true pomm.pooler.model: class: 'PommProject\PommBundle\Model\ContainerModelPooler' @@ -55,12 +65,15 @@ services: - ['setContainer', ['@service_container']] tags: - { name: pomm.pooler } + public: true + pomm.pooler.model_layer: class: 'PommProject\PommBundle\Model\ContainerModelLayerPooler' calls: - ['setContainer', ['@service_container']] tags: - { name: pomm.pooler } + public: true pomm.commands.inspect_config: class: 'PommProject\Cli\Command\InspectConfig' @@ -68,51 +81,63 @@ services: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true + pomm.commands.inspect_database: class: 'PommProject\Cli\Command\InspectDatabase' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true + pomm.commands.inspect_schema: class: 'PommProject\Cli\Command\InspectSchema' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true + pomm.commands.inspect_relation: class: 'PommProject\Cli\Command\InspectRelation' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true pomm.commands.generate_relation_structure: class: 'PommProject\Cli\Command\GenerateRelationStructure' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true pomm.commands.generate_relation_model: class: 'PommProject\Cli\Command\GenerateRelationModel' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true pomm.commands.generate_entity: class: 'PommProject\Cli\Command\GenerateEntity' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true pomm.commands.generate_for_relation: class: 'PommProject\Cli\Command\GenerateForRelation' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true pomm.commands.generate_for_schema: class: 'PommProject\Cli\Command\GenerateForSchema' calls: - ['setPomm', ['@pomm']] tags: - { name: console.command } + public: true \ No newline at end of file diff --git a/sources/lib/Resources/config/services/profiler.yml b/sources/lib/Resources/config/services/profiler.yml index 331588e..5e68e74 100644 --- a/sources/lib/Resources/config/services/profiler.yml +++ b/sources/lib/Resources/config/services/profiler.yml @@ -4,11 +4,14 @@ services: arguments: ['@?kernel', '@?debug.stopwatch'] tags: - { name: data_collector, template: '@Pomm/Collector/time.html.twig', id: 'time'} + public: true pomm.data_collector: class: 'PommProject\SymfonyBridge\DatabaseDataCollector' arguments: [null,'@?debug.stopwatch'] tags: - { name: data_collector, template: '@Pomm/Profiler/db.html.twig', id: 'pomm'} + public: true pomm.data_collector.configurator: class: 'PommProject\SymfonyBridge\Configurator\DatabaseCollectorConfigurator' arguments: ['@?pomm.data_collector'] + public: true diff --git a/tests/behat.yml.dist b/tests/behat.yml.dist index f195f45..1b82660 100644 --- a/tests/behat.yml.dist +++ b/tests/behat.yml.dist @@ -1,7 +1,7 @@ default: suites: default: - paths: [ %paths.base%/tests/Features ] + paths: [ "%paths.base%/tests/Features" ] contexts: - FeatureContext - behatch:context:json diff --git a/tests/composer.json b/tests/composer.json index 6af3056..54e7275 100644 --- a/tests/composer.json +++ b/tests/composer.json @@ -1,14 +1,14 @@ { "require": { - "symfony/symfony": "~2.8|~3.0", + "symfony/symfony": "~2.8|~3.0|~4.0", "symfony/monolog-bundle": "~3.0", "twig/extensions": "~1.0", - "sensio/framework-extra-bundle": "~3.0,>=3.0.2", + "sensio/framework-extra-bundle": "~3.0,>=3.0.2|~4.0", "pomm-project/cli": "~2.0", "pomm-project/foundation": "~2.0", "pomm-project/model-manager": "~2.0", "pomm-project/pomm-bundle": "dev-master", - "pomm-project/pomm-symfony-bridge": "~2.4" + "pomm-project/pomm-symfony-bridge": "~2.5" }, "require-dev": { "behatch/contexts": "~2.7|~3.0", diff --git a/tests/src/AppBundle/Controller/AutowireController.php b/tests/src/AppBundle/Controller/AutowireController.php new file mode 100644 index 0000000..c375985 --- /dev/null +++ b/tests/src/AppBundle/Controller/AutowireController.php @@ -0,0 +1,26 @@ + + */ +class AutowireController extends Controller +{ + public function getAutowireAction($name, Pomm $pomm) + { + $config = $pomm + ->getDefaultSession() + ->getModel(ConfigModel::class) + ->findByPk(['name' => $name]); + return $this->render( + 'AppBundle:Front:get.html.twig', + compact('config') + ); + } +} diff --git a/tests/src/AppBundle/Resources/config/routing.yml b/tests/src/AppBundle/Resources/config/routing.yml index 2c37717..8cb420a 100644 --- a/tests/src/AppBundle/Resources/config/routing.yml +++ b/tests/src/AppBundle/Resources/config/routing.yml @@ -57,3 +57,8 @@ serviceContainer: path: /serviceContainer defaults: { _controller: index_controller:serviceContainerAction } methods: [GET] + +get_autowire: + path: /get_autowire/{name} + defaults: { _controller: autowire_controller:getAutowireAction } + methods: [GET] diff --git a/tests/src/AppBundle/Resources/config/services.yml b/tests/src/AppBundle/Resources/config/services.yml index 585ff76..7622c80 100644 --- a/tests/src/AppBundle/Resources/config/services.yml +++ b/tests/src/AppBundle/Resources/config/services.yml @@ -2,8 +2,12 @@ services: index_controller: class: AppBundle\Controller\IndexController arguments: ['@templating', '@pomm.default_session', '@serializer', '@property_info', '@pomm.session.service_db', '@service_model'] + public: true service_model: class: AppBundle\Model\MyDb1\PublicSchema\ServiceModel arguments: ['@logger'] tags: - { name: pomm.model, session: pomm.session.service_db } + autowire_controller: + class: AppBundle\Controller\AutowireController + tags: ['controller.service_arguments'] diff --git a/tests/tests/Features/autowire.feature b/tests/tests/Features/autowire.feature new file mode 100644 index 0000000..8c34da8 --- /dev/null +++ b/tests/tests/Features/autowire.feature @@ -0,0 +1,5 @@ +Feature: Autowire + + Scenario: + When I am on "/app_dev.php/get_autowire/test" + Then I should see "test => value" \ No newline at end of file From 0475f73060539fbd2b587d6a90ed488a68c438b3 Mon Sep 17 00:00:00 2001 From: Mikael Paris Date: Fri, 15 Dec 2017 22:22:45 +0100 Subject: [PATCH 2/7] add sf4 in test --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 592e520..07e87e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ env: matrix: - SYMFONY_VERSION=2 - SYMFONY_VERSION=3 + - SYMFONY_VERSION=4 matrix: allow_failures: From ce6249a191c2f8d1b0a7ac69b6ddff60bd448708 Mon Sep 17 00:00:00 2001 From: Mikael Paris Date: Sat, 30 Dec 2017 17:51:07 +0100 Subject: [PATCH 3/7] correct tag for sf2 and force dependency for test --- .travis.yml | 14 +++++++++----- .../lib/DependencyInjection/Compiler/ModelPass.php | 9 +++++---- tests/src/AppBundle/Resources/config/services.yml | 3 ++- tests/tests/Features/autowire.feature | 1 + 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07e87e5..9cd5e6a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,22 +38,26 @@ before_install: - php -S localhost:8080 -t tests/web &> /dev/null & - ln -fs parameters.yml.dist tests/app/config/parameters.yml + - test "$SYMFONY_VERSION" -eq 2 && composer require --no-update symfony/lts:^2||true + - test "$SYMFONY_VERSION" -eq 3 && composer require --no-update symfony/lts:^3||true + - cd tests/ + - test "$SYMFONY_VERSION" -eq 2 && composer require --no-update symfony/lts:^2||true + - test "$SYMFONY_VERSION" -eq 3 && composer require --no-update symfony/lts:^3||true + - cd .. install: - echo 'memory_limit=-1' > travis.php.ini - phpenv config-add travis.php.ini - - composer install - - test "$SYMFONY_VERSION" -eq 3 || composer update --prefer-lowest + - composer update - cd tests/ - - composer install - - test "$SYMFONY_VERSION" -eq 3 || composer update --prefer-lowest + - composer update - rm -rf vendor/pomm-project/pomm-bundle - ln -s ../../../ vendor/pomm-project/pomm-bundle script: - ../vendor/bin/phpcs --standard=psr2 --runtime-set ignore_warnings_on_exit true --report=summary ../sources - ./app/console pomm:generate:schema-all -d 'src/' -a 'AppBundle\Model' my_db1 - - ./bin/behat + - test "$SYMFONY_VERSION" -eq 2 && ./bin/behat --tags '~@upper2lts' ||./bin/behat - ./app/console pomm:generate:schema-all default_session_builder diff --git a/sources/lib/DependencyInjection/Compiler/ModelPass.php b/sources/lib/DependencyInjection/Compiler/ModelPass.php index 7c1d4dd..28e043d 100644 --- a/sources/lib/DependencyInjection/Compiler/ModelPass.php +++ b/sources/lib/DependencyInjection/Compiler/ModelPass.php @@ -61,16 +61,17 @@ private function addTagged(DI\ContainerBuilder $container, $tag, $defaultService $container->removeDefinition($id); $container->addDefinitions([$id . '.pomm.inner' => $old]); - $container->register($id, $old->getClass()) + $service = $container->register($id, $old->getClass()) ->setFactory([new DI\Reference($sessionId), $method]) ->addArgument($old->getClass()) ; - if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '>=')) { - $container->setAlias($class, $id); - } else { + if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '<')) { $container->addAutowiringType($old->getClass()); } + + $container->setAlias($class, $id); + } } } diff --git a/tests/src/AppBundle/Resources/config/services.yml b/tests/src/AppBundle/Resources/config/services.yml index 7622c80..c88039f 100644 --- a/tests/src/AppBundle/Resources/config/services.yml +++ b/tests/src/AppBundle/Resources/config/services.yml @@ -10,4 +10,5 @@ services: - { name: pomm.model, session: pomm.session.service_db } autowire_controller: class: AppBundle\Controller\AutowireController - tags: ['controller.service_arguments'] + tags: + - { name: controller.service_arguments } diff --git a/tests/tests/Features/autowire.feature b/tests/tests/Features/autowire.feature index 8c34da8..29c6507 100644 --- a/tests/tests/Features/autowire.feature +++ b/tests/tests/Features/autowire.feature @@ -1,3 +1,4 @@ +@upper2lts Feature: Autowire Scenario: From 9756461d85d3c6ca924cb2c1506dd723026a4bf7 Mon Sep 17 00:00:00 2001 From: Mikael Paris Date: Sat, 30 Dec 2017 18:04:28 +0100 Subject: [PATCH 4/7] correct error phpcs --- sources/lib/DependencyInjection/Compiler/ModelPass.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sources/lib/DependencyInjection/Compiler/ModelPass.php b/sources/lib/DependencyInjection/Compiler/ModelPass.php index 28e043d..9bbeb88 100644 --- a/sources/lib/DependencyInjection/Compiler/ModelPass.php +++ b/sources/lib/DependencyInjection/Compiler/ModelPass.php @@ -70,8 +70,7 @@ private function addTagged(DI\ContainerBuilder $container, $tag, $defaultService $container->addAutowiringType($old->getClass()); } - $container->setAlias($class, $id); - + $container->setAlias($class, $id); } } } From 5cb9b32c4c39d2f55b8a7ca27a5c29cf9d0b077a Mon Sep 17 00:00:00 2001 From: Mikael Paris Date: Sat, 30 Dec 2017 18:29:19 +0100 Subject: [PATCH 5/7] correct typo for model --- sources/lib/DependencyInjection/Compiler/ModelPass.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/lib/DependencyInjection/Compiler/ModelPass.php b/sources/lib/DependencyInjection/Compiler/ModelPass.php index 9bbeb88..e0ab0f9 100644 --- a/sources/lib/DependencyInjection/Compiler/ModelPass.php +++ b/sources/lib/DependencyInjection/Compiler/ModelPass.php @@ -67,7 +67,7 @@ private function addTagged(DI\ContainerBuilder $container, $tag, $defaultService ; if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '<')) { - $container->addAutowiringType($old->getClass()); + $service->addAutowiringType($old->getClass()); } $container->setAlias($class, $id); From 912f2e1fcd61783c134cacb5f1781bf360d1d939 Mon Sep 17 00:00:00 2001 From: Sanpi Date: Tue, 16 Jan 2018 20:25:00 +0100 Subject: [PATCH 6/7] [travis] Simplify multiple symfony version support --- .travis.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9cd5e6a..3b3e17a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,11 +38,9 @@ before_install: - php -S localhost:8080 -t tests/web &> /dev/null & - ln -fs parameters.yml.dist tests/app/config/parameters.yml - - test "$SYMFONY_VERSION" -eq 2 && composer require --no-update symfony/lts:^2||true - - test "$SYMFONY_VERSION" -eq 3 && composer require --no-update symfony/lts:^3||true + - test "$SYMFONY_VERSION" -eq 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION" - cd tests/ - - test "$SYMFONY_VERSION" -eq 2 && composer require --no-update symfony/lts:^2||true - - test "$SYMFONY_VERSION" -eq 3 && composer require --no-update symfony/lts:^3||true + - test "$SYMFONY_VERSION" -eq 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION" - cd .. install: @@ -59,5 +57,5 @@ install: script: - ../vendor/bin/phpcs --standard=psr2 --runtime-set ignore_warnings_on_exit true --report=summary ../sources - ./app/console pomm:generate:schema-all -d 'src/' -a 'AppBundle\Model' my_db1 - - test "$SYMFONY_VERSION" -eq 2 && ./bin/behat --tags '~@upper2lts' ||./bin/behat + - ./bin/behat --tags "~@upper${SYMFONY_VERSION}lts" - ./app/console pomm:generate:schema-all default_session_builder From ef1bcb124b089c61dc40343dce1591fd6621c374 Mon Sep 17 00:00:00 2001 From: Sanpi Date: Tue, 16 Jan 2018 20:29:12 +0100 Subject: [PATCH 7/7] [travis] Get real symfony version before running behat --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b3e17a..3f46031 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,8 +54,17 @@ install: - rm -rf vendor/pomm-project/pomm-bundle - ln -s ../../../ vendor/pomm-project/pomm-bundle +before_script: + - | + export CURRENT_SYMFONY_VERSION=$( \ + composer show --format=json \ + | jq '.installed[] | select(.name == "symfony/symfony") | .version' \ + | sed 's/^"v\([0-9]\+\)\.[^"]*"/\1/' \ + ) + - echo $CURRENT_SYMFONY_VERSION + script: - ../vendor/bin/phpcs --standard=psr2 --runtime-set ignore_warnings_on_exit true --report=summary ../sources - ./app/console pomm:generate:schema-all -d 'src/' -a 'AppBundle\Model' my_db1 - - ./bin/behat --tags "~@upper${SYMFONY_VERSION}lts" + - ./bin/behat --tags "~@upper${CURRENT_SYMFONY_VERSION}lts" - ./app/console pomm:generate:schema-all default_session_builder