Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions config/definition.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php

declare(strict_types=1);

namespace Symfony\Component\Config\Definition\Configurator;

use Doctrine\ORM\Events as DoctrineEvents;
use Sofascore\PurgatoryBundle\Purger\PurgerInterface;
use Symfony\Component\HttpClient\HttpClient;
use Symfony\Component\Messenger\MessageBusInterface;

return static function (DefinitionConfigurator $definition): void {
$rootNode = $definition->rootNode();

$rootNode
->fixXmlConfig('mapping_path')
->fixXmlConfig('route_ignore_pattern')
->children()
->arrayNode('mapping_paths')
->info('List of files or directories where Purgatory will look for additional purge definitions.')
->scalarPrototype()->end()
->defaultValue([])
->end()
->arrayNode('route_ignore_patterns')
->info('Route names that match the given regular expressions will be ignored.')
->example(['/^_profiler/', '/^_wdt/'])
->scalarPrototype()->end()
->defaultValue([])
->end()
->arrayNode('doctrine_middleware')
->canBeDisabled()
->children()
->integerNode('priority')
->info('Explicitly set the priority of Purgatory\'s Doctrine middleware.')
->defaultNull()
->end()
->end()
->end()
->arrayNode('doctrine_event_listener_priorities')
->info('Explicitly set the priorities of Purgatory\'s Doctrine event listener.')
->beforeNormalization()
->ifTrue(static fn (mixed $priority): bool => \is_int($priority))
->then(static fn (int $priority): array => [
DoctrineEvents::preRemove => $priority,
DoctrineEvents::postPersist => $priority,
DoctrineEvents::postUpdate => $priority,
DoctrineEvents::postFlush => $priority,
])
->end()
->addDefaultsIfNotSet()
->children()
->integerNode(DoctrineEvents::preRemove)->defaultNull()->end()
->integerNode(DoctrineEvents::postPersist)->defaultNull()->end()
->integerNode(DoctrineEvents::postUpdate)->defaultNull()->end()
->integerNode(DoctrineEvents::postFlush)
->info('This event is not registered when the Doctrine middleware is enabled.')
->defaultNull()
->end()
->end()
->end()
->arrayNode('purger')
->fixXmlConfig('host')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(static fn (string $purger): array => ['name' => $purger])
->end()
->validate()
->ifTrue(static fn (array $purger): bool => 'varnish' === $purger['name'] && !class_exists(HttpClient::class))
->thenInvalid('The Varnish purger requires Symfony\'s HTTP client component to be installed. Try running "composer require symfony/http-client".')
->end()
->children()
->scalarNode('name')
->info(\sprintf('The ID of a service that implements the "%s" interface', PurgerInterface::class))
->example('symfony')
->defaultNull()
->end()
->arrayNode('hosts')
->info('The hosts from which URLs should be purged')
->scalarPrototype()
->validate()->always(static fn (string $host): string => rtrim($host, '/'))->end()
->end()
->defaultValue([])
->end()
->scalarNode('http_client')
->info('The service ID of the HTTP client to use, must be an instance of Symfony\'s HTTP client')
->defaultNull()
->cannotBeEmpty()
->end()
->end()
->end()
->arrayNode('messenger')
->addDefaultsIfNotSet()
->beforeNormalization()
->ifString()
->then(static fn (string $messenger): array => ['transport' => $messenger])
->end()
->validate()
->ifTrue(static fn (array $messenger): bool => !interface_exists(MessageBusInterface::class) && array_filter($messenger))
->thenInvalid('Messenger support cannot be enabled as the component is not installed. Try running "composer require symfony/messenger".')
->end()
->validate()
->ifTrue(static fn (array $messenger): bool => !$messenger['transport'] && $messenger['bus'])
->thenInvalid('Cannot set the messenger bus without defining the transport.')
->end()
->validate()
->ifTrue(static fn (array $messenger): bool => !$messenger['transport'] && $messenger['batch_size'])
->thenInvalid('Cannot set the batch size without defining the transport.')
->end()
->children()
->scalarNode('transport')
->info('Set the name of the messenger transport to use')
->defaultNull()
->cannotBeEmpty()
->end()
->scalarNode('bus')
->info('Set the name of the messenger bus to use')
->defaultNull()
->cannotBeEmpty()
->end()
->integerNode('batch_size')
->info('Set the number of urls to dispatch per message')
->defaultNull()
->validate()
->ifTrue(static fn (int $batchSize): bool => !($batchSize > 0))
->thenInvalid('The batch size must be a number greater than 0.')
->end()
->end()
->end()
->end()
->booleanNode('profiler_integration')
->info('Enables the data collector and profiler panel if the profiler is enabled.')
->defaultTrue()
->end()
->end()
;
};
12 changes: 9 additions & 3 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,29 @@ parameters:
count: 1
path: src/Cache/RouteMetadata/YamlMetadataProvider.php

