Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -220,6 +220,9 @@ class DbDumpCommand extends Command {
|
|||
// Set primary key, unique keys, and indexes.
|
||||
$this->getTableIndexes($table, $definition);
|
||||
|
||||
// Set table collation.
|
||||
$this->getTableCollation($table, $definition);
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
|
@ -235,7 +238,6 @@ class DbDumpCommand extends Command {
|
|||
// Note, this query doesn't support ordering, so that is worked around
|
||||
// below by keying the array on Seq_in_index.
|
||||
$query = $this->connection->query("SHOW INDEX FROM {" . $table . "}");
|
||||
$indexes = [];
|
||||
while (($row = $query->fetchAssoc()) !== FALSE) {
|
||||
$index_name = $row['Key_name'];
|
||||
$column = $row['Column_name'];
|
||||
|
@ -259,6 +261,22 @@ class DbDumpCommand extends Command {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the table collation.
|
||||
*
|
||||
* @param string $table
|
||||
* The table to find indexes for.
|
||||
* @param array &$definition
|
||||
* The schema definition to modify.
|
||||
*/
|
||||
protected function getTableCollation($table, &$definition) {
|
||||
$query = $this->connection->query("SHOW TABLE STATUS LIKE '{" . $table . "}'");
|
||||
$data = $query->fetchAssoc();
|
||||
|
||||
// Set `mysql_character_set`. This will be ignored by other backends.
|
||||
$definition['mysql_character_set'] = str_replace('_general_ci', '', $data['Collation']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all data from a given table.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Command\GenerateProxyClassApplication.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Command;
|
||||
|
||||
use Drupal\Component\ProxyBuilder\ProxyBuilder;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
|
||||
/**
|
||||
* Provides a console command to generate proxy classes.
|
||||
*/
|
||||
class GenerateProxyClassApplication extends Application {
|
||||
|
||||
/**
|
||||
* The proxy builder.
|
||||
*
|
||||
* @var \Drupal\Component\ProxyBuilder\ProxyBuilder
|
||||
*/
|
||||
protected $proxyBuilder;
|
||||
|
||||
/**
|
||||
* Constructs a new GenerateProxyClassApplication instance.
|
||||
*
|
||||
* @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder
|
||||
* The proxy builder.
|
||||
*/
|
||||
public function __construct(ProxyBuilder $proxy_builder) {
|
||||
$this->proxyBuilder = $proxy_builder;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getCommandName(InputInterface $input) {
|
||||
return 'generate-proxy-class';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultCommands() {
|
||||
// Even though this is a single command, keep the HelpCommand (--help).
|
||||
$default_commands = parent::getDefaultCommands();
|
||||
$default_commands[] = new GenerateProxyClassCommand($this->proxyBuilder);
|
||||
return $default_commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Overridden so the application doesn't expect the command name as the first
|
||||
* argument.
|
||||
*/
|
||||
public function getDefinition() {
|
||||
$definition = parent::getDefinition();
|
||||
// Clears the normal first argument (the command name).
|
||||
$definition->setArguments();
|
||||
return $definition;
|
||||
}
|
||||
|
||||
}
|
97
core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php
Normal file
97
core/lib/Drupal/Core/Command/GenerateProxyClassCommand.php
Normal file
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Core\Command\GenerateProxyClassCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\Core\Command;
|
||||
|
||||
use Drupal\Component\ProxyBuilder\ProxyBuilder;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
* Provides a console command to generate proxy classes.
|
||||
*/
|
||||
class GenerateProxyClassCommand extends Command {
|
||||
|
||||
/**
|
||||
* The proxy builder.
|
||||
*
|
||||
* @var \Drupal\Component\ProxyBuilder\ProxyBuilder
|
||||
*/
|
||||
protected $proxyBuilder;
|
||||
|
||||
/**
|
||||
* Constructs a new GenerateProxyClassCommand instance.
|
||||
*
|
||||
* @param \Drupal\Component\ProxyBuilder\ProxyBuilder $proxy_builder
|
||||
* The proxy builder.
|
||||
*/
|
||||
public function __construct(ProxyBuilder $proxy_builder) {
|
||||
parent::__construct();
|
||||
|
||||
$this->proxyBuilder = $proxy_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure() {
|
||||
$this->setName('generate-proxy-class')
|
||||
->setDefinition([
|
||||
new InputArgument('class_name', InputArgument::REQUIRED, 'The class to be proxied'),
|
||||
new InputArgument('namespace_root_path', InputArgument::REQUIRED, 'The filepath to the root of the namespace.'),
|
||||
])
|
||||
->setDescription('Dumps a generated proxy class into its appropriate namespace.')
|
||||
->addUsage('\'Drupal\Core\Batch\BatchStorage\' "core/lib/Drupal/Core"')
|
||||
->addUsage('\'Drupal\block\BlockRepository\' "core/modules/block/src"')
|
||||
->addUsage('\'Drupal\mymodule\MyClass\' "modules/contrib/mymodule/src"');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$class_name = ltrim($input->getArgument('class_name'), '\\');
|
||||
$namespace_root = $input->getArgument('namespace_root_path');
|
||||
|
||||
$match = [];
|
||||
preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
|
||||
|
||||
if ($match) {
|
||||
$root_namespace = $match[1];
|
||||
$rest_fqcn = $match[2];
|
||||
|
||||
$proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
|
||||
$proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
|
||||
|
||||
$proxy_class_string = $this->proxyBuilder->build($class_name);
|
||||
|
||||
$file_string = <<<EOF
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \{{ proxy_class_name }}.
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file was generated via php core/scripts/generate-proxy-class.php '$class_name' "$namespace_root".
|
||||
*/
|
||||
{{ proxy_class_string }}
|
||||
EOF;
|
||||
$file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue