Chris@0: proxyBuilder = $proxy_builder; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: protected function configure() { Chris@0: $this->setName('generate-proxy-class') Chris@0: ->setDefinition([ Chris@0: new InputArgument('class_name', InputArgument::REQUIRED, 'The class to be proxied'), Chris@0: new InputArgument('namespace_root_path', InputArgument::REQUIRED, 'The filepath to the root of the namespace.'), Chris@0: ]) Chris@0: ->setDescription('Dumps a generated proxy class into its appropriate namespace.') Chris@0: ->addUsage('\'Drupal\Core\Batch\BatchStorage\' "core/lib/Drupal/Core"') Chris@0: ->addUsage('\'Drupal\block\BlockRepository\' "core/modules/block/src"') Chris@0: ->addUsage('\'Drupal\mymodule\MyClass\' "modules/contrib/mymodule/src"'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: protected function execute(InputInterface $input, OutputInterface $output) { Chris@0: $class_name = ltrim($input->getArgument('class_name'), '\\'); Chris@0: $namespace_root = $input->getArgument('namespace_root_path'); Chris@0: Chris@0: $match = []; Chris@0: preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match); Chris@0: Chris@0: if ($match) { Chris@0: $root_namespace = $match[1]; Chris@0: $rest_fqcn = $match[2]; Chris@0: Chris@0: $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php'; Chris@0: $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn; Chris@0: Chris@0: $proxy_class_string = $this->proxyBuilder->build($class_name); Chris@0: Chris@0: $file_string = <<writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename)); Chris@0: } Chris@0: Chris@0: } Chris@0: Chris@0: }