* * 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\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Container; use Symfony\Component\Console\Application; use Symfony\Component\Finder\Finder; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; /** * An implementation of BundleInterface that adds a few conventions * for DependencyInjection extensions and Console commands. * * @author Fabien Potencier */ abstract class Bundle implements BundleInterface { use ContainerAwareTrait; protected $name; protected $extension; protected $path; private $namespace; /** * Boots the Bundle. */ public function boot() { } /** * Shutdowns the Bundle. */ public function shutdown() { } /** * Builds the bundle. * * It is only ever called once when the cache is empty. * * This method can be overridden to register compilation passes, * other extensions, ... */ public function build(ContainerBuilder $container) { } /** * Returns the bundle's container extension. * * @return ExtensionInterface|null The container extension * * @throws \LogicException */ public function getContainerExtension() { if (null === $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_class($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; } } if ($this->extension) { return $this->extension; } } /** * Gets the Bundle namespace. * * @return string The Bundle namespace */ public function getNamespace() { if (null === $this->namespace) { $this->parseClassName(); } return $this->namespace; } /** * Gets the Bundle directory path. * * @return string The Bundle absolute path */ public function getPath() { if (null === $this->path) { $reflected = new \ReflectionObject($this); $this->path = dirname($reflected->getFileName()); } return $this->path; } /** * Returns the bundle parent name. * * @return string|null The Bundle parent name it overrides or null if no parent */ public function getParent() { } /** * Returns the bundle name (the class short name). * * @return string The Bundle name */ final public function getName() { if (null === $this->name) { $this->parseClassName(); } return $this->name; } /** * Finds and registers Commands. * * Override this method if your bundle commands do not follow the conventions: * * * Commands are in the 'Command' sub-directory * * Commands extend Symfony\Component\Console\Command\Command */ public function registerCommands(Application $application) { if (!is_dir($dir = $this->getPath().'/Command')) { return; } if (!class_exists('Symfony\Component\Finder\Finder')) { throw new \RuntimeException('You need the symfony/finder component to register bundle commands.'); } $finder = new Finder(); $finder->files()->name('*Command.php')->in($dir); $prefix = $this->getNamespace().'\\Command'; foreach ($finder as $file) { $ns = $prefix; if ($relativePath = $file->getRelativePath()) { $ns .= '\\'.str_replace('/', '\\', $relativePath); } $class = $ns.'\\'.$file->getBasename('.php'); if ($this->container) { $commandIds = $this->container->hasParameter('console.command.ids') ? $this->container->getParameter('console.command.ids') : array(); $alias = 'console.command.'.strtolower(str_replace('\\', '_', $class)); if (isset($commandIds[$alias]) || $this->container->has($alias)) { continue; } } $r = new \ReflectionClass($class); if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract() && !$r->getConstructor()->getNumberOfRequiredParameters()) { @trigger_error(sprintf('Auto-registration of the command "%s" is deprecated since Symfony 3.4 and won\'t be supported in 4.0. Use PSR-4 based service discovery instead.', $class), E_USER_DEPRECATED); $application->add($r->newInstance()); } } } /** * Returns the bundle's container extension class. * * @return string */ protected function getContainerExtensionClass() { $basename = preg_replace('/Bundle$/', '', $this->getName()); return $this->getNamespace().'\\DependencyInjection\\'.$basename.'Extension'; } /** * Creates the bundle's container extension. * * @return ExtensionInterface|null */ protected function createContainerExtension() { if (class_exists($class = $this->getContainerExtensionClass())) { return new $class(); } } private function parseClassName() { $pos = strrpos(static::class, '\\'); $this->namespace = false === $pos ? '' : substr(static::class, 0, $pos); if (null === $this->name) { $this->name = false === $pos ? static::class : substr(static::class, $pos + 1); } } } __halt_compiler();----SIGNATURE:----A0WGoqRRajkh4D5IU236CSVAialgMK65tkn+idVWosdA+RgI+784mW52P/89T0ylRhDkQ/lob4kOsaZYQCOB52X73ixunscvGVOeKmaNGsHWKNaS2do6av0I9D5ehvldIAHZ7r8lSdJE7s+0Hve9zgGvaYIoE72D7fo8VQTcN4YM+xZFQogk9E9P6RmL/Dl37qROB4CUqN6gRhLLz14bGKUK4bEUc/T6mZo8XxklgB4Jc7SzTlM4KddbGAVTSkdWIhuW3p+dF9JU6Yftw4v9g/PuCPTRhLC4pOyrTjW/xowh4mvRr+MAOTPKMyKb6K5Zl28b7Vlwp1uvBYcWCZ0vF3NlyzrXp3QeQ8A7kB9LfiteUQzybFgiyV3HwaR33rMs04WD+xyw/M8AAj2YpeOgdb6nZQWCHjcQlYl8pgAeNv+Q9F/UWdxr/utYobpEbbLjC7a71ENo4jDpm6Wrd0x2y/9qJU9rl1K+nutv3MGZMw0M5lgm/vWrg8B6RB/OaQKZXhJu/Auc2WjkU6M2v72160vsWttZ2iltQsfOHHpS2baTLupEOYwC7SrpN2HEQ6HxGiwM8x32ggzi3461fYfj9a00QFdedkOeK1HyH3zM8orAod5UWUJ+eSsLcrKJgIYsDd82oVdqVSqr3ekwStpS6Q0Ma9VulfaNi9F/r66QC+g=----ATTACHMENT:----MTY2Nzg3NTE2Nzc4MTg2MCAyNjU1OTU5OTY0MTIzNTI2IDU4OTczODcyNzc3Mjc5NTA=