Skip to content

Commit df6df11

Browse files
committed
Merge branch 'master' of github.com:hechoendrupal/drupal-console
2 parents a835913 + 31bdaa5 commit df6df11

17 files changed

Lines changed: 63 additions & 51 deletions

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"drupal/console-core": "1.9.7",
5050
"drupal/console-extend-plugin": "~0.9.5",
5151
"psy/psysh": "0.6.* || ~0.8",
52+
"symfony/expression-language": "~3.0|~4.0",
5253
"symfony/css-selector": "~3.0|~4.0",
5354
"symfony/dom-crawler": "~3.0|~4.0",
5455
"symfony/http-foundation": "~3.0|~4.0"

src/Command/Config/ImportSingleCommand.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
$name = Path::getFilenameWithoutExtension($configFile);
103103
$ymlFile = new Parser();
104104
$value = $ymlFile->parse(file_get_contents($configFile));
105-
$source_storage->delete($name);
106-
$source_storage->write($name, $value);
105+
$source_storage->replaceData($name, $value);
107106
$names[] = $name;
108107
continue;
109108
}

src/Command/Shared/EventsTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*/
1515
trait EventsTrait
1616
{
17+
private $events;
18+
1719
/**
1820
* @return mixed
1921
*/

src/Extension/Manager.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,6 @@ class Manager
4646
*/
4747
private $extension = null;
4848

49-
/**
50-
* @var Drupal\Core\Extension\ModuleExtensionList
51-
*/
52-
private $extensionList;
53-
5449
/**
5550
* @var ModuleHandlerInterface
5651
*/
@@ -67,22 +62,19 @@ class Manager
6762
* @param Site $site
6863
* @param Client $httpClient
6964
* @param string $appRoot
70-
* @param ModuleExtensionList $extensionList
7165
* @param ModuleHandlerInterface $moduleHandler
7266
* @param ThemeHandler $themeHandler
7367
*/
7468
public function __construct(
7569
Site $site,
7670
Client $httpClient,
7771
$appRoot,
78-
ModuleExtensionList $extensionList,
7972
ModuleHandlerInterface $moduleHandler,
8073
ThemeHandler $themeHandler
8174
) {
8275
$this->site = $site;
8376
$this->httpClient = $httpClient;
8477
$this->appRoot = $appRoot;
85-
$this->extensionList = $extensionList;
8678
$this->moduleHandler = $moduleHandler;
8779
$this->themeHandler = $themeHandler;
8880
$this->initialize();
@@ -250,7 +242,8 @@ private function discoverExtensions($type)
250242
{
251243
if ($type === 'module') {
252244
$this->site->loadLegacyFile('/core/modules/system/system.module');
253-
$this->extensionList->reset()->getList();
245+
$extensionList = \Drupal::service('extension.list.module');
246+
$extensionList->reset()->getList();
254247
}
255248

256249
if ($type === 'theme') {

src/Generator/BlockTypeGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function generate(array $parameters)
3737
$module = $parameters['module'];
3838
$class_name = $parameters['class_name'];
3939
$blockId = $parameters['block_id'];
40-
$description = $parameters['block_description'];
40+
$description = $parameters['description'];
4141
$parameters['machine_name'] = $blockId;
4242

4343
$this->renderFile(

src/Generator/ComposerGenerator.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ public function __construct(
4040
public function generate(array $parameters)
4141
{
4242
$machineName = $parameters['machine_name'];
43+
$module = $this->extensionManager->getModule($machineName);
44+
if (!$module) {
45+
throw new \Exception(
46+
"Unable to load module: \"{$machineName}\" from extension manager. This may be an unresolved issue in the module generator. This will prevent the generator from creating the composer.json file for the module. Try calling the command without setting dependencies. See https://github.com/hechoendrupal/drupal-console/issues/4118");
47+
}
4348
$composerPath = !is_null($parameters['package_path']) ?
4449
$parameters['package_path'] . '/' . $machineName . '/composer.json' :
45-
$this->extensionManager->getModule($machineName)
46-
->getPath() . '/composer.json';
50+
$module->getPath() . '/composer.json';
4751
$this->renderFile(
4852
'module/composer.json.twig',
4953
$composerPath,

src/Generator/PluginSkeletonGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function generate(array $parameters)
3737
$module = $parameters['module'];
3838
$pluginMetaData = $parameters['plugin_metadata'];
3939

40-
$parameters['plugin_annotation'] = array_pop(explode('\\', $pluginMetaData['pluginAnnotation']));
41-
$parameters['plugin_interface'] = array_pop(explode('\\', $pluginMetaData['pluginInterface']));
40+
$parameters['plugin_annotation'] = current(explode('\\', $pluginMetaData['pluginAnnotation']));
41+
$parameters['plugin_interface'] = current(explode('\\', $pluginMetaData['pluginInterface']));
4242
$parameters['namespace'] = str_replace('/', '\\', $pluginMetaData['subdir']);
4343

4444
$this->renderFile(

templates/module/links.task-entity-content.yml.twig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
route_name: {{ entity_name }}.settings
66
title: 'Settings'
77
base_route: {{ entity_name }}.settings
8+
{% else %}
9+
entity.{{ entity_name }}_type.edit_form:
10+
route_name: entity.{{ entity_name }}_type.edit_form
11+
base_route: entity.{{ entity_name }}_type.edit_form
12+
title: 'Edit'
13+
weight: 0
814
{% endif %}
915

1016
entity.{{ entity_name }}.canonical:

templates/module/src/Controller/entity-controller.php.twig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace Drupal\{{ module }}\Controller;
1212
use Drupal\Component\Utility\Xss;
1313
use Drupal\Core\Controller\ControllerBase;
1414
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
15+
use Drupal\Core\Link;
1516
use Drupal\Core\Url;
1617
use Drupal\{{ module }}\Entity\{{ entity_class }}Interface;
1718
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -117,7 +118,7 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
117118
$latest_revision = TRUE;
118119

119120
foreach (array_reverse($vids) as $vid) {
120-
/** @var \Drupal\{{ module }}\{{ entity_class }}Interface $revision */
121+
/** @var \Drupal\{{ module }}\Entity\{{ entity_class }}Interface $revision */
121122
$revision = ${{ entity_name }}_storage->loadRevision($vid);
122123
{% if is_translatable %}
123124
// Only show revisions that are affected by the language that is being
@@ -132,13 +133,13 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
132133
// Use revision link to link to revisions that are not active.
133134
$date = $this->dateFormatter->format($revision->getRevisionCreationTime(), 'short');
134135
if ($vid != ${{ entity_name }}->getRevisionId()) {
135-
$link = $this->l($date, new Url('entity.{{ entity_name }}.revision', [
136+
$link = Link::fromTextAndUrl($date, new Url('entity.{{ entity_name }}.revision', [
136137
'{{ entity_name }}' => ${{ entity_name }}->id(),
137138
'{{ entity_name }}_revision' => $vid,
138-
]));
139+
]))->toString();
139140
}
140141
else {
141-
$link = ${{ entity_name }}->link($date);
142+
$link = ${{ entity_name }}->toLink($date)->toString();
142143
}
143144

144145
$row = [];

templates/module/src/Entity/Form/entity-content-revision-delete.php.twig

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
2323
*/
2424
class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %}
2525
{% block class_methods %}
26+
27+
/**
28+
* The date formatter.
29+
*
30+
* @var \Drupal\Core\Datetime\DateFormatterInterface
31+
*/
32+
protected $dateFormatter;
33+
2634
/**
2735
* The {{ label }} revision.
2836
*
@@ -49,6 +57,7 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
4957
*/
5058
public static function create(ContainerInterface $container) {
5159
$instance = parent::create($container);
60+
$instance->dateFormatter = $container->get('date.formatter');
5261
$instance->{{ entity_class[:1]|lower ~ entity_class[1:] }}Storage = $container->get('entity_type.manager')->getStorage('{{ entity_name }}');
5362
$instance->connection = $container->get('database');
5463
return $instance;
@@ -66,7 +75,7 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
6675
*/
6776
public function getQuestion() {
6877
return $this->t('Are you sure you want to delete the revision from %revision-date?', [
69-
'%revision-date' => \Drupal::service('date.formatter')->format($this->revision->getRevisionCreationTime()),
78+
'%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()),
7079
]);
7180
}
7281

@@ -101,7 +110,7 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
101110
$this->{{ entity_class }}Storage->deleteRevision($this->revision->getRevisionId());
102111

103112
$this->logger('content')->notice('{{ label }}: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
104-
$this->messenger()->addMessage(t('Revision from %revision-date of {{ label }} %title has been deleted.', ['%revision-date' => \Drupal::service('date.formatter')->format($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
113+
$this->messenger()->addMessage(t('Revision from %revision-date of {{ label }} %title has been deleted.', ['%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
105114
$form_state->setRedirect(
106115
'entity.{{ entity_name }}.canonical',
107116
['{{ entity_name }}' => $this->revision->id()]

0 commit comments

Comments
 (0)