components-web-app /
api-components-bundle
| 1 | <?php |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of the Silverback API Components Bundle Project |
||
| 5 | * |
||
| 6 | * (c) Daniel West <[email protected]> |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | declare(strict_types=1); |
||
| 13 | |||
| 14 | namespace Silverback\ApiComponentsBundle\DependencyInjection\CompilerPass; |
||
| 15 | |||
| 16 | use GuzzleHttp\Client; |
||
|
0 ignored issues
–
show
|
|||
| 17 | use Silverback\ApiComponentsBundle\EventListener\Api\CollectionApiEventListener; |
||
| 18 | use Silverback\ApiComponentsBundle\EventListener\Doctrine\PurgeHttpCacheListener; |
||
| 19 | use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
||
| 20 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 21 | use Symfony\Component\DependencyInjection\Definition; |
||
| 22 | use Symfony\Component\DependencyInjection\Reference; |
||
| 23 | use Symfony\Component\HttpClient\ScopingHttpClient; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @author Daniel West <[email protected]> |
||
| 27 | */ |
||
| 28 | class ApiPlatformCompilerPass implements CompilerPassInterface |
||
| 29 | { |
||
| 30 | public function process(ContainerBuilder $container): void |
||
| 31 | { |
||
| 32 | $itemsPerPageParameterName = $container->getParameter('api_platform.collection.pagination.items_per_page_parameter_name'); |
||
| 33 | |||
| 34 | $container->getDefinition(CollectionApiEventListener::class)->setArgument('$itemsPerPageParameterName', $itemsPerPageParameterName); |
||
| 35 | |||
| 36 | // Todo: revert to checking for service id api_platform.http_cache.purger when https://github.com/api-platform/core/pull/4695 is merged |
||
| 37 | if (!$container->hasDefinition('api_platform.http_cache.purger.varnish.xkey')) { |
||
| 38 | $container->removeDefinition(PurgeHttpCacheListener::class); |
||
| 39 | |||
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | // Todo: remove this - API Platform will be implementing this shortly using http client instead of guzzle |
||
| 44 | $config = $container->getExtensionConfig('api_platform'); |
||
| 45 | $apiPlatformConfig = array_merge(...$config); |
||
| 46 | $definitions = []; |
||
| 47 | foreach ($apiPlatformConfig['http_cache']['invalidation']['varnish_urls'] as $key => $url) { |
||
| 48 | $ops = $apiPlatformConfig['http_cache']['invalidation']['request_options'] ?? []; |
||
| 49 | $definition = new Definition(ScopingHttpClient::class, [new Reference('http_client'), $url, ['base_uri' => $url] + $ops]); |
||
| 50 | $definition->setFactory([ScopingHttpClient::class, 'forBaseUri']); |
||
| 51 | |||
| 52 | $definitions[] = $definition; |
||
| 53 | } |
||
| 54 | $container->findDefinition('api_platform.http_cache.purger.varnish.xkey')->setArgument('$clients', $definitions); |
||
| 55 | } |
||
| 56 | } |
||
| 57 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths