diff --git a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php index 71863c8..0d9fa46 100644 --- a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php +++ b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php @@ -23,7 +23,7 @@ class ProxyBuilder { */ public static function buildProxyClassName($class_name) { $match = []; - preg_match('/([a-zA-Z0-9]+\\\\[a-zA-Z0-9]+)\\\\(.+)/', $class_name, $match); + preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match); $root_namespace = $match[1]; $rest_fqcn = $match[2]; $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn; diff --git a/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php b/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php index c453eb4..0ad9eb0 100644 --- a/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php +++ b/core/lib/Drupal/Core/Command/GenerateProxyClassApplication.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Command; use Drupal\Component\ProxyBuilder\ProxyBuilder; -use Drupal\Core\File\FileSystemInterface; use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputInterface; @@ -25,28 +24,17 @@ class GenerateProxyClassApplication extends Application { protected $proxyBuilder; /** - * The file system. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** * Constructs a new GenerateProxyClassApplication instance. * * @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder * The proxy builder. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The file system. */ - public function __construct(ProxyBuilder $proxy_builder, FileSystemInterface $file_system) { + public function __construct(ProxyBuilder $proxy_builder) { $this->proxyBuilder = $proxy_builder; - $this->fileSystem = $file_system; parent::__construct(); } - /** * {@inheritdoc} */ @@ -60,7 +48,7 @@ protected function getCommandName(InputInterface $input) { protected function getDefaultCommands() { // Even though this is a single command, keep the HelpCommand (--help). $default_commands = parent::getDefaultCommands(); - $default_commands[] = new GenerateProxyClassCommand($this->proxyBuilder, $this->fileSystem); + $default_commands[] = new GenerateProxyClassCommand($this->proxyBuilder); return $default_commands; } diff --git a/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php index 90b39c8..9ee0a32 100644 --- a/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php +++ b/core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Command; use Drupal\Component\ProxyBuilder\ProxyBuilder; -use Drupal\Core\File\FileSystemInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -27,25 +26,15 @@ class GenerateProxyClassCommand extends Command { protected $proxyBuilder; /** - * The file system. - * - * @var \Drupal\Core\File\FileSystemInterface - */ - protected $fileSystem; - - /** * Constructs a new GenerateProxyClassCommand instance. * * @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder * The proxy builder. - * @param \Drupal\Core\File\FileSystemInterface $file_system - * The file system. */ - public function __construct(ProxyBuilder $proxy_builder, FileSystemInterface $file_system) { + public function __construct(ProxyBuilder $proxy_builder) { parent::__construct(); $this->proxyBuilder = $proxy_builder; - $this->fileSystem = $file_system; } /** @@ -68,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $namespace_root = $input->getArgument('namespace_root'); $match = []; - preg_match('/([a-zA-Z0-9]+\\\\[a-zA-Z0-9]+)\\\\(.+)/', $class_name, $match); + preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match); if ($match) { $root_namespace = $match[1]; @@ -94,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { EOS; $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string); - $this->fileSystem->mkdir(dirname($proxy_filename), NULL, TRUE); + mkdir(dirname($proxy_filename), 0775, TRUE); file_put_contents($proxy_filename, $file_string); $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename)); diff --git a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php index 83a7845..cc1e409 100644 --- a/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php +++ b/core/lib/Drupal/Core/Installer/InstallerServiceProvider.php @@ -58,7 +58,10 @@ public function register(ContainerBuilder $container) { // Replace the route builder with an empty implementation. // @todo Convert installer steps into routes; add an installer.routing.yml. $definition = $container->getDefinition('router.builder'); - $definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder'); + $definition->setClass('Drupal\Core\Installer\InstallerRouteBuilder') + // The core router builder, but there is no reason here to be lazy, so + // we don't need to ship with a custom proxy class. + ->setLazy(FALSE); } /** diff --git a/core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php b/core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php new file mode 100644 index 0000000..36a9993 --- /dev/null +++ b/core/modules/views_ui/src/ProxyClass/ParamConverter/ViewUIConverter.php @@ -0,0 +1,68 @@ +container = $container; + $this->serviceId = $serviceId; + } + + protected function lazyLoadItself() + { + if (!isset($this->service)) { + $this->service = $this->container->get($this->serviceId); + } + + return $this->service; + } + + public function convert($value, $definition, $name, array $defaults) + { + return $this->lazyLoadItself()->convert($value, $definition, $name, $defaults); + } + + public function applies($definition, $name, \Symfony\Component\Routing\Route $route) + { + return $this->lazyLoadItself()->applies($definition, $name, $route); + } + + } + +} diff --git a/core/scripts/generate-proxy-class.php b/core/scripts/generate-proxy-class.php index 764f092..d5f0e43 100644 --- a/core/scripts/generate-proxy-class.php +++ b/core/scripts/generate-proxy-class.php @@ -19,5 +19,5 @@ $kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot(); // Run the database dump command. -$application = new GenerateProxyClassApplication(new ProxyBuilder(), \Drupal::service('file_system')); +$application = new GenerateProxyClassApplication(new ProxyBuilder()); $application->run(); diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php index d04227e..fa9128e 100644 --- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php +++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php @@ -41,6 +41,14 @@ public function testBuildProxyClassName() { } /** + * @covers ::buildProxyClassName + */ + public function testBuildProxyClassNameForModule() { + $class_name = $this->proxyBuilder->buildProxyClassName('Drupal\views_ui\ParamConverter\ViewUIConverter'); + $this->assertEquals('Drupal\views_ui\ProxyClass\ParamConverter\ViewUIConverter', $class_name); + } + + /** * @covers ::buildProxyNamespace */ public function testBuildProxyNamespace() {