<?php

declare(strict_types=1);

use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;

if (!defined('_PS_VERSION_') || Tools::version_compare(_PS_VERSION_, '8.0.0')) {
    return;
}

assert(isset($container) && $container instanceof ContainerBuilder);

$container->removeDefinition('gls_poland.event_subscriber_locator');
$container
    ->getDefinition('gls_poland.event_dispatcher')
    ->setArgument(0, new ServiceLocatorArgument(new TaggedIteratorArgument('gls_poland.event_subscriber', null, null, true)));
