Skip to content

Commit

Permalink
Add compiler pass for Symfony Clock with Symfony 5
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Nov 18, 2024
1 parent e8b1a3e commit 24f4ef0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/DependencyInjection/Compiler/SymfonyClockCompilerPass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\InvoicingPlugin\DependencyInjection\Compiler;

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

final class SymfonyClockCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container): void
{
if ($container->hasParameter('clock')) {
return;
}

$container->setDefinition('clock', new Definition(Clock::class));
}
}
11 changes: 11 additions & 0 deletions src/SyliusInvoicingPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,20 @@
namespace Sylius\InvoicingPlugin;

use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
use Sylius\InvoicingPlugin\DependencyInjection\Compiler\SymfonyClockCompilerPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;


/** @internal */
final class SyliusInvoicingPlugin extends Bundle
{
use SyliusPluginTrait;

public function build(ContainerBuilder $container): void
{
parent::build($container);

$container->addCompilerPass(new SymfonyClockCompilerPass());
}
}

0 comments on commit 24f4ef0

Please sign in to comment.