Skip to content

Commit

Permalink
Merge 20a3c10 into 1bf113e
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 5, 2021
2 parents 1bf113e + 20a3c10 commit 431e23e
Show file tree
Hide file tree
Showing 27 changed files with 196 additions and 55 deletions.
105 changes: 105 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -956,3 +956,108 @@ jobs:
vendor/bin/behat --out=std --format=progress --profile=default --no-interaction
}
phpunit_legacy_metadata:
name: PHPUnit (PHP ${{ matrix.php }}) 2.7 BC layer
env:
METADATA_BACKWARD_COMPATIBILITY_LAYER: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php:
- '7.4'
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Require Symfony components
run: composer require symfony/intl symfony/uid --dev --no-interaction --no-progress --ansi
- name: Install PHPUnit
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run PHPUnit tests
run: |
mkdir -p build/logs/phpunit
vendor/bin/simple-phpunit --log-junit build/logs/phpunit/junit.xml
behat_legacy_metadata:
name: Behat (PHP ${{ matrix.php }}) 2.7 BC layer
env:
METADATA_BACKWARD_COMPATIBILITY_LAYER: 1
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
matrix:
php:
- '7.4'
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
tools: pecl, composer
extensions: intl, bcmath, curl, openssl, mbstring, pdo_sqlite
coverage: pcov
ini-values: memory_limit=-1
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
restore-keys: ${{ runner.os }}-composer-
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Require Symfony components
run: composer require symfony/intl symfony/uid --dev --no-interaction --no-progress --ansi
- name: Install PHPUnit
run: vendor/bin/simple-phpunit --version
- name: Clear test app cache
run: tests/Fixtures/app/console cache:clear --ansi
- name: Run Behat tests
run: |
mkdir -p build/logs/behat
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default --no-interaction --tags='~@php8'
- name: Run Behat tests
if: (startsWith(matrix.php, '8.0'))
run: |
mkdir -p build/logs/behat
vendor/bin/behat --out=std --format=progress --format=junit --out=build/logs/behat/junit --profile=default --no-interaction
- name: Export OpenAPI documents
run: |
mkdir -p build/out/openapi
tests/Fixtures/app/console api:openapi:export --spec-version=2 -o build/out/openapi/swagger_v2.json
tests/Fixtures/app/console api:openapi:export --spec-version=2 --yaml -o build/out/openapi/swagger_v2.yaml
tests/Fixtures/app/console api:openapi:export --spec-version=3 -o build/out/openapi/openapi_v3.json
tests/Fixtures/app/console api:openapi:export --spec-version=3 --yaml -o build/out/openapi/openapi_v3.yaml
- name: Validate OpenAPI documents
run: |
npx swagger-cli validate build/out/openapi/swagger_v2.json
npx swagger-cli validate build/out/openapi/swagger_v2.yaml
npx swagger-cli validate build/out/openapi/openapi_v3.json
npx swagger-cli validate build/out/openapi/openapi_v3.yaml
1 change: 0 additions & 1 deletion phpstan.neon.dist
Expand Up @@ -50,7 +50,6 @@ parameters:
- handleNotFound
ignoreErrors:
# False positives
- '#Parameter \#1 \$callback of function call_user_func expects callable\(\): mixed, non-empty-string given\.#'
-
message: '#Unreachable statement - code above always terminates.#'
paths:
Expand Down
Expand Up @@ -14,6 +14,7 @@
namespace ApiPlatform\Core\Bridge\Doctrine\EventListener;

use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface;
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
use ApiPlatform\Core\HttpCache\PurgerInterface;
use ApiPlatform\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -45,10 +46,14 @@ final class PurgeHttpCacheListener
private $xkeyEnabled;
private $httpTagsEnabled;

