Skip to content

Commit

Permalink
Replace TaggedIterator with AutowireIterator across multiple files
Browse files Browse the repository at this point in the history
The commit switches the usage from TaggedIterator to AutowireIterator to better manage dependencies within the application. This affects multiple classes in src directory involving spomky_labs_pwa cache strategy, match callback handlers, and other related dependencies. The change enhances dependency handling and supports cleaner code injection.
  • Loading branch information
Spomky committed Jul 12, 2024
1 parent 65c2a87 commit cbeedc9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/CachingStrategy/BackgroundSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use SpomkyLabs\PwaBundle\MatchCallbackHandler\MatchCallbackHandlerInterface;
use SpomkyLabs\PwaBundle\Service\CanLogInterface;
use SpomkyLabs\PwaBundle\WorkboxPlugin\BackgroundSyncPlugin;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;

final class BackgroundSync implements HasCacheStrategiesInterface, CanLogInterface
{
Expand All @@ -24,7 +24,7 @@ final class BackgroundSync implements HasCacheStrategiesInterface, CanLogInterfa
*/
public function __construct(
ServiceWorker $serviceWorker,
#[TaggedIterator('spomky_labs_pwa.match_callback_handler')]
#[AutowireIterator('spomky_labs_pwa.match_callback_handler')]
private readonly iterable $matchCallbackHandlers,
) {
$this->workbox = $serviceWorker->workbox;
Expand Down
4 changes: 2 additions & 2 deletions src/CachingStrategy/PreloadUrlsGeneratorManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use SpomkyLabs\PwaBundle\Service\CanLogInterface;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use function array_key_exists;

final class PreloadUrlsGeneratorManager implements CanLogInterface
Expand All @@ -24,7 +24,7 @@ final class PreloadUrlsGeneratorManager implements CanLogInterface
* @param PreloadUrlsGeneratorInterface[] $generators
*/
public function __construct(
#[TaggedIterator('spomky_labs_pwa.preload_urls_generator')]
#[AutowireIterator('spomky_labs_pwa.preload_urls_generator')]
iterable $generators
) {
$this->logger = new NullLogger();
Expand Down
4 changes: 2 additions & 2 deletions src/CachingStrategy/ResourceCaches.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use SpomkyLabs\PwaBundle\WorkboxPlugin\ExpirationPlugin;
use SpomkyLabs\PwaBundle\WorkboxPlugin\RangeRequestsPlugin;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Symfony\Component\Serializer\Encoder\JsonEncode;
use Symfony\Component\Serializer\SerializerInterface;
use function count;
Expand All @@ -40,7 +40,7 @@ public function __construct(
private readonly PreloadUrlsGeneratorManager $preloadUrlsGeneratorManager,
ServiceWorker $serviceWorker,
private readonly SerializerInterface $serializer,
#[TaggedIterator('spomky_labs_pwa.match_callback_handler')]
#[AutowireIterator('spomky_labs_pwa.match_callback_handler')]
private readonly iterable $matchCallbackHandlers,
#[Autowire('%kernel.debug%')]
bool $debug,
Expand Down
4 changes: 2 additions & 2 deletions src/Command/ListCacheStrategiesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Symfony\Component\Yaml\Yaml;
use function count;

Expand All @@ -25,7 +25,7 @@ final class ListCacheStrategiesCommand extends Command
* @param iterable<HasCacheStrategiesInterface> $services
*/
public function __construct(
#[TaggedIterator('spomky_labs_pwa.cache_strategy')]
#[AutowireIterator('spomky_labs_pwa.cache_strategy')]
private readonly iterable $services,
) {
parent::__construct();
Expand Down
4 changes: 2 additions & 2 deletions src/DataCollector/PwaCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use SpomkyLabs\PwaBundle\Service\FaviconsCompiler;
use SpomkyLabs\PwaBundle\Service\ManifestCompiler;
use SpomkyLabs\PwaBundle\Service\ServiceWorkerCompiler;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
Expand All @@ -37,7 +37,7 @@ final class PwaCollector extends DataCollector
*/
public function __construct(
private readonly SerializerInterface $serializer,
#[TaggedIterator('spomky_labs_pwa.cache_strategy')]
#[AutowireIterator('spomky_labs_pwa.cache_strategy')]
private readonly iterable $cachingServices,
private readonly Manifest $manifest,
private readonly ServiceWorker $serviceWorker,
Expand Down
4 changes: 2 additions & 2 deletions src/Service/ServiceWorkerCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symfony\Component\AssetMapper\AssetMapperInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use function assert;
use function count;
use function in_array;
Expand All @@ -34,7 +34,7 @@ final class ServiceWorkerCompiler implements FileCompilerInterface, CanLogInterf
public function __construct(
private readonly ServiceWorker $serviceWorker,
private readonly AssetMapperInterface $assetMapper,
#[TaggedIterator('spomky_labs_pwa.service_worker_rule', defaultPriorityMethod: 'getPriority')]
#[AutowireIterator('spomky_labs_pwa.service_worker_rule', defaultPriorityMethod: 'getPriority')]
private readonly iterable $serviceworkerRules,
#[Autowire('%kernel.debug%')]
public readonly bool $debug,
Expand Down
4 changes: 2 additions & 2 deletions src/ServiceWorkerRule/AppendCacheStrategies.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use SpomkyLabs\PwaBundle\CachingStrategy\HasCacheStrategiesInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use const PHP_EOL;

final readonly class AppendCacheStrategies implements ServiceWorkerRuleInterface
Expand All @@ -15,7 +15,7 @@
* @param iterable<HasCacheStrategiesInterface> $cacheStrategies
*/
public function __construct(
#[TaggedIterator('spomky_labs_pwa.cache_strategy')]
#[AutowireIterator('spomky_labs_pwa.cache_strategy')]
private iterable $cacheStrategies,
#[Autowire('%kernel.debug%')]
public bool $debug,
Expand Down
4 changes: 2 additions & 2 deletions src/Subscriber/FileCompileEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Symfony\Component\AssetMapper\Event\PreAssetsCompileEvent;
use Symfony\Component\AssetMapper\Path\PublicAssetsFilesystemInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;

#[AsEventListener(PreAssetsCompileEvent::class)]
Expand All @@ -23,7 +23,7 @@ final class FileCompileEventListener implements CanLogInterface
* @param iterable<FileCompilerInterface> $fileCompilers
*/
public function __construct(
#[TaggedIterator('spomky_labs_pwa.compiler')]
#[AutowireIterator('spomky_labs_pwa.compiler')]
private readonly iterable $fileCompilers,
#[Autowire('@asset_mapper.local_public_assets_filesystem')]
private readonly PublicAssetsFilesystemInterface $assetsFilesystem,
Expand Down
4 changes: 2 additions & 2 deletions src/Subscriber/PwaDevServerSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use SpomkyLabs\PwaBundle\Service\CanLogInterface;
use SpomkyLabs\PwaBundle\Service\Data;
use SpomkyLabs\PwaBundle\Service\FileCompilerInterface;
use Symfony\Component\DependencyInjection\Attribute\TaggedIterator;
use Symfony\Component\DependencyInjection\Attribute\AutowireIterator;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\RequestEvent;
Expand All @@ -25,7 +25,7 @@ final class PwaDevServerSubscriber implements EventSubscriberInterface, CanLogIn
* @param iterable<FileCompilerInterface> $fileCompilers
*/
public function __construct(
#[TaggedIterator('spomky_labs_pwa.compiler')]
#[AutowireIterator('spomky_labs_pwa.compiler')]
private readonly iterable $fileCompilers,
private readonly null|Profiler $profiler,
) {
Expand Down

0 comments on commit cbeedc9

Please sign in to comment.