Skip to content

Commit

Permalink
SUPPORT-86536 - add symfony 6 support (#13)
Browse files Browse the repository at this point in the history
Co-authored-by: Yuri Gaidoba <[email protected]>
  • Loading branch information
ypppa and Yuri Gaidoba authored Dec 5, 2023
1 parent 73d265b commit eaf1e1d
Show file tree
Hide file tree
Showing 24 changed files with 324 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ composer.lock
bin/
var/
!bin/update-constraints-to-lowest.php

.phpunit.result.cache
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.7.0]
### Added
- Support for Symfony 6.4

### Changed
- Fixed code style
- Fixed tests

## [1.6.0]
### Added
- Allow library to work with various version of `paysera/lib-object-wrapper` from `0.1.0`
Expand Down
19 changes: 10 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
"require": {
"php": "^7.1 || ^8.0",
"ext-json": "*",
"symfony/framework-bundle": "^3.4.34|^4.3|^5.4",
"symfony/security-bundle": "^3.4.34|^4.3|^5.4",
"symfony/validator": "^3.4.34|^4.3|^5.4",
"symfony/framework-bundle": "^3.4.34|^4.3|^5.4|^6.0",
"symfony/security-bundle": "^3.4.34|^4.3|^5.4|^6.0",
"symfony/validator": "^3.4.34|^4.3|^5.4|^6.0",
"paysera/lib-normalization-bundle": "^1.1.0",
"paysera/lib-normalization": "^1.2",
"paysera/lib-object-wrapper": "~0.1",
"paysera/lib-pagination": "^1.0",
"paysera/lib-dependency-injection": "^1.3.0",
"psr/log": "^1.0|^2.0",
"doctrine/persistence": "^1.3.8 || ^2.0.1"
"doctrine/persistence": "^1.3.8 || ^2.0.1 || ^3.0",
"doctrine/annotations": "^v1.14"
},
"require-dev": {
"phpunit/phpunit": "^6.5 || ^9.0",
"mockery/mockery": "^1.2.4",
"symfony/yaml": "^3.4.34|^4.3|^5.4",
"doctrine/doctrine-bundle": "^1.4|^2.0",
"doctrine/orm": "^2.5.14|^2.6"
"phpunit/phpunit": "^7.5 || ^9.5",
"mockery/mockery": "^1.3.6",
"symfony/yaml": "^3.4.34|^4.3|^5.4|^6.0",
"doctrine/doctrine-bundle": "^1.12.0|^2.1",
"doctrine/orm": "^2.5.14"
},
"config": {
"bin-dir": "bin"
Expand Down
16 changes: 5 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit
backupGlobals = "false"
backupStaticAttributes = "false"
colors = "true"
convertErrorsToExceptions = "true"
convertNoticesToExceptions = "true"
convertWarningsToExceptions = "true"
processIsolation = "false"
stopOnFailure = "false"
bootstrap = "vendor/autoload.php" >
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
convertDeprecationsToExceptions="false"
colors="true">

<testsuites>
<testsuite name="Project Test Suite">
Expand Down
8 changes: 8 additions & 0 deletions src/DependencyInjection/PayseraApiExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\Persistence\ObjectRepository;
use Paysera\Bundle\ApiBundle\Service\PathAttributeResolver\DoctrinePathAttributeResolver;
use RuntimeException;
use Symfony\Bundle\FrameworkBundle\Routing\AttributeRouteControllerLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Definition;
Expand All @@ -23,6 +24,13 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/services'));
if (class_exists(AttributeRouteControllerLoader::class)) {
$loader->load('annotations.xml');
} else {
$loader->load('annotations_legacy.xml');
}

$container->setParameter('paysera_api.locales', $config['locales']);
if (count($config['locales']) === 0) {
$container->removeDefinition('paysera_api.listener.locale');
Expand Down
1 change: 0 additions & 1 deletion src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<imports>
<import resource="services/annotations.xml"/>
<import resource="services/listeners.xml"/>
<import resource="services/normalizers.xml"/>
<import resource="services/pagination.xml"/>
Expand Down
6 changes: 3 additions & 3 deletions src/Resources/config/services/annotations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<service decorates="routing.loader.annotation"
parent="routing.loader.annotation"
id="paysera_api.annotations.loader"
<service decorates="routing.loader.attribute"
parent="routing.loader.attribute"
id="paysera_api.loader.attribute"
class="Paysera\Bundle\ApiBundle\Service\Annotation\RoutingAnnotationLoader">
<call method="setRequestHelper">
<argument type="service" id="paysera_api.rest_request_helper"/>
Expand Down
25 changes: 25 additions & 0 deletions src/Resources/config/services/annotations_legacy.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<service decorates="routing.loader.annotation"
parent="routing.loader.annotation"
id="paysera_api.annotations.loader"
class="Paysera\Bundle\ApiBundle\Service\Annotation\RoutingAnnotationLoader">
<call method="setRequestHelper">
<argument type="service" id="paysera_api.rest_request_helper"/>
</call>
<call method="setRestRequestOptionsBuilder">
<argument type="service" id="paysera_api.annotations.options_builder"/>
</call>
</service>

<service id="paysera_api.annotations.options_builder"
class="Paysera\Bundle\ApiBundle\Service\Annotation\RestRequestOptionsBuilder">
<argument type="service" id="paysera_api.rest_request_options_validator"/>
</service>
</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\Kernel;

/**
* This is the class that loads and manages your bundle configuration.
Expand All @@ -24,7 +25,8 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.xml');
$prefix = Kernel::MAJOR_VERSION <= 4 ? 'legacy_' : '';
$loader->load($prefix . 'services.xml');

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="../../Controller/" type="annotation"/>

<route id="paysera_fixture_test_1" path="/config/by-full-controller">
<default key="_controller">PayseraFixtureTestBundle:Default:action1</default>
</route>
<route id="paysera_fixture_test_1b" path="/config/by-full-controller-and-class-name">
<default key="_controller">PayseraFixtureTestBundle:Default:action1b</default>
</route>
<route id="paysera_fixture_test_2" path="/config/by-class-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2</default>
</route>
<route id="paysera_fixture_test_3" path="/config/by-service-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action3</default>
</route>
<route id="paysera_fixture_test_4" path="/config/routing-by-service-name-config-by-class-name">
<default key="_controller">paysera_fixture_test.controller.default_controller:action4</default>
</route>
<route id="paysera_fixture_test_5" path="/config/routing-by-class-name-config-by-service-name">
<default key="_controller">Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action5</default>
</route>

<route id="paysera_fixture_test" path="/">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
</route>
<route id="paysera_fixture_test_with_return" path="/with-return">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithReturn</default>
</route>
<route id="paysera_fixture_test_with_url_parameter" path="/with-url-parameter/{urlParameter}">
<default key="_controller">paysera_fixture_test.controller.default_controller:action</default>
</route>
<route id="paysera_fixture_test_with_several_url_parameters" path="/with-url-parameters/{urlParameter1}/{urlParameter2}">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
</route>
<route id="paysera_fixture_test_with_several_parameters" path="/with-parameters">
<default key="_controller">paysera_fixture_test.controller.default_controller:actionWithMultipleParameters</default>
</route>
</routes>
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>
<service class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController"
id="paysera_fixture_test.controller.default_controller"
public="true"/>

<service id="paysera_fixture_test.normalizer.item_denormalizer.parameter"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:parameter"/>
<argument>parameter</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.parameter.custom"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:parameter" group="custom"/>
<argument>parameter_custom</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.key"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:key"/>
<argument>key</argument>
</service>
<service id="paysera_fixture_test.normalizer.item_denormalizer.key.custom"
class="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\ItemDenormalizer">
<tag name="paysera_normalization.object_denormalizer" type="extract:key" group="custom"/>
<argument>key_custom</argument>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PrefixedDenormalizer">
<tag name="paysera_normalization.mixed_type_denormalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\MyObjectNormalizer">
<tag name="paysera_normalization.object_denormalizer"/>
<tag name="paysera_normalization.normalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\MyObjectCustomNormalizer">
<tag name="paysera_normalization.object_denormalizer" type="my_object_custom"/>
<tag name="paysera_normalization.normalizer" type="my_object_custom"/>
<tag name="paysera_normalization.normalizer"
type="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Entity\MyObject"
group="custom"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PersistedEntityFilterDenormalizer">
<tag name="paysera_normalization.object_denormalizer"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Normalizer\PersistedEntityNormalizer">
<tag name="paysera_normalization.normalizer"/>
</service>

<service id="paysera_fixture_test.rest_request_options.1"
class="Paysera\Bundle\ApiBundle\Entity\RestRequestOptions">
<tag name="paysera_api.request_options" controller="PayseraFixtureTestBundle:Default:action1"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action1bAction"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action2"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller:action3"/>
<tag name="paysera_api.request_options"
controller="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\DefaultController::action4"/>
<tag name="paysera_api.request_options" controller="paysera_fixture_test.controller.default_controller::action5"/>

<call method="addQueryResolverOptions">
<argument type="service">
<service class="Paysera\Bundle\ApiBundle\Entity\QueryResolverOptions">
<call method="setDenormalizationType">
<argument>extract:parameter</argument>
</call>
<call method="setParameterName">
<argument>parameter</argument>
</call>
</service>
</argument>
</call>
</service>

<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedClassRequiredPermissionsController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\AnnotatedClassValidationController"
public="true"/>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Controller\PagedQueryController"
public="true">
<argument type="service" id="doctrine.orm.entity_manager"/>
</service>

<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\PrefixedPathAttributeResolver">
<tag name="paysera_api.path_attribute_resolver" type="prefixed"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\MyObjectResolver">
<tag name="paysera_api.path_attribute_resolver" type="my_object_resolver"/>
<tag name="paysera_api.path_attribute_resolver"
type="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\Entity\MyObject"/>
</service>
<service id="Paysera\Bundle\ApiBundle\Tests\Functional\Fixtures\FixtureTestBundle\PathAttributeResolver\NullResolver">
<tag name="paysera_api.path_attribute_resolver" type="always_null"/>
</service>
</services>
</container>
Loading

0 comments on commit eaf1e1d

Please sign in to comment.