Skip to content

Commit

Permalink
Merge branch 'feature-add-support-sf4'
Browse files Browse the repository at this point in the history
  • Loading branch information
sanpii committed Jan 17, 2018
2 parents e003e53 + ef1bcb1 commit b288e5d
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 13 deletions.
22 changes: 17 additions & 5 deletions .travis.yml
Expand Up @@ -15,6 +15,7 @@ env:
matrix:
- SYMFONY_VERSION=2
- SYMFONY_VERSION=3
- SYMFONY_VERSION=4

matrix:
allow_failures:
Expand All @@ -37,22 +38,33 @@ 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 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION"
- cd tests/
- test "$SYMFONY_VERSION" -eq 4 || composer require --no-update "symfony/lts:^$SYMFONY_VERSION"
- 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

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
- ./bin/behat --tags "~@upper${CURRENT_SYMFONY_VERSION}lts"
- ./app/console pomm:generate:schema-all default_session_builder
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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": {
Expand Down
9 changes: 7 additions & 2 deletions sources/lib/DependencyInjection/Compiler/ModelPass.php
Expand Up @@ -61,11 +61,16 @@ 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())
->setAutowiringTypes([$old->getClass()]) //set this one as a default for autowire
;

if (version_compare(\Symfony\Component\HttpKernel\Kernel::VERSION, '3.3', '<')) {
$service->addAutowiringType($old->getClass());
}

$container->setAlias($class, $id);
}
}
}
2 changes: 2 additions & 0 deletions sources/lib/DependencyInjection/PommExtension.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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'])) {
Expand Down
27 changes: 26 additions & 1 deletion sources/lib/Resources/config/services/pomm.yml
Expand Up @@ -2,117 +2,142 @@ 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'
calls:
- ['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'
calls:
- ['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
3 changes: 3 additions & 0 deletions sources/lib/Resources/config/services/profiler.yml
Expand Up @@ -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
2 changes: 1 addition & 1 deletion 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
Expand Down
6 changes: 3 additions & 3 deletions 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",
Expand Down
26 changes: 26 additions & 0 deletions tests/src/AppBundle/Controller/AutowireController.php
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of the pomm-bundle package.
*
*/
namespace AppBundle\Controller;
use AppBundle\Model\MyDb1\PublicSchema\ConfigModel;
use PommProject\Foundation\Pomm;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
/**
* @author Mikael Paris <stood86@gmail.com>
*/
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')
);
}
}
5 changes: 5 additions & 0 deletions tests/src/AppBundle/Resources/config/routing.yml
Expand Up @@ -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]
5 changes: 5 additions & 0 deletions tests/src/AppBundle/Resources/config/services.yml
Expand Up @@ -2,8 +2,13 @@ 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:
- { name: controller.service_arguments }
6 changes: 6 additions & 0 deletions tests/tests/Features/autowire.feature
@@ -0,0 +1,6 @@
@upper2lts
Feature: Autowire

Scenario:
When I am on "/app_dev.php/get_autowire/test"
Then I should see "test => value"

0 comments on commit b288e5d

Please sign in to comment.