-
message: '#^Comparison operation "\<" between 80101 and 80100 is always false\.$#'
identifier: smaller.alwaysFalse
count: 1
path: src/PurgatoryBundle.php

-
message: '#^Parameter \#2 \$configurator of method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:registerAttributeForAutoconfiguration\(\) expects callable\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\AsExpressionLanguageFunction, Reflector\)\: void, Closure\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\AsExpressionLanguageFunction, ReflectionClass\|ReflectionMethod\)\: void given\.$#'
identifier: argument.type
count: 1
path: src/DependencyInjection/PurgatoryExtension.php
path: src/PurgatoryBundle.php

-
message: '#^Parameter \#2 \$configurator of method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:registerAttributeForAutoconfiguration\(\) expects callable\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\AsRouteParamService, Reflector\)\: void, Closure\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\AsRouteParamService, ReflectionClass\|ReflectionMethod\)\: void given\.$#'
identifier: argument.type
count: 1
path: src/DependencyInjection/PurgatoryExtension.php
path: src/PurgatoryBundle.php

-
message: '#^Parameter \#2 \$configurator of method Symfony\\Component\\DependencyInjection\\ContainerBuilder\:\:registerAttributeForAutoconfiguration\(\) expects callable\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\PurgeOn, Reflector\)\: void, Closure\(Symfony\\Component\\DependencyInjection\\ChildDefinition, Sofascore\\PurgatoryBundle\\Attribute\\PurgeOn, ReflectionClass\|ReflectionMethod\)\: void given\.$#'
identifier: argument.type
count: 1
path: src/DependencyInjection/PurgatoryExtension.php
path: src/PurgatoryBundle.php

-
message: '#^Trait Sofascore\\PurgatoryBundle\\Test\\InteractsWithPurgatory is used zero times and is not analysed\.$#'
Expand Down
1 change: 0 additions & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ parameters:
paths:
- src
excludePaths:
- src/DependencyInjection/Configuration.php
- src/Doctrine/DBAL/PurgatoryConnection.php
58 changes: 58 additions & 0 deletions src/DependencyInjection/BundleExtensionWrapper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);

namespace Sofascore\PurgatoryBundle\DependencyInjection;

use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\ConfigurationExtensionInterface;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;

/**
* @internal
*
* @see https://github.com/symfony/symfony/pull/64955
*/
final class BundleExtensionWrapper extends Extension implements PrependExtensionInterface
{
public function __construct(
private readonly ExtensionInterface&ConfigurationExtensionInterface&PrependExtensionInterface $extension,
) {
}

/**
* @param array<array-key, mixed> $config
*/
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
{
return $this->extension->getConfiguration($config, $container);
}

public function getAlias(): string
{
return $this->extension->getAlias();
}

public function prepend(ContainerBuilder $container): void
{
$this->extension->prepend($container);
}

public function load(array $configs, ContainerBuilder $container): void
{
$this->extension->load($configs, $container);
}

public function getNamespace(): string
{
return 'http://sofascore.com/schema/dic/purgatory';
}

public function getXsdValidationBasePath(): string
{
return \dirname(__DIR__, 2).'/config/schema';
}
}
146 changes: 0 additions & 146 deletions src/DependencyInjection/Configuration.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Sofascore\PurgatoryBundle\DependencyInjection\CompilerPass;
namespace Sofascore\PurgatoryBundle\DependencyInjection;

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

final class ControllerClassMapPass implements CompilerPassInterface
final class ControllerClassMapCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
Expand Down
Loading