Skip to content

Commit

Permalink
Merge pull request #90 from coopTilleuls/fix/api_platform
Browse files Browse the repository at this point in the history
fix: API Platform documentation bridge
  • Loading branch information
vincentchalamon committed Feb 8, 2022
2 parents 8320b46 + ce4cd27 commit b889a5b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CoopTilleulsForgotPasswordBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@

namespace CoopTilleuls\ForgotPasswordBundle;

use CoopTilleuls\ForgotPasswordBundle\DependencyInjection\CompilerPass\ApiPlatformCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;

/**
* @author Vincent Chalamon <vincent@les-tilleuls.coop>
*/
final class CoopTilleulsForgotPasswordBundle extends Bundle
{
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new ApiPlatformCompilerPass());
}
}
34 changes: 34 additions & 0 deletions DependencyInjection/CompilerPass/ApiPlatformCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

/*
* This file is part of the CoopTilleulsForgotPasswordBundle package.
*
* (c) Vincent Chalamon <vincent@les-tilleuls.coop>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace CoopTilleuls\ForgotPasswordBundle\DependencyInjection\CompilerPass;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

/**
* @author Vincent Chalamon <vincent@les-tilleuls.coop>
*/
final class ApiPlatformCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('api_platform.swagger.normalizer.documentation')) {
$container->removeDefinition('coop_tilleuls_forgot_password.normalizer.documentation');
}

if (!$container->hasDefinition('api_platform.openapi.factory')) {
$container->removeDefinition('coop_tilleuls_forgot_password.openapi.factory');
}
}
}
8 changes: 0 additions & 8 deletions DependencyInjection/CoopTilleulsForgotPasswordExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,5 @@ public function load(array $configs, ContainerBuilder $container): void
$class = true === $config['use_jms_serializer'] ? JMSNormalizer::class : SymfonyNormalizer::class;
$serializerId = true === $config['use_jms_serializer'] ? 'jms_serializer.serializer' : 'serializer';
$container->setDefinition('coop_tilleuls_forgot_password.normalizer', new Definition($class, [new Reference($serializerId)]))->setPublic(false);

if (!$container->hasDefinition('api_platform.swagger.normalizer.documentation')) {
$container->removeDefinition('coop_tilleuls_forgot_password.normalizer.documentation');
}

if (!$container->hasDefinition('api_platform.openapi.factory')) {
$container->removeDefinition('coop_tilleuls_forgot_password.openapi.factory');
}
}
}

0 comments on commit b889a5b

Please sign in to comment.