public function __construct(PurgerInterface $purger, IriConverterInterface $iriConverter, ResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null, PurgerInterface $xKeyPurger = null, bool $xkeyEnabled = false, bool $httpTagsEnabled = true)
public function __construct(PurgerInterface $purger, $iriConverter, ResourceClassResolverInterface $resourceClassResolver, PropertyAccessorInterface $propertyAccessor = null, PurgerInterface $xKeyPurger = null, bool $xkeyEnabled = false, bool $httpTagsEnabled = true)
{
$this->purger = $purger;
$this->iriConverter = $iriConverter;
if ($iriConverter instanceof LegacyIriConverterInterface) {
trigger_deprecation('api-platform/core', '2.7', sprintf('Use an implementation of "%s" instead of "%s".', IriConverterInterface::class, LegacyIriConverterInterface::class));
}

$this->resourceClassResolver = $resourceClassResolver;
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
$this->xKeyPurger = $xKeyPurger;
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Bridge/Doctrine/MongoDbOdm/ItemDataProvider.php
Expand Up @@ -108,7 +108,7 @@ public function getItem(string $resourceClass, $id, string $operationName = null
$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);

if ($resourceMetadata instanceof ResourceMetadataCollection) {
$attribute = $resourceMetadata->getOperation($operationName)->getExtraProperties()['doctrine_mongodb'] ?? [];
$attribute = $resourceMetadata->getOperation()->getExtraProperties()['doctrine_mongodb'] ?? [];
} else {
$attribute = $resourceMetadata->getItemOperationAttribute($operationName, 'doctrine_mongodb', [], true);
}
Expand Down
Expand Up @@ -33,6 +33,8 @@
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Extractor\XmlExtractor;
use ApiPlatform\Core\Metadata\Extractor\YamlExtractor;
use ApiPlatform\GraphQl\Error\ErrorHandlerInterface;
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
use ApiPlatform\GraphQl\Resolver\QueryCollectionResolverInterface;
Expand Down Expand Up @@ -789,18 +791,23 @@ private function registerLegacyServices(ContainerBuilder $container, array $conf
return;
}

$container->removeDefinition('api_platform.identifiers_extractor');
$container->removeAlias('api_platform.identifiers_extractor');
$container->setAlias('api_platform.identifiers_extractor', 'api_platform.identifiers_extractor.legacy');

$container->removeDefinition('api_platform.iri_converter');
$container->removeAlias('api_platform.iri_converter');
$container->setAlias('api_platform.iri_converter', 'api_platform.iri_converter.legacy');

$container->removeDefinition('api_platform.openapi.factory');
$container->removeAlias('api_platform.openapi.factory');
$container->setAlias('api_platform.openapi.factory', 'api_platform.openapi.factory.legacy');

$definition = $container->getDefinition('api_platform.metadata.property.metadata_factory.serializer');
$definition->setArgument(0, $container->getDefinition('api_platform.metadata.resource.metadata_factory'));
$definition->setArgument(0, new Reference('api_platform.metadata.resource.metadata_factory'));
$container->setDefinition('api_platform.metadata.property.metadata_factory.serializer', $definition);

$container->getDefinition('api_platform.metadata.extractor.xml')->setClass(XmlExtractor::class);
if (class_exists(Yaml::class)) {
$container->getDefinition('api_platform.metadata.extractor.yaml')->setClass(YamlExtractor::class);
}
}

private function registerRectorConfiguration(ContainerBuilder $container, XmlFileLoader $loader): void
Expand Down
16 changes: 9 additions & 7 deletions src/Core/Bridge/Symfony/Bundle/Resources/config/api.xml
Expand Up @@ -71,15 +71,16 @@
</service>
<service id="ApiPlatform\Core\Api\IriConverterInterface" alias="api_platform.iri_converter.legacy" />

<service id="api_platform.iri_converter" class="ApiPlatform\Bridge\Symfony\Routing\IriConverter" public="false">
<service id="api_platform.symfony.iri_converter" class="ApiPlatform\Bridge\Symfony\Routing\IriConverter" public="false">
<argument type="service" id="api_platform.state_provider" />
<argument type="service" id="api_platform.router" />
<argument type="service" id="api_platform.identifiers_extractor" />
<argument type="service" id="api_platform.api.identifiers_extractor" />
<argument type="service" id="api_platform.identifier.converter" />
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
</service>
<service id="ApiPlatform\Api\IriConverterInterface" alias="api_platform.iri_converter" />
<service id="api_platform.iri_converter" alias="api_platform.symfony.iri_converter" />
<service id="ApiPlatform\Api\IriConverterInterface" alias="api_platform.symfony.iri_converter" />

<service id="api_platform.formats_provider" class="ApiPlatform\Core\Api\FormatsProvider">
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
Expand Down Expand Up @@ -216,7 +217,7 @@

<service id="api_platform.listener.view.respond" class="ApiPlatform\Core\EventListener\RespondListener">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" priority="8" />
</service>

Expand Down Expand Up @@ -262,7 +263,7 @@
<argument>%api_platform.version%</argument>
<argument>null</argument>
<argument on-invalid="null">%api_platform.swagger.versions%</argument>
<argument type="service" id="api_platform.openapi.factory" on-invalid="null"></argument>
<argument type="service" id="api_platform.openapi.factory.next" on-invalid="null"></argument>
</service>

<service id="api_platform.action.exception" class="ApiPlatform\Core\Action\ExceptionAction" public="true">
Expand Down Expand Up @@ -290,14 +291,15 @@
</service>
<service id="ApiPlatform\Core\Api\IdentifiersExtractorInterface" alias="api_platform.identifiers_extractor.cached" />

