-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from pug-php/feature/symfony-6
Upgrade to Symfony 6
- Loading branch information
Showing
34 changed files
with
1,021 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pug\Exceptions; | ||
|
||
use RuntimeException; | ||
|
23 changes: 10 additions & 13 deletions
23
src/Pug/PugSymfonyBundle/Command/AssetsPublishCommand.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pug\PugSymfonyBundle; | ||
|
||
use Symfony\Component\Config\FileLocator; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; | ||
use Symfony\Component\HttpKernel\DependencyInjection\Extension; | ||
|
||
/** | ||
* TwigExtension. | ||
* | ||
* @author Fabien Potencier <[email protected]> | ||
* @author Jeremy Mikola <[email protected]> | ||
*/ | ||
class PugExtension extends Extension | ||
{ | ||
public function load(array $configs, ContainerBuilder $container) | ||
{ | ||
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/config')); | ||
$loader->load('pug.php'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pug\PugSymfonyBundle; | ||
|
||
use Pug\PugSymfonyBundle\Command\AssetsPublishCommand; | ||
use Pug\PugSymfonyEngine; | ||
use Pug\Symfony\Traits\PrivatePropertyAccessor; | ||
use ReflectionException; | ||
use ReflectionMethod; | ||
use ReflectionProperty; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
||
class PugSymfonyBundle extends Bundle | ||
{ | ||
use PrivatePropertyAccessor; | ||
|
||
/** | ||
* @param ContainerInterface|null $container | ||
* | ||
* @throws ReflectionException | ||
*/ | ||
public function setContainer(ContainerInterface $container = null) | ||
public function build(ContainerBuilder $containerBuilder): void | ||
{ | ||
$this->container = $container; | ||
|
||
if ($container) { | ||
/** @var KernelInterface $kernel */ | ||
$kernel = $container->get('kernel'); | ||
$engine = new PugSymfonyEngine($kernel); | ||
/** @var ReflectionProperty $propertyAccessor */ | ||
$services = static::getPrivateProperty($container, 'services', $propertyAccessor); | ||
$services[PugSymfonyEngine::class] = $engine; | ||
$propertyAccessor->setValue($container, $services); | ||
} | ||
$extension = new PugExtension(); | ||
$containerBuilder->registerExtension($extension); | ||
$containerBuilder->loadFromExtension($extension->getAlias()); | ||
} | ||
|
||
public function registerCommands(Application $application) | ||
{ | ||
$method = new ReflectionMethod(AssetsPublishCommand::class, '__construct'); | ||
$class = $method->getNumberOfParameters() === 1 ? $method->getParameters()[0]->getClass() : null; | ||
|
||
if ($class && $class->getName() === PugSymfonyEngine::class) { | ||
/** @var PugSymfonyEngine $engine */ | ||
$engine = $this->container->get(PugSymfonyEngine::class); | ||
|
||
$application->addCommands([ | ||
new AssetsPublishCommand($engine), | ||
]); | ||
} | ||
$application->addCommands([ | ||
$this->container->get(AssetsPublishCommand::class), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
return static function (ContainerConfigurator $configurator): void { | ||
$services = $configurator->services() | ||
->defaults() | ||
->autowire() | ||
->autoconfigure(); | ||
|
||
$services->load('Pug\\', __DIR__.'/../../*') | ||
->exclude([ | ||
__DIR__.'/../../Exceptions', | ||
__DIR__.'/../../PugSymfonyBundle', | ||
__DIR__.'/../../Symfony', | ||
__DIR__.'/../../Twig', | ||
]); | ||
|
||
$services->load('Pug\\PugSymfonyBundle\\Command\\', __DIR__.'/../../PugSymfonyBundle/Command/*') | ||
->public(); | ||
}; |
Oops, something went wrong.