Skip to content

Commit

Permalink
Tracking changes for configured paths
Browse files Browse the repository at this point in the history
  • Loading branch information
yceruto committed Dec 2, 2023
1 parent 0d6acf2 commit c25d34e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/DependencyInjection/Compiler/TrackPathsPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace OpenSolid\OpenApiBundle\DependencyInjection\Compiler;

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

class TrackPathsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
$paths = $container->getParameter('openapi_paths');

foreach ($paths as $path) {
if (!$container->fileExists($path)) {
throw new \RuntimeException(sprintf('OpenAPI path "%s" not found.', $path));
}
}
}
}
3 changes: 3 additions & 0 deletions src/OpenApiBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace OpenSolid\OpenApiBundle;

use OpenSolid\OpenApiBundle\DependencyInjection\Compiler\SerializerMappingPass;
use OpenSolid\OpenApiBundle\DependencyInjection\Compiler\TrackPathsPass;
use OpenSolid\OpenApiBundle\DependencyInjection\Compiler\ValidatorMappingPass;
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
Expand All @@ -23,6 +25,7 @@ public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new ValidatorMappingPass());
$container->addCompilerPass(new SerializerMappingPass());
$container->addCompilerPass(new TrackPathsPass(), PassConfig::TYPE_AFTER_REMOVING);
}

public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
Expand Down

0 comments on commit c25d34e

Please sign in to comment.