<service id="api_platform.identifiers_extractor" class="ApiPlatform\Api\IdentifiersExtractor" public="false">
<service id="api_platform.api.identifiers_extractor" class="ApiPlatform\Api\IdentifiersExtractor" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
<argument type="service" id="api_platform.property_accessor" />
</service>
<service id="ApiPlatform\Api\IdentifiersExtractorInterface" alias="api_platform.identifiers_extractor" />
<service id="api_platform.identifiers_extractor" alias="api_platform.api.identifiers_extractor" />
<service id="ApiPlatform\Api\IdentifiersExtractorInterface" alias="api_platform.api.identifiers_extractor" />

<service id="api_platform.identifier.converter" class="ApiPlatform\Core\Identifier\IdentifierConverter" public="false">
<argument type="service" id="api_platform.identifiers_extractor.cached" />
Expand Down
Expand Up @@ -10,7 +10,7 @@

<service id="api_platform.doctrine_mongodb.odm.listener.mercure.publish" class="ApiPlatform\Core\Bridge\Doctrine\EventListener\PublishMercureUpdatesListener">
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.serializer" />
<argument>%api_platform.formats%</argument>
Expand Down
Expand Up @@ -10,7 +10,7 @@

<service id="api_platform.doctrine.orm.listener.mercure.publish" class="ApiPlatform\Core\Bridge\Doctrine\EventListener\PublishMercureUpdatesListener">
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.serializer" />
<argument>%api_platform.formats%</argument>
Expand Down
10 changes: 5 additions & 5 deletions src/Core/Bridge/Symfony/Bundle/Resources/config/graphql.xml
Expand Up @@ -53,7 +53,7 @@

<service id="api_platform.graphql.resolver.stage.read" class="ApiPlatform\GraphQl\Resolver\Stage\ReadStage" public="false">
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.collection_data_provider" />
<argument type="service" id="api_platform.subresource_data_provider" />
<argument type="service" id="api_platform.graphql.serializer.context_builder" />
Expand Down Expand Up @@ -95,7 +95,7 @@
</service>

<service id="api_platform.graphql.resolver.resource_field" class="ApiPlatform\GraphQl\Resolver\ResourceFieldResolver" public="false">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
</service>

<service id="api_platform.graphql.query_resolver_locator" class="Symfony\Component\DependencyInjection\ServiceLocator">
Expand Down Expand Up @@ -209,7 +209,7 @@
<service id="api_platform.graphql.normalizer.item" class="ApiPlatform\GraphQl\Serializer\ItemNormalizer" public="false">
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.identifiers_extractor.cached" />
<argument type="service" id="api_platform.resource_class_resolver" />
<argument type="service" id="api_platform.property_accessor" />
Expand All @@ -229,7 +229,7 @@

<service id="api_platform.graphql.normalizer.object" class="ApiPlatform\GraphQl\Serializer\ObjectNormalizer" public="false">
<argument type="service" id="serializer.normalizer.object" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.identifiers_extractor.cached" />

<!-- Run after serializer.denormalizer.array but before serializer.normalizer.object -->
Expand Down Expand Up @@ -266,7 +266,7 @@
<argument type="service" id="api_platform.graphql.cache.subscription" />
<argument type="service" id="api_platform.graphql.subscription.subscription_identifier_generator" />
<argument type="service" id="api_platform.graphql.resolver.stage.serialize" />
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
</service>

<service id="api_platform.graphql.subscription.subscription_identifier_generator" class="ApiPlatform\GraphQl\Subscription\SubscriptionIdentifierGenerator" />
Expand Down
Expand Up @@ -10,7 +10,7 @@
<service id="api_platform.http_cache.purger.varnish.xkey" class="ApiPlatform\Core\HttpCache\VarnishXKeyPurger" public="false" />

<service id="api_platform.http_cache.listener.response.add_tags" class="ApiPlatform\Core\HttpCache\EventListener\AddTagsListener">
<argument type="service" id="api_platform.iri_converter" />
<argument type="service" id="api_platform.symfony.iri_converter" />
<argument type="service" id="api_platform.metadata.resource.metadata_collection_factory" />
<argument>%api_platform.http_cache.invalidation.xkey.enabled%</argument>
<argument>%api_platform.http_cache.invalidation.xkey.glue%</argument>
Expand Down
Expand Up @@ -9,6 +9,7 @@
<argument type="service" id="annotation_reader" />
<argument>%api_platform.resource_class_directories%</argument>
<argument type="service" id="api_platform.metadata.resource.name_collection_factory.annotation.inner" />
<argument>%api_platform.metadata_backward_compatibility_layer%</argument>
</service>

<service id="api_platform.metadata.resource.metadata_factory.annotation" decorates="api_platform.metadata.resource.metadata_factory" decoration-priority="40" class="ApiPlatform\Core\Metadata\Resource\Factory\AnnotationResourceMetadataFactory" public="false">
Expand Down

0 comments on commit 431e23e

Please sign in to comment.