first commit
This commit is contained in:
61
vendor/symfony/http-kernel/Bundle/AbstractBundle.php
vendored
Normal file
61
vendor/symfony/http-kernel/Bundle/AbstractBundle.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
use Symfony\Component\Config\Definition\Configurator\DefinitionConfigurator;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurableExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
/**
|
||||
* A Bundle that provides configuration hooks.
|
||||
*
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*/
|
||||
abstract class AbstractBundle extends Bundle implements ConfigurableExtensionInterface
|
||||
{
|
||||
protected string $extensionAlias = '';
|
||||
|
||||
public function configure(DefinitionConfigurator $definition): void
|
||||
{
|
||||
}
|
||||
|
||||
public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
|
||||
{
|
||||
}
|
||||
|
||||
public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getContainerExtension(): ?ExtensionInterface
|
||||
{
|
||||
if ('' === $this->extensionAlias) {
|
||||
$this->extensionAlias = Container::underscore(preg_replace('/Bundle$/', '', $this->getName()));
|
||||
}
|
||||
|
||||
return $this->extension ??= new BundleExtension($this, $this->extensionAlias);
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
if (null === $this->path) {
|
||||
$reflected = new \ReflectionObject($this);
|
||||
// assume the modern directory structure by default
|
||||
$this->path = \dirname($reflected->getFileName(), 2);
|
||||
}
|
||||
|
||||
return $this->path;
|
||||
}
|
||||
}
|
160
vendor/symfony/http-kernel/Bundle/Bundle.php
vendored
Normal file
160
vendor/symfony/http-kernel/Bundle/Bundle.php
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
|
||||
/**
|
||||
* An implementation of BundleInterface that adds a few conventions for DependencyInjection extensions.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class Bundle implements BundleInterface
|
||||
{
|
||||
protected $name;
|
||||
protected $extension;
|
||||
protected $path;
|
||||
private string $namespace;
|
||||
|
||||
/**
|
||||
* @var ContainerInterface|null
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be overridden to register compilation passes,
|
||||
* other extensions, ...
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundle's container extension.
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function getContainerExtension(): ?ExtensionInterface
|
||||
{
|
||||
if (!isset($this->extension)) {
|
||||
$extension = $this->createContainerExtension();
|
||||
|
||||
if (null !== $extension) {
|
||||
if (!$extension instanceof ExtensionInterface) {
|
||||
throw new \LogicException(sprintf('Extension "%s" must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface.', get_debug_type($extension)));
|
||||
}
|
||||
|
||||
// check naming convention
|
||||
$basename = preg_replace('/Bundle$/', '', $this->getName());
|
||||
$expectedAlias = Container::underscore($basename);
|
||||
|
||||
if ($expectedAlias != $extension->getAlias()) {
|
||||
throw new \LogicException(sprintf('Users will expect the alias of the default extension of a bundle to be the underscored version of the bundle name ("%s"). You can override "Bundle::getContainerExtension()" if you want to use "%s" or another alias.', $expectedAlias, $extension->getAlias()));
|
||||
}
|
||||
|
||||
$this->extension = $extension;
|
||||
} else {
|
||||
$this->extension = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->extension ?: null;
|
||||
}
|
||||
|
||||
public function getNamespace(): string
|
||||
{
|
||||
if (!isset($this->namespace)) {
|
||||
$this->parseClassName();
|
||||
}
|
||||
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
public function getPath(): string
|
||||
{
|
||||
if (!isset($this->path)) {
|
||||
$reflected = new \ReflectionObject($this);
|
||||
$this->path = \dirname($reflected->getFileName());
|
||||
}
|
||||
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundle name (the class short name).
|
||||
*/
|
||||
final public function getName(): string
|
||||
{
|
||||
if (!isset($this->name)) {
|
||||
$this->parseClassName();
|
||||
}
|
||||
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function registerCommands(Application $application)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundle's container extension class.
|
||||
*/
|
||||
protected function getContainerExtensionClass(): string
|
||||
{
|
||||
$basename = preg_replace('/Bundle$/', '', $this->getName());
|
||||
|
||||
return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the bundle's container extension.
|
||||
*/
|
||||
protected function createContainerExtension(): ?ExtensionInterface
|
||||
{
|
||||
return class_exists($class = $this->getContainerExtensionClass()) ? new $class() : null;
|
||||
}
|
||||
|
||||
private function parseClassName(): void
|
||||
{
|
||||
$pos = strrpos(static::class, '\\');
|
||||
$this->namespace = false === $pos ? '' : substr(static::class, 0, $pos);
|
||||
$this->name ??= false === $pos ? static::class : substr(static::class, $pos + 1);
|
||||
}
|
||||
|
||||
public function setContainer(?ContainerInterface $container): void
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
67
vendor/symfony/http-kernel/Bundle/BundleExtension.php
vendored
Normal file
67
vendor/symfony/http-kernel/Bundle/BundleExtension.php
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
use Symfony\Component\Config\Definition\Configuration;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\ConfigurableExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\Extension;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionTrait;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
|
||||
/**
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class BundleExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
use ExtensionTrait;
|
||||
|
||||
public function __construct(
|
||||
private ConfigurableExtensionInterface $subject,
|
||||
private string $alias,
|
||||
) {
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
|
||||
{
|
||||
return new Configuration($this->subject, $container, $this->getAlias());
|
||||
}
|
||||
|
||||
public function getAlias(): string
|
||||
{
|
||||
return $this->alias;
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container): void
|
||||
{
|
||||
$callback = function (ContainerConfigurator $configurator) use ($container) {
|
||||
$this->subject->prependExtension($configurator, $container);
|
||||
};
|
||||
|
||||
$this->executeConfiguratorCallback($container, $callback, $this->subject);
|
||||
}
|
||||
|
||||
public function load(array $configs, ContainerBuilder $container): void
|
||||
{
|
||||
$config = $this->processConfiguration($this->getConfiguration([], $container), $configs);
|
||||
|
||||
$callback = function (ContainerConfigurator $configurator) use ($config, $container) {
|
||||
$this->subject->loadExtension($config, $configurator, $container);
|
||||
};
|
||||
|
||||
$this->executeConfiguratorCallback($container, $callback, $this->subject);
|
||||
}
|
||||
}
|
74
vendor/symfony/http-kernel/Bundle/BundleInterface.php
vendored
Normal file
74
vendor/symfony/http-kernel/Bundle/BundleInterface.php
vendored
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Bundle;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
|
||||
/**
|
||||
* BundleInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
interface BundleInterface
|
||||
{
|
||||
/**
|
||||
* Boots the Bundle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot();
|
||||
|
||||
/**
|
||||
* Shutdowns the Bundle.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function shutdown();
|
||||
|
||||
/**
|
||||
* Builds the bundle.
|
||||
*
|
||||
* It is only ever called once when the cache is empty.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function build(ContainerBuilder $container);
|
||||
|
||||
/**
|
||||
* Returns the container extension that should be implicitly loaded.
|
||||
*/
|
||||
public function getContainerExtension(): ?ExtensionInterface;
|
||||
|
||||
/**
|
||||
* Returns the bundle name (the class short name).
|
||||
*/
|
||||
public function getName(): string;
|
||||
|
||||
/**
|
||||
* Gets the Bundle namespace.
|
||||
*/
|
||||
public function getNamespace(): string;
|
||||
|
||||
/**
|
||||
* Gets the Bundle directory path.
|
||||
*
|
||||
* The path should always be returned as a Unix path (with /).
|
||||
*/
|
||||
public function getPath(): string;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function setContainer(?ContainerInterface $container);
|
||||
}
|
Reference in New Issue
Block a user