- */
-class YamlFileDumper extends FileDumper
-{
- /**
- * @var int Nesting depth. 0 means one line by message, 1 will
- * indent at most one time, and so on.
- */
- public $nestLevel = 0;
-
- /**
- * {@inheritDoc}
- */
- public function dump(MessageCatalogue $messages, $options = array())
- {
- $this->nestLevel = array_key_exists('nest-level', $options) ? $options['nest-level'] : 0;
-
- parent::dump($messages, $options);
- }
-
- /**
- * {@inheritDoc}
- */
- protected function format(MessageCatalogue $messages, $domain)
- {
- $m = $messages->all($domain);
-
- if ($this->nestLevel > 0) {
- // build a message tree from the message list, with a max depth
- // of $this->nestLevel
- $tree = array();
- foreach ($m as $key => $message) {
- // dots are ignored at the beginning and at the end of a key
- $key = trim($key, "\t .");
-
- if (strlen($key) > 0) {
- $codes = explode('.', $key, $this->nestLevel + 1);
- $node = &$tree;
-
- foreach ($codes as $code) {
- if (strlen($code) > 0) {
- if (!isset($node)) {
- $node = array();
- }
- $node = &$node[$code];
- }
- }
- $node = $message;
- }
- }
-
- return Yaml::dump(
- $tree,
- $this->nestLevel + 1
- ); // second parameter at 1 outputs normal line-by-line catalogue
- } else {
- return Yaml::dump($m, 1);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- protected function getExtension()
- {
- return 'yml';
- }
-}
diff --git a/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php b/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php
index 89b7a7c1f..143c8b94a 100644
--- a/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php
+++ b/src/Zippy/Adapter/TarGzGNUTarForWindowsAdapter.php
@@ -13,6 +13,7 @@
/**
* Class TarGzGNUTarForWindowsAdapter
+ *
* @package Drupal\Console\Zippy\Adapter
*/
class TarGzGNUTarForWindowsAdapter extends TarGzGNUTarAdapter
@@ -30,6 +31,6 @@ protected function doAdd(ResourceInterface $resource, $files, $recursive)
*/
protected function getLocalOptions()
{
- return array_merge(parent::getLocalOptions(), array('--force-local'));
+ return array_merge(parent::getLocalOptions(), ['--force-local']);
}
}
diff --git a/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php b/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php
index 6c83aecca..c0f672ce4 100644
--- a/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php
+++ b/src/Zippy/FileStrategy/TarGzFileForWindowsStrategy.php
@@ -11,6 +11,7 @@
/**
* Class TarGzFileForWindowsStrategy
+ *
* @package Drupal\Console\Zippy/Strategy
*/
class TarGzFileForWindowsStrategy extends AbstractFileStrategy
@@ -20,9 +21,9 @@ class TarGzFileForWindowsStrategy extends AbstractFileStrategy
*/
protected function getServiceNames()
{
- return array(
+ return [
'Drupal\\Console\\Zippy\\Adapter\\TarGzGNUTarForWindowsAdapter'
- );
+ ];
}
/**
diff --git a/templates/dash/generate-doc.html.twig b/templates/dash/generate-doc.html.twig
deleted file mode 100644
index 196bbc715..000000000
--- a/templates/dash/generate-doc.html.twig
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
- {% block title %}{{ command }}{% endblock %}
-
-
-
-{{ command }}
-The {{ command }} command: {{ description }}
-Usage:
-
- $ drupal {{ command }} {% if arguments|length>0 %}[arguments] {% endif %}{% if options|length>0 %}[options] {% endif %}
-
-
-{% if options|length>0 %}
-Available options
-
-
-
- Option
- Details
-
-
-
- {% for option in options %}
-
- {{ option.name }}
- {{ option.description }}
-
- {% endfor %}
-
-
-{% endif %}
-
-{% if arguments|length>0 %}
-Available arguments
-
-
-
- Argument
- Details
-
-
-
- {% for argument in arguments %}
-
- {{ argument.name }}
- {{ argument.description }}
-
- {% endfor %}
-
-
-{% endif %}
-
-
diff --git a/templates/dash/index.html.twig b/templates/dash/index.html.twig
deleted file mode 100644
index 83428bd03..000000000
--- a/templates/dash/index.html.twig
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-
-
- Drupal Console
-
-
-
-Drupal Console
-
-Getting the project
-
-There are different ways to get the project on your local machine. Our recommendation for getting the project on your
- local machine is by using the installer.
-
-Using the Drupal Console Installer
-
-You can install the Drupal Console locally by running the installer in your project
- directory, the installer will take care of downloading the necesary files to run drupal console on you computer.
-
-Using curl:
-$ curl https://drupalconsole.com/installer -L -o drupal.phar
-
-Or if you don't have curl:
-php -r "readfile('https://drupalconsole.com/installer');" > drupal.phar
-
-Example:
-$ php console.phar generate:module
-
-You can place this file anywhere you wish. If you put it in your PATH, you can access it
- globally. On unixy systems you can even make it executable and invoke it without php.
-
-Access console from anywhere on your system
-$ mv console.phar /usr/local/bin/drupal
-
-Apply executable permissions on the downloaded file:
-$ chmod +x /usr/local/bin/drupal
-
-You can now execute console using:
-$ drupal
-
-NOTE: The name drupal
is just an alias you can name it
- anything you like.
-
-
-Install Drupal Console Using Composer
-
-You can install this project using composer.
-
-
-
-Install Drupal Console globally using composer:
-$ composer global require drupal/console:@stable
-
-Add the binary directory to your class path:
-$ echo "PATH=$PATH:~/.composer/vendor/bin" >> ~/.bash_profile
-
-You can now execute console using:
-$ console generate:module
-
-Download phar file
-
-You can download the latest version of Console from the repository releases page at:
-
-https://github.com/hechoendrupal/DrupalConsole
-
-
-Make sure you download the console.phar file from the most current release.
-
-Update project
-
-Drupal 8 is under heavy development, to keep in sync with the latest changes. The easiest and recommended way of
- updating Drupal Console is using the self-update command.
-
-Depending on the installation method:
-Installed globally (and renamed to "drupal"):
-$ drupal self-update
-
-Installed globally (using composer):
-$ composer global update drupal/console:@stable
-
-Installed locally (running
- from directory where the console.phar has been downloaded):
-$ php console.phar self-update
-
-Available Drupal Console Commands
-Note: Drupal Console commands *must* be run from the root of a Drupal 8 installation.
-
-
-
- Drupal Console Command
- Details
-
-
-
- {% for namespace, commands in command_list %}
- {% if namespace != 'none' %}
-
- {{ namespace }}
-
-
- {% endif %}
- {% for command in commands %}
-
- {{ command.name }}
- {{ command.description }}
-
- {% endfor %}
- {% endfor %}
-
-
-{% if options|length>0 %}
- Available options
-
-
-
- Option
- Details
-
-
-
- {% for option in options %}
-
- {{ option.name }}
- {{ option.description }}
-
- {% endfor %}
-
-
-{% endif %}
-{% if arguments|length>0 %}
- Available arguments
-
-
-
- Argument
- Details
-
-
-
- {% for argument in arguments %}
-
- {{ argument.name }}
- {{ argument.description }}
-
- {% endfor %}
-
-
-{% endif %}
-
-
diff --git a/templates/database/add.php.twig b/templates/database/add.php.twig
new file mode 100644
index 000000000..c279c9fbd
--- /dev/null
+++ b/templates/database/add.php.twig
@@ -0,0 +1,10 @@
+
+$databases['{{ database }}']['default'] = [
+ 'database' => '{{ database }}',
+ 'username' => '{{ username }}',
+ 'password' => '{{ password }}',
+ 'host' => '{{ host }}',
+ 'port' => '{{ port }}',
+ 'driver' => '{{ driver }}',
+ 'prefix' => '{{ prefix }}',
+];
diff --git a/templates/gitbook/available-commands-list.md.twig b/templates/gitbook/available-commands-list.md.twig
deleted file mode 100644
index 3343a19aa..000000000
--- a/templates/gitbook/available-commands-list.md.twig
+++ /dev/null
@@ -1,14 +0,0 @@
-{% for namespace in application.namespaces %}
-{% if not loop.first %}
-{% set last_namespace = namespace %}
-{% endif %}
-{% if last_namespace is defined %}
-
- {# Empty new line hack #}
-{% endif %}
-{% spaceless %}
-{% for command in commands[namespace] %}
- * [{{ command.name }}](commands/{{ command.name|replace(':','-') }}.md)
-{% endfor %}
-{% endspaceless %}
-{% endfor %}
diff --git a/templates/gitbook/available-commands.md.twig b/templates/gitbook/available-commands.md.twig
deleted file mode 100644
index a9791ba6b..000000000
--- a/templates/gitbook/available-commands.md.twig
+++ /dev/null
@@ -1,32 +0,0 @@
-# {{ application.messages.title }}
-
-**{{ application.messages.note }}:** {{ application.messages.note_description }}.
-
-{{ application.messages.command }} | {{ application.messages.details }}
------------- | -------------
-{% for namespace in application.namespaces %}
-{% if namespace != 'none' %}
-**{{ namespace }}** |
-{% endif %}
-{% for command in commands[namespace] %}
-[{{ command.name }}]({{ command.name|replace(':','-') }}.md) | {{ command.description }}
-{% endfor %}
-{% endfor %}
-{% if application.options|length>0 %}
-
-## {{ application.messages.options }}
-{{ application.messages.option }} | {{ application.messages.details }}
--------|-------------
-{% for option in application.options %}
---{{ option.name }} | {{ option.description }}
-{% endfor %}
-{% endif %}
-{% if application.arguments|length>0 %}
-
-## {{ application.messages.arguments }}
-{{ application.messages.argument }} | {{ application.messages.details }}
----------|-------------
-{% for argument in application.arguments %}
-{{ argument.name }} | {{ argument.description }}
-{% endfor %}
-{% endif %}
diff --git a/templates/gitbook/command.md.twig b/templates/gitbook/command.md.twig
deleted file mode 100644
index df02d0900..000000000
--- a/templates/gitbook/command.md.twig
+++ /dev/null
@@ -1,39 +0,0 @@
-# {{ name }}
-{{ description }}
-
-**{{ messages.usage }}:**
-```
-$ drupal {{ name }}{% if arguments|length>0 %} [arguments]{% endif %}{% if options|length>0 %} [options]{% endif %}
-
-{% for alias in aliases %}
-$ {{ alias }}
-{% endfor %}
-```
-{% if options|length>0 %}
-
-## {{ messages.options }}
-{{ messages.option }} | {{ messages.details }}
--------|-------------
-{% for option in options %}
---{{ option.name }} | {{ option.description }}
-{% endfor %}
-{% endif %}
-{% if arguments|length>0 %}
-
-## {{ messages.arguments }}
-{{ messages.argument }} | {{ messages.details }}
----------|-------------
-{% for argument in arguments %}
-{{ argument.name }} | {{ argument.description }}
-{% endfor %}
-{% endif %}
-{% if examples|length>0 %}
-
-## {{ messages.examples }}
-{% for example in examples %}
-* {{ example.description }}
-```
-$ {{ example.execution }}
-```
-{% endfor %}
-{% endif %}
diff --git a/templates/module/Tests/Controller/controller.php.twig b/templates/module/Tests/Controller/controller.php.twig
index a1748f9f5..d963c6652 100644
--- a/templates/module/Tests/Controller/controller.php.twig
+++ b/templates/module/Tests/Controller/controller.php.twig
@@ -23,11 +23,11 @@ class {{class_name}}Test extends WebTestBase {% endblock %}
* {@inheritdoc}
*/
public static function getInfo() {
- return array(
+ return [
'name' => "{{module}} {{class_name}}'s controller functionality",
'description' => 'Test Unit for module {{module}} and controller {{class_name}}.',
'group' => 'Other',
- );
+ ];
}
/**
diff --git a/templates/module/entity-content-page.php.twig b/templates/module/entity-content-page.php.twig
index 4279ebe0d..4b855e446 100644
--- a/templates/module/entity-content-page.php.twig
+++ b/templates/module/entity-content-page.php.twig
@@ -9,8 +9,6 @@
{% block use_class %}
use Drupal\Core\Render\Element;
-use Drupal\Core\Link;
-use Drupal\Core\Url;
{% endblock %}
{% block file_methods %}
diff --git a/templates/module/src/help.php.twig b/templates/module/help.php.twig
similarity index 93%
rename from templates/module/src/help.php.twig
rename to templates/module/help.php.twig
index d43f632e8..28248c1e5 100644
--- a/templates/module/src/help.php.twig
+++ b/templates/module/help.php.twig
@@ -1,6 +1,6 @@
{% block file_methods %}
{% if not file_exists %}
- [
+ 'render element' => 'children',
+ ],
+ ];
+}
diff --git a/templates/module/module.twig b/templates/module/module.twig
index c6b55b356..53540372f 100644
--- a/templates/module/module.twig
+++ b/templates/module/module.twig
@@ -1,6 +1,6 @@
{% extends "base/file.php.twig" %}
-{% block file_path %}{{machine_name}}.module.{% endblock %}
+{% block file_path %}{{machine_name}}.module{% endblock %}
{% block use_class %}
use Drupal\Core\Routing\RouteMatchInterface;
diff --git a/templates/module/module.views.inc.twig b/templates/module/module.views.inc.twig
index daf921f23..98e755c13 100644
--- a/templates/module/module.views.inc.twig
+++ b/templates/module/module.views.inc.twig
@@ -21,19 +21,19 @@ use Drupal\system\ActionConfigEntityInterface;
function {{module}}_views_data() {
$data['views']['table']['group'] = t('Custom Global');
- $data['views']['table']['join'] = array(
+ $data['views']['table']['join'] = [
// #global is a special flag which allows a table to appear all the time.
- '#global' => array(),
- );
+ '#global' => [],
+ ];
- $data['views']['{{ class_machine_name }}'] = array(
+ $data['views']['{{ class_machine_name }}'] = [
'title' => t('{{ title }}'),
'help' => t('{{ description }}'),
- 'field' => array(
+ 'field' => [
'id' => '{{ class_machine_name }}',
- ),
- );
+ ],
+ ];
return $data;
}
diff --git a/templates/module/php_tag.php.twig b/templates/module/php_tag.php.twig
new file mode 100644
index 000000000..b3d9bbc7f
--- /dev/null
+++ b/templates/module/php_tag.php.twig
@@ -0,0 +1 @@
+entityManager()->getStorage('{{ entity_name }}')->loadRevision(${{ entity_name }}_revision);
- return $this->t('Revision of %title from %date', array('%title' => ${{ entity_name }}->label(), '%date' => format_date(${{ entity_name }}->getRevisionCreationTime())));
+ return $this->t('Revision of %title from %date', ['%title' => ${{ entity_name }}->label(), '%date' => format_date(${{ entity_name }}->getRevisionCreationTime())]);
}
/**
@@ -74,12 +72,12 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
${{ entity_name }}_storage = $this->entityManager()->getStorage('{{ entity_name }}');
$build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => ${{ entity_name }}->label()]) : $this->t('Revisions for %title', ['%title' => ${{ entity_name }}->label()]);
- $header = array($this->t('Revision'), $this->t('Operations'));
+ $header = [$this->t('Revision'), $this->t('Operations')];
$revert_permission = (($account->hasPermission("revert all {{ label|lower }} revisions") || $account->hasPermission('administer {{ label|lower }} entities')));
$delete_permission = (($account->hasPermission("delete all {{ label|lower }} revisions") || $account->hasPermission('administer {{ label|lower }} entities')));
- $rows = array();
+ $rows = [];
$vids = ${{ entity_name }}_storage->revisionIds(${{ entity_name }});
@@ -93,11 +91,11 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
$username = [
'#theme' => 'username',
- '#account' => $revision->getRevisionAuthor(),
+ '#account' => $revision->getRevisionUser(),
];
// Use revision link to link to revisions that are not active.
- $date = \Drupal::service('date.formatter')->format($revision->revision_timestamp->value, 'short');
+ $date = \Drupal::service('date.formatter')->format($revision->getRevisionCreationTime(), 'short');
if ($vid != ${{ entity_name }}->getRevisionId()) {
$link = $this->l($date, new Url('entity.{{ entity_name }}.revision', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]));
}
@@ -113,7 +111,7 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
'#context' => [
'date' => $link,
'username' => \Drupal::service('renderer')->renderPlain($username),
- 'message' => ['#markup' => $revision->revision_log_message->value, '#allowed_tags' => Xss::getHtmlTagList()],
+ 'message' => ['#markup' => $revision->getRevisionLogMessage(), '#allowed_tags' => Xss::getHtmlTagList()],
],
],
];
@@ -139,10 +137,10 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
'title' => $this->t('Revert'),
{% if is_translatable %}
'url' => $has_translations ?
- Url::fromRoute('{{ entity_name }}.revision_revert_translation_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid, 'langcode' => $langcode]) :
- Url::fromRoute('{{ entity_name }}.revision_revert_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
+ Url::fromRoute('entity.{{ entity_name }}.translation_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid, 'langcode' => $langcode]) :
+ Url::fromRoute('entity.{{ entity_name }}.revision_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
{% else %}
- 'url' => Url::fromRoute('{{ entity_name }}.revision_revert_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
+ 'url' => Url::fromRoute('entity.{{ entity_name }}.revision_revert', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
{% endif %}
];
}
@@ -150,7 +148,7 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
if ($delete_permission) {
$links['delete'] = [
'title' => $this->t('Delete'),
- 'url' => Url::fromRoute('{{ entity_name }}.revision_delete_confirm', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
+ 'url' => Url::fromRoute('entity.{{ entity_name }}.revision_delete', ['{{ entity_name }}' => ${{ entity_name }}->id(), '{{ entity_name }}_revision' => $vid]),
];
}
@@ -166,11 +164,11 @@ class {{ entity_class }}Controller extends ControllerBase implements ContainerIn
}
}
- $build['{{ entity_name }}_revisions_table'] = array(
+ $build['{{ entity_name }}_revisions_table'] = [
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
- );
+ ];
return $build;
}
diff --git a/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig b/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig
index 4d5a13f2e..02674ac11 100644
--- a/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig
+++ b/templates/module/src/Entity/Form/entity-content-revision-delete.php.twig
@@ -82,14 +82,14 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
* {@inheritdoc}
*/
public function getQuestion() {
- return t('Are you sure you want to delete the revision from %revision-date?', array('%revision-date' => format_date($this->revision->getRevisionCreationTime())));
+ return t('Are you sure you want to delete the revision from %revision-date?', ['%revision-date' => format_date($this->revision->getRevisionCreationTime())]);
}
/**
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.{{ entity_name }}.version_history', array('{{ entity_name }}' => $this->revision->id()));
+ return new Url('entity.{{ entity_name }}.version_history', ['{{ entity_name }}' => $this->revision->id()]);
}
/**
@@ -115,16 +115,16 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->{{ entity_class }}Storage->deleteRevision($this->revision->getRevisionId());
- $this->logger('content')->notice('{{ label }}: deleted %title revision %revision.', array('%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
- drupal_set_message(t('Revision from %revision-date of {{ label }} %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label())));
+ $this->logger('content')->notice('{{ label }}: deleted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
+ drupal_set_message(t('Revision from %revision-date of {{ label }} %title has been deleted.', ['%revision-date' => format_date($this->revision->getRevisionCreationTime()), '%title' => $this->revision->label()]));
$form_state->setRedirect(
'entity.{{ entity_name }}.canonical',
- array('{{ entity_name }}' => $this->revision->id())
+ ['{{ entity_name }}' => $this->revision->id()]
);
- if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id', array(':id' => $this->revision->id()))->fetchField() > 1) {
+ if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id', [':id' => $this->revision->id()])->fetchField() > 1) {
$form_state->setRedirect(
'entity.{{ entity_name }}.version_history',
- array('{{ entity_name }}' => $this->revision->id())
+ ['{{ entity_name }}' => $this->revision->id()]
);
}
}
diff --git a/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig b/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig
index 6d2f46c2a..0c38ba5b3 100644
--- a/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig
+++ b/templates/module/src/Entity/Form/entity-content-revision-revert-translation.php.twig
@@ -87,11 +87,11 @@ class {{ entity_class }}RevisionRevertTranslationForm extends {{ entity_class }}
$this->langcode = $langcode;
$form = parent::buildForm($form, $form_state, ${{ entity_name }}_revision);
- $form['revert_untranslated_fields'] = array(
+ $form['revert_untranslated_fields'] = [
'#type' => 'checkbox',
'#title' => $this->t('Revert content shared among translations'),
'#default_value' => FALSE,
- );
+ ];
return $form;
}
diff --git a/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig b/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig
index 42e65979f..4077d9417 100644
--- a/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig
+++ b/templates/module/src/Entity/Form/entity-content-revision-revert.php.twig
@@ -89,7 +89,7 @@ class {{ entity_class }}RevisionRevertForm extends ConfirmFormBase {% endblock %
* {@inheritdoc}
*/
public function getCancelUrl() {
- return new Url('entity.{{ entity_name }}.version_history', array('{{ entity_name }}' => $this->revision->id()));
+ return new Url('entity.{{ entity_name }}.version_history', ['{{ entity_name }}' => $this->revision->id()]);
}
/**
@@ -132,7 +132,7 @@ class {{ entity_class }}RevisionRevertForm extends ConfirmFormBase {% endblock %
drupal_set_message(t('{{ label }} %title has been reverted to the revision from %revision-date.', ['%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
$form_state->setRedirect(
'entity.{{ entity_name }}.version_history',
- array('{{ entity_name }}' => $this->revision->id())
+ ['{{ entity_name }}' => $this->revision->id()]
);
}
diff --git a/templates/module/src/Entity/Form/entity-content.php.twig b/templates/module/src/Entity/Form/entity-content.php.twig
index 1cc9a7cf2..63982a485 100644
--- a/templates/module/src/Entity/Form/entity-content.php.twig
+++ b/templates/module/src/Entity/Form/entity-content.php.twig
@@ -30,12 +30,12 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %}
{% if revisionable %}
if (!$this->entity->isNew()) {
- $form['new_revision'] = array(
+ $form['new_revision'] = [
'#type' => 'checkbox',
'#title' => $this->t('Create new revision'),
'#default_value' => FALSE,
'#weight' => 10,
- );
+ ];
}
{% endif %}
@@ -57,7 +57,7 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %}
// If a new revision is created, save the current user as revision author.
$entity->setRevisionCreationTime(REQUEST_TIME);
- $entity->setRevisionAuthorId(\Drupal::currentUser()->id());
+ $entity->setRevisionUserId(\Drupal::currentUser()->id());
}
else {
$entity->setNewRevision(FALSE);
diff --git a/templates/module/src/Entity/Form/entity-settings.php.twig b/templates/module/src/Entity/Form/entity-settings.php.twig
index df0a3aebe..aa71845e4 100644
--- a/templates/module/src/Entity/Form/entity-settings.php.twig
+++ b/templates/module/src/Entity/Form/entity-settings.php.twig
@@ -17,8 +17,6 @@ use Drupal\Core\Form\FormStateInterface;
/**
* Class {{ entity_class }}SettingsForm.
*
- * @package Drupal\{{module}}\Form
- *
* @ingroup {{module}}
*/
class {{ entity_class }}SettingsForm extends FormBase {% endblock %}
@@ -30,7 +28,7 @@ class {{ entity_class }}SettingsForm extends FormBase {% endblock %}
* The unique string identifying the form.
*/
public function getFormId() {
- return '{{ entity_class }}_settings';
+ return '{{ entity_class|lower }}_settings';
}
/**
@@ -57,7 +55,7 @@ class {{ entity_class }}SettingsForm extends FormBase {% endblock %}
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
- $form['{{ entity_class }}_settings']['#markup'] = 'Settings form for {{ label }} entities. Manage field settings here.';
+ $form['{{ entity_class|lower }}_settings']['#markup'] = 'Settings form for {{ label }} entities. Manage field settings here.';
return $form;
}
{% endblock %}
diff --git a/templates/module/src/Entity/entity-content-views-data.php.twig b/templates/module/src/Entity/entity-content-views-data.php.twig
index ffaed8650..c8ee2645b 100644
--- a/templates/module/src/Entity/entity-content-views-data.php.twig
+++ b/templates/module/src/Entity/entity-content-views-data.php.twig
@@ -10,14 +10,13 @@ namespace Drupal\{{ module }}\Entity;
{% block use_class %}
use Drupal\views\EntityViewsData;
-use Drupal\views\EntityViewsDataInterface;
{% endblock %}
{% block class_declaration %}
/**
* Provides Views data for {{ label }} entities.
*/
-class {{ entity_class }}ViewsData extends EntityViewsData implements EntityViewsDataInterface {% endblock %}
+class {{ entity_class }}ViewsData extends EntityViewsData {% endblock %}
{% block class_methods %}
/**
* {@inheritdoc}
@@ -25,11 +24,8 @@ class {{ entity_class }}ViewsData extends EntityViewsData implements EntityViews
public function getViewsData() {
$data = parent::getViewsData();
- $data['{{ entity_name }}']['table']['base'] = array(
- 'field' => 'id',
- 'title' => $this->t('{{ label }}'),
- 'help' => $this->t('The {{ label }} ID.'),
- );
+ // Additional information for Views integration, such as table joins, can be
+ // put here.
return $data;
}
diff --git a/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig b/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig
index c14788809..77ea4dfbb 100644
--- a/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig
+++ b/templates/module/src/Entity/entity-content-with-bundle.theme_hook_suggestions.php.twig
@@ -4,7 +4,7 @@
* Implements hook_theme_suggestions_HOOK().
*/
function {{ module }}_theme_suggestions_{{ entity_name }}(array $variables) {
- $suggestions = array();
+ $suggestions = [];
$entity = $variables['elements']['#{{ entity_name }}'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
diff --git a/templates/module/src/Entity/entity-content.php.twig b/templates/module/src/Entity/entity-content.php.twig
index 640e1d97e..f1088f3f8 100644
--- a/templates/module/src/Entity/entity-content.php.twig
+++ b/templates/module/src/Entity/entity-content.php.twig
@@ -56,7 +56,9 @@ use Drupal\user\UserInterface;
* },
* },
* base_table = "{{ entity_name }}",
+{% if is_translatable %}
* data_table = "{{ entity_name }}_field_data",
+{% endif %}
{% if revisionable %}
* revision_table = "{{ entity_name }}_revision",
* revision_data_table = "{{ entity_name }}_field_revision",
@@ -92,11 +94,11 @@ use Drupal\user\UserInterface;
{% if revisionable %}
* "version-history" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions",
* "revision" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/view",
-{% if is_translatable %}
* "revision_revert" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/revert",
+ * "revision_delete" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/delete",
+{% if is_translatable %}
* "translation_revert" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/revert/{langcode}",
{% endif %}
- * "revision_delete" = "{{ base_path }}/{{ entity_name }}/{{ '{'~entity_name~'}' }}/revisions/{{ '{'~entity_name~'_revision}' }}/delete",
{% endif %}
* "collection" = "{{ base_path }}/{{ entity_name }}",
* },
@@ -121,9 +123,9 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
- $values += array(
+ $values += [
'user_id' => \Drupal::currentUser()->id(),
- );
+ ];
}
{% if revisionable %}
@@ -144,21 +146,12 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
// If no revision author has been set explicitly, make the {{ entity_name }} owner the
// revision author.
- if (!$this->getRevisionAuthor()) {
- $this->setRevisionAuthorId($this->getOwnerId());
+ if (!$this->getRevisionUser()) {
+ $this->setRevisionUserId($this->getOwnerId());
}
}
{% endif %}
-{% if bundle_entity_type %}
- /**
- * {@inheritdoc}
- */
- public function getType() {
- return $this->bundle();
- }
-
-{% endif %}
/**
* {@inheritdoc}
*/
@@ -233,38 +226,6 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
$this->set('status', $published ? TRUE : FALSE);
return $this;
}
-{% if revisionable %}
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionCreationTime() {
- return $this->get('revision_timestamp')->value;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionCreationTime($timestamp) {
- $this->set('revision_timestamp', $timestamp);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionAuthor() {
- return $this->get('revision_uid')->entity;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionAuthorId($uid) {
- $this->set('revision_uid', $uid);
- return $this;
- }
-{% endif %}
/**
* {@inheritdoc}
@@ -279,21 +240,21 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
- 'settings' => array(
+ 'settings' => [
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
- ),
- ))
+ ],
+ ])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
@@ -303,20 +264,20 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
{% if revisionable %}
->setRevisionable(TRUE)
{% endif %}
- ->setSettings(array(
+ ->setSettings([
'max_length' => 50,
'text_processing' => 0,
- ))
+ ])
->setDefaultValue('')
- ->setDisplayOptions('view', array(
+ ->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
- ))
- ->setDisplayOptions('form', array(
+ ])
+ ->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
@@ -335,20 +296,7 @@ class {{ entity_class }} extends {% if revisionable %}RevisionableContentEntityB
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
-{% if revisionable %}
-
- $fields['revision_timestamp'] = BaseFieldDefinition::create('created')
- ->setLabel(t('Revision timestamp'))
- ->setDescription(t('The time that the current revision was created.'))
- ->setQueryable(FALSE)
- ->setRevisionable(TRUE);
-
- $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')
- ->setLabel(t('Revision user ID'))
- ->setDescription(t('The user ID of the author of the current revision.'))
- ->setSetting('target_type', 'user')
- ->setQueryable(FALSE)
- ->setRevisionable(TRUE);
+{% if revisionable and is_translatable %}
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
diff --git a/templates/module/src/Entity/entity-content.theme.php.twig b/templates/module/src/Entity/entity-content.theme.php.twig
index 4aab3bdc7..afa9d750c 100644
--- a/templates/module/src/Entity/entity-content.theme.php.twig
+++ b/templates/module/src/Entity/entity-content.theme.php.twig
@@ -1,7 +1,7 @@
{% block hook_theme %}
- $theme['{{ entity_name }}'] = array(
+ $theme['{{ entity_name }}'] = [
'render element' => 'elements',
'file' => '{{ entity_name }}.page.inc',
'template' => '{{ entity_name }}',
- );
+ ];
{% endblock %}
diff --git a/templates/module/src/Entity/entity.php.twig b/templates/module/src/Entity/entity.php.twig
index 07d85f294..03efd8791 100644
--- a/templates/module/src/Entity/entity.php.twig
+++ b/templates/module/src/Entity/entity.php.twig
@@ -24,6 +24,7 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
* id = "{{ entity_name }}",
* label = @Translation("{{ label }}"),
* handlers = {
+ * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\{{ module }}\{{ entity_class }}ListBuilder",
* "form" = {
* "add" = "Drupal\{{ module }}\Form\{{ entity_class }}Form",
diff --git a/templates/module/src/Entity/interface-entity-content.php.twig b/templates/module/src/Entity/interface-entity-content.php.twig
index 7831466e3..981b81bc2 100644
--- a/templates/module/src/Entity/interface-entity-content.php.twig
+++ b/templates/module/src/Entity/interface-entity-content.php.twig
@@ -10,9 +10,8 @@ namespace Drupal\{{module}}\Entity;
{% block use_class %}
{% if revisionable %}
+use Drupal\Core\Entity\RevisionLogInterface;
use Drupal\Core\Entity\RevisionableInterface;
-use Drupal\Component\Utility\Xss;
-use Drupal\Core\Url;
{% else %}
use Drupal\Core\Entity\ContentEntityInterface;
{% endif %}
@@ -26,20 +25,10 @@ use Drupal\user\EntityOwnerInterface;
*
* @ingroup {{module}}
*/
-interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableInterface{% else %} ContentEntityInterface{% endif %}, EntityChangedInterface, EntityOwnerInterface {% endblock %}
+interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableInterface, RevisionLogInterface{% else %} ContentEntityInterface{% endif %}, EntityChangedInterface, EntityOwnerInterface {% endblock %}
{% block class_methods %}
// Add get/set methods for your configuration properties here.
-{% if bundle_entity_type %}
- /**
- * Gets the {{ label }} type.
- *
- * @return string
- * The {{ label }} type.
- */
- public function getType();
-
-{% endif %}
/**
* Gets the {{ label }} name.
*
@@ -125,7 +114,7 @@ interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableI
* @return \Drupal\user\UserInterface
* The user entity for the revision author.
*/
- public function getRevisionAuthor();
+ public function getRevisionUser();
/**
* Sets the {{ label }} revision author.
@@ -136,6 +125,6 @@ interface {{ entity_class }}Interface extends {% if revisionable %}RevisionableI
* @return \Drupal\{{ module }}\Entity\{{ entity_class }}Interface
* The called {{ label }} entity.
*/
- public function setRevisionAuthorId($uid);
+ public function setRevisionUserId($uid);
{% endif %}
{% endblock %}
diff --git a/templates/module/src/Form/entity.php.twig b/templates/module/src/Form/entity.php.twig
index 0b415c571..0ce40406a 100644
--- a/templates/module/src/Form/entity.php.twig
+++ b/templates/module/src/Form/entity.php.twig
@@ -16,8 +16,6 @@ use Drupal\Core\Form\FormStateInterface;
{% block class_declaration %}
/**
* Class {{ entity_class }}Form.
- *
- * @package Drupal\{{ module }}\Form
*/
class {{ entity_class }}Form extends EntityForm {% endblock %}
{% block class_methods %}
@@ -70,6 +68,6 @@ class {{ entity_class }}Form extends EntityForm {% endblock %}
'%label' => ${{ entity_name | machine_name }}->label(),
]));
}
- $form_state->setRedirectUrl(${{ entity_name | machine_name }}->urlInfo('collection'));
+ $form_state->setRedirectUrl(${{ entity_name | machine_name }}->toUrl('collection'));
}
{% endblock %}
diff --git a/templates/module/src/Form/form-config.php.twig b/templates/module/src/Form/form-config.php.twig
index 52ca88bfa..a4cc85a4f 100644
--- a/templates/module/src/Form/form-config.php.twig
+++ b/templates/module/src/Form/form-config.php.twig
@@ -20,12 +20,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
{% block class_declaration %}
/**
* Class {{ class_name }}.
- *
- * @package Drupal\{{module_name}}\Form
*/
class {{ class_name }} extends ConfigFormBase {% endblock %}
{% block class_construct %}
{% if services is not empty %}
+ /**
+ * Constructs a new {{ class_name }} object.
+ */
public function __construct(
ConfigFactoryInterface $config_factory,
{{ servicesAsParameters(services)|join(',\n ') }}
diff --git a/templates/module/src/Form/form.php.twig b/templates/module/src/Form/form.php.twig
index 1e307cef4..6548f0283 100644
--- a/templates/module/src/Form/form.php.twig
+++ b/templates/module/src/Form/form.php.twig
@@ -19,12 +19,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
{% block class_declaration %}
/**
* Class {{ class_name }}.
- *
- * @package Drupal\{{module_name}}\Form
*/
class {{ class_name }} extends FormBase {% endblock %}
{% block class_construct %}
{% if services is not empty %}
+ /**
+ * Constructs a new {{ class_name }} object.
+ */
public function __construct(
{{ servicesAsParameters(services)|join(',\n ') }}
) {
@@ -80,18 +81,17 @@ class {{ class_name }} extends FormBase {% endblock %}
{% endif %}
];
{% endfor %}
-
$form['submit'] = [
- '#type' => 'submit',
- '#value' => t('Submit'),
+ '#type' => 'submit',
+ '#value' => $this->t('Submit'),
];
return $form;
}
/**
- * {@inheritdoc}
- */
+ * {@inheritdoc}
+ */
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
@@ -102,7 +102,7 @@ class {{ class_name }} extends FormBase {% endblock %}
public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result.
foreach ($form_state->getValues() as $key => $value) {
- drupal_set_message($key . ': ' . $value);
+ drupal_set_message($key . ': ' . $value);
}
}
diff --git a/templates/module/src/Plugin/Block/block.php.twig b/templates/module/src/Plugin/Block/block.php.twig
index e223b856f..c7d4cec4f 100644
--- a/templates/module/src/Plugin/Block/block.php.twig
+++ b/templates/module/src/Plugin/Block/block.php.twig
@@ -32,7 +32,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{% block class_construct %}
{% if services is not empty %}
/**
- * Construct.
+ * Constructs a new {{class_name}} object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
diff --git a/templates/module/src/Plugin/Condition/condition.php.twig b/templates/module/src/Plugin/Condition/condition.php.twig
index 569e56298..c782c90f5 100644
--- a/templates/module/src/Plugin/Condition/condition.php.twig
+++ b/templates/module/src/Plugin/Condition/condition.php.twig
@@ -42,7 +42,7 @@ public static function create(ContainerInterface $container, array $configuratio
}
/**
- * Creates a new ExampleCondition instance.
+ * Creates a new {{ class_name }} object.
*
* @param array $configuration
* The plugin configuration, i.e. an array with configuration values keyed
diff --git a/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig b/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig
index 34203bc4d..92059a4d4 100644
--- a/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig
+++ b/templates/module/src/Plugin/Field/FieldFormatter/imageformatter.php.twig
@@ -58,7 +58,7 @@ class {{ class_name }} extends ImageFormatterBase implements ContainerFactoryPlu
protected $imageStyleStorage;
/**
- * Constructs an ImageFormatter object.
+ * Constructs a new {{ class_name }} object.
*
* @param string $plugin_id
* The plugin_id for the formatter.
@@ -177,7 +177,7 @@ class {{ class_name }} extends ImageFormatterBase implements ContainerFactoryPlu
if ($image_link_setting == 'content') {
$entity = $items->getEntity();
if (!$entity->isNew()) {
- $url = $entity->urlInfo();
+ $url = $entity->toUrl();
}
}
elseif ($image_link_setting == 'file') {
diff --git a/templates/module/src/Plugin/Mail/mail.php.twig b/templates/module/src/Plugin/Mail/mail.php.twig
index d2e466e4c..878b3eea2 100644
--- a/templates/module/src/Plugin/Mail/mail.php.twig
+++ b/templates/module/src/Plugin/Mail/mail.php.twig
@@ -31,7 +31,7 @@ class {{class_name}} extends PhpMail {% if services is not empty %}implements Co
{% block class_construct %}
{% if services is not empty %}
/**
- * Construct.
+ * Constructs a new {{class_name}} object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
diff --git a/templates/module/src/Plugin/Rest/Resource/rest.php.twig b/templates/module/src/Plugin/Rest/Resource/rest.php.twig
index a5c3bbdce..9145f2e2a 100644
--- a/templates/module/src/Plugin/Rest/Resource/rest.php.twig
+++ b/templates/module/src/Plugin/Rest/Resource/rest.php.twig
@@ -43,7 +43,7 @@ class {{ class_name }} extends ResourceBase {% endblock %}
{% block class_construct %}
/**
- * Constructs a Drupal\rest\Plugin\ResourceBase object.
+ * Constructs a new {{ class_name }} object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
diff --git a/templates/module/src/Plugin/migrate/process/process.php.twig b/templates/module/src/Plugin/migrate/process/process.php.twig
new file mode 100644
index 000000000..148d433f1
--- /dev/null
+++ b/templates/module/src/Plugin/migrate/process/process.php.twig
@@ -0,0 +1,33 @@
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+\Drupal\{{module}}\Plugin\migrate\process\{{class_name}}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module}}\Plugin\migrate\process;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\migrate\ProcessPluginBase;
+use Drupal\migrate\MigrateExecutableInterface;
+use Drupal\migrate\Row;
+{% endblock %}
+
+{% block class_declaration %}
+/**
+ * Provides a '{{class_name}}' migrate process plugin.
+ *
+ * @MigrateProcessPlugin(
+ * id = "{{plugin_id}}"
+ * )
+ */
+class {{class_name}} extends ProcessPluginBase {% endblock %}
+{% block class_methods %}
+ /**
+ * {@inheritdoc}
+ */
+ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
+ // Plugin logic goes here.
+ }
+{% endblock %}
diff --git a/templates/module/src/Plugin/migrate/source/source.php.twig b/templates/module/src/Plugin/migrate/source/source.php.twig
new file mode 100644
index 000000000..1f8ee6e23
--- /dev/null
+++ b/templates/module/src/Plugin/migrate/source/source.php.twig
@@ -0,0 +1,55 @@
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+\Drupal\{{module}}\Plugin\migrate\source\{{class_name}}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module}}\Plugin\migrate\source;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\migrate\Plugin\migrate\source\SqlBase;
+{% endblock %}
+
+{% block class_declaration %}
+/**
+ * Provides a '{{class_name}}' migrate source.
+ *
+ * @MigrateSource(
+ * id = "{{plugin_id}}"
+ * )
+ */
+class {{class_name}} extends SqlBase {% endblock %}
+{% block class_methods %}
+ /**
+ * {@inheritdoc}
+ */
+ public function query() {
+
+ return $this->select('{{table}}', '{{alias}}')
+ ->fields('{{alias}}'){% if group_by %}
+ ->groupBy('{{alias}}.{{group_by}}')
+ {% endif %};
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function fields() {
+ $fields = [
+ {% for field in fields %}
+ '{{field.id}}' => $this->t('{{field.description}}'),
+ {% endfor %}
+];
+ return $fields;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getIds() {
+ return [
+ ];
+ }
+{% endblock %}
diff --git a/templates/module/src/Plugin/skeleton.php.twig b/templates/module/src/Plugin/skeleton.php.twig
index 4354a98f9..5bce614ab 100644
--- a/templates/module/src/Plugin/skeleton.php.twig
+++ b/templates/module/src/Plugin/skeleton.php.twig
@@ -39,7 +39,7 @@ class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin
{% block class_construct %}
{% if services is not empty %}
/**
- * Construct.
+ * Constructs a new {{class_name}} object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
@@ -54,7 +54,7 @@ class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin
$plugin_definition,
{{ servicesAsParameters(services)|join(', \n\t') }}
) {
- parent::__cons truct($configuration, $plugin_id, $plugin_definition);
+ parent::__construct($configuration, $plugin_id, $plugin_definition);
{{ serviceClassInitialization(services) }}
}
{% endif %}
diff --git a/templates/module/src/Routing/route-subscriber.php.twig b/templates/module/src/Routing/route-subscriber.php.twig
index f7c52b53c..83cb44946 100644
--- a/templates/module/src/Routing/route-subscriber.php.twig
+++ b/templates/module/src/Routing/route-subscriber.php.twig
@@ -17,7 +17,6 @@ use Symfony\Component\Routing\RouteCollection;
/**
* Class {{ class }}.
*
- * @package Drupal\{{module}}\Routing
* Listens to the dynamic route events.
*/
class {{ class }} extends RouteSubscriberBase {% endblock %}
diff --git a/templates/module/src/Tests/load-test.php.twig b/templates/module/src/Tests/load-test.php.twig
index df13935ca..69c2925a7 100644
--- a/templates/module/src/Tests/load-test.php.twig
+++ b/templates/module/src/Tests/load-test.php.twig
@@ -1,16 +1,16 @@
{% extends "base/class.php.twig" %}
{% block file_path %}
-\Drupal\{{ machine_name }}\Tests\LoadTest
+\Drupal\Tests\{{ machine_name }}\Functional\LoadTest
{% endblock %}
{% block namespace_class %}
-namespace Drupal\{{ machine_name }}\Tests;
+namespace Drupal\Tests\{{ machine_name }}\Functional;
{% endblock %}
{% block use_class %}
use Drupal\Core\Url;
-use Drupal\simpletest\WebTestBase;
+use Drupal\Tests\BrowserTestBase;
{% endblock %}
{% block class_declaration %}
@@ -19,7 +19,7 @@ use Drupal\simpletest\WebTestBase;
*
* @group {{ machine_name }}
*/
-class LoadTest extends WebTestBase{% endblock %}
+class LoadTest extends BrowserTestBase {% endblock %}
{% block class_methods %}
/**
* Modules to enable.
diff --git a/templates/module/src/TwigExtension/twig-extension.php.twig b/templates/module/src/TwigExtension/twig-extension.php.twig
index 5b6f54758..362e65d5f 100644
--- a/templates/module/src/TwigExtension/twig-extension.php.twig
+++ b/templates/module/src/TwigExtension/twig-extension.php.twig
@@ -14,8 +14,6 @@ namespace Drupal\{{module}}\TwigExtension;
{% block class_declaration %}
/**
* Class {{ class }}.
- *
- * @package Drupal\{{module}}
*/
class {{ class }} extends \Twig_Extension {% endblock %}
@@ -36,7 +34,7 @@ class {{ class }} extends \Twig_Extension {% endblock %}
{% if services|length > 1 %}
/**
- * Constructor.
+ * Constructs a new {{ class }} object.
*/
public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
parent::__construct($renderer);
diff --git a/templates/module/src/cache-context.php.twig b/templates/module/src/cache-context.php.twig
new file mode 100644
index 000000000..87a7b4c19
--- /dev/null
+++ b/templates/module/src/cache-context.php.twig
@@ -0,0 +1,54 @@
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+\Drupal\{{module}}\{{ class }}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module}}\CacheContext;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Cache\Context\CacheContextInterface;
+{% endblock %}
+
+{% block class_declaration %}
+/**
+* Class {{ class }}.
+*/
+class {{ class }} implements CacheContextInterface {% endblock %}
+
+{% block class_construct %}
+
+ /**
+ * Constructs a new {{ class }} object.
+ */
+ public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
+ {{ serviceClassInitialization(services) }}
+ }
+
+{% endblock %}
+
+{% block class_methods %}
+ /**
+ * {@inheritdoc}
+ */
+ public static function getLabel() {
+ drupal_set_message('Lable of cache context');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getContext() {
+ // Actual logic of context variation will lie here.
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheableMetadata() {
+ return new CacheableMetadata();
+ }
+{% endblock %}
diff --git a/templates/module/src/entity-content-route-provider.php.twig b/templates/module/src/entity-content-route-provider.php.twig
index 0a316ace6..afaa8908a 100644
--- a/templates/module/src/entity-content-route-provider.php.twig
+++ b/templates/module/src/entity-content-route-provider.php.twig
@@ -18,8 +18,8 @@ use Symfony\Component\Routing\Route;
/**
* Provides routes for {{ label }} entities.
*
- * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
- * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
+ * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
+ * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endblock %}
{% block class_methods %}
@@ -30,10 +30,6 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb
$collection = parent::getRoutes($entity_type);
$entity_type_id = $entity_type->id();
-
- if ($collection_route = $this->getCollectionRoute($entity_type)) {
- $collection->add("entity.{$entity_type_id}.collection", $collection_route);
- }
{% if revisionable %}
if ($history_route = $this->getHistoryRoute($entity_type)) {
@@ -45,16 +41,18 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb
}
if ($revert_route = $this->getRevisionRevertRoute($entity_type)) {
- $collection->add("{$entity_type_id}.revision_revert_confirm", $revert_route);
+ $collection->add("entity.{$entity_type_id}.revision_revert", $revert_route);
}
if ($delete_route = $this->getRevisionDeleteRoute($entity_type)) {
- $collection->add("{$entity_type_id}.revision_delete_confirm", $delete_route);
+ $collection->add("entity.{$entity_type_id}.revision_delete", $delete_route);
}
+{% if is_translatable %}
if ($translation_route = $this->getRevisionTranslationRevertRoute($entity_type)) {
$collection->add("{$entity_type_id}.revision_revert_translation_confirm", $translation_route);
}
+{% endif %}
{% endif %}
if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
@@ -63,31 +61,6 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb
return $collection;
}
-
- /**
- * Gets the collection route.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type.
- *
- * @return \Symfony\Component\Routing\Route|null
- * The generated route, if available.
- */
- protected function getCollectionRoute(EntityTypeInterface $entity_type) {
- if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
- $entity_type_id = $entity_type->id();
- $route = new Route($entity_type->getLinkTemplate('collection'));
- $route
- ->setDefaults([
- '_entity_list' => $entity_type_id,
- '_title' => "{$entity_type->getLabel()} list",
- ])
- ->setRequirement('_permission', 'access {{ label|lower }} overview')
- ->setOption('_admin_route', TRUE);
-
- return $route;
- }
- }
{% if revisionable %}
/**
diff --git a/templates/module/src/entity-route-provider.php.twig b/templates/module/src/entity-route-provider.php.twig
index b7ef81652..860d7b307 100644
--- a/templates/module/src/entity-route-provider.php.twig
+++ b/templates/module/src/entity-route-provider.php.twig
@@ -29,39 +29,8 @@ class {{ entity_class }}HtmlRouteProvider extends AdminHtmlRouteProvider {% endb
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
- $entity_type_id = $entity_type->id();
-
- if ($collection_route = $this->getCollectionRoute($entity_type)) {
- $collection->add("entity.{$entity_type_id}.collection", $collection_route);
- }
+ // Provide your custom entity routes here.
return $collection;
}
-
- /**
- * Gets the collection route.
- *
- * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
- * The entity type.
- *
- * @return \Symfony\Component\Routing\Route|null
- * The generated route, if available.
- */
- protected function getCollectionRoute(EntityTypeInterface $entity_type) {
- if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass()) {
- $entity_type_id = $entity_type->id();
- $route = new Route($entity_type->getLinkTemplate('collection'));
- $route
- ->setDefaults([
- '_entity_list' => $entity_type_id,
- // Make sure this is not a TranslatableMarkup object as the
- // TitleResolver translates this string again.
- '_title' => (string) $entity_type->getLabel(),
- ])
- ->setRequirement('_permission', $entity_type->getAdminPermission())
- ->setOption('_admin_route', TRUE);
-
- return $route;
- }
- }
{% endblock %}
diff --git a/templates/module/src/entity-storage.php.twig b/templates/module/src/entity-storage.php.twig
index 006f417e4..01aec1cc4 100644
--- a/templates/module/src/entity-storage.php.twig
+++ b/templates/module/src/entity-storage.php.twig
@@ -33,7 +33,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en
public function revisionIds({{ entity_class }}Interface $entity) {
return $this->database->query(
'SELECT vid FROM {{ '{'~entity_name~'_revision}' }} WHERE id=:id ORDER BY vid',
- array(':id' => $entity->id())
+ [':id' => $entity->id()]
)->fetchCol();
}
@@ -43,7 +43,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en
public function userRevisionIds(AccountInterface $account) {
return $this->database->query(
'SELECT vid FROM {{ '{'~entity_name~'_field_revision}' }} WHERE uid = :uid ORDER BY vid',
- array(':uid' => $account->id())
+ [':uid' => $account->id()]
)->fetchCol();
}
@@ -51,7 +51,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en
* {@inheritdoc}
*/
public function countDefaultLanguageRevisions({{ entity_class }}Interface $entity) {
- return $this->database->query('SELECT COUNT(*) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id AND default_langcode = 1', array(':id' => $entity->id()))
+ return $this->database->query('SELECT COUNT(*) FROM {{ '{'~entity_name~'_field_revision}' }} WHERE id = :id AND default_langcode = 1', [':id' => $entity->id()])
->fetchField();
}
@@ -60,7 +60,7 @@ class {{ entity_class }}Storage extends SqlContentEntityStorage implements {{ en
*/
public function clearRevisionsLanguage(LanguageInterface $language) {
return $this->database->update('{{ entity_name }}_revision')
- ->fields(array('langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED))
+ ->fields(['langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED])
->condition('langcode', $language->getId())
->execute();
}
diff --git a/templates/module/src/event-subscriber.php.twig b/templates/module/src/event-subscriber.php.twig
index a8fded0f3..e79389234 100644
--- a/templates/module/src/event-subscriber.php.twig
+++ b/templates/module/src/event-subscriber.php.twig
@@ -16,15 +16,13 @@ use Symfony\Component\EventDispatcher\Event;
{% block class_declaration %}
/**
* Class {{ class }}.
- *
- * @package Drupal\{{module}}
*/
class {{ class }} implements EventSubscriberInterface {% endblock %}
{% block class_construct %}
/**
- * Constructor.
+ * Constructs a new {{ class }} object.
*/
public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
{{ serviceClassInitialization(services) }}
diff --git a/templates/module/src/listbuilder-entity-content.php.twig b/templates/module/src/listbuilder-entity-content.php.twig
index 1615da806..46af6648c 100644
--- a/templates/module/src/listbuilder-entity-content.php.twig
+++ b/templates/module/src/listbuilder-entity-content.php.twig
@@ -11,8 +11,7 @@ namespace Drupal\{{module}};
{% block use_class %}
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
-use Drupal\Core\Routing\LinkGeneratorTrait;
-use Drupal\Core\Url;
+use Drupal\Core\Link;
{% endblock %}
{% block class_declaration %}
@@ -22,9 +21,6 @@ use Drupal\Core\Url;
* @ingroup {{ module }}
*/
class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %}
-{% block use_trait %}
- use LinkGeneratorTrait;
-{% endblock %}
{% block class_methods %}
/**
@@ -42,13 +38,10 @@ class {{ entity_class }}ListBuilder extends EntityListBuilder {% endblock %}
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\{{module}}\Entity\{{ entity_class }} */
$row['id'] = $entity->id();
- $row['name'] = $this->l(
+ $row['name'] = Link::createFromRoute(
$entity->label(),
- new Url(
- 'entity.{{ entity_name }}.edit_form', array(
- '{{ entity_name }}' => $entity->id(),
- )
- )
+ 'entity.{{ entity_name }}.edit_form',
+ ['{{ entity_name }}' => $entity->id()]
);
return $row + parent::buildRow($entity);
}
diff --git a/templates/module/src/plugin-type-annotation-manager.php.twig b/templates/module/src/plugin-type-annotation-manager.php.twig
index f8645554b..2ed39b5df 100644
--- a/templates/module/src/plugin-type-annotation-manager.php.twig
+++ b/templates/module/src/plugin-type-annotation-manager.php.twig
@@ -22,7 +22,7 @@ class {{ class_name }}Manager extends DefaultPluginManager {% endblock %}
{% block class_methods %}
/**
- * Constructor for {{ class_name }}Manager objects.
+ * Constructs a new {{ class_name }}Manager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
diff --git a/templates/module/src/service-interface.php.twig b/templates/module/src/service-interface.php.twig
index 6177ec8da..9989f83e4 100644
--- a/templates/module/src/service-interface.php.twig
+++ b/templates/module/src/service-interface.php.twig
@@ -11,7 +11,5 @@ namespace Drupal\{{module}};
{% block interface_declaration %}
/**
* Interface {{ interface }}.
- *
- * @package Drupal\{{module}}
*/
interface {{ interface }} {% endblock %}
diff --git a/templates/module/src/service.php.twig b/templates/module/src/service.php.twig
index 2deb9d3eb..1347bfa56 100644
--- a/templates/module/src/service.php.twig
+++ b/templates/module/src/service.php.twig
@@ -10,13 +10,11 @@ namespace Drupal\{{module}};{% endblock %}
{% block class_declaration %}
/**
* Class {{ class }}.
- *
- * @package Drupal\{{module}}
*/
class {{ class }}{% if(interface is defined and interface) %} implements {{ interface }}{% endif %} {% endblock %}
{% block class_construct %}
/**
- * Constructor.
+ * Constructs a new {{ class }} object.
*/
public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
{{ serviceClassInitialization(services) }}
diff --git a/templates/module/src/yaml-plugin-manager.php.twig b/templates/module/src/yaml-plugin-manager.php.twig
index 81e6442b7..16d486bc5 100644
--- a/templates/module/src/yaml-plugin-manager.php.twig
+++ b/templates/module/src/yaml-plugin-manager.php.twig
@@ -28,14 +28,14 @@ class {{ plugin_class }}Manager extends DefaultPluginManager implements {{ plugi
*
* @var array
*/
- protected $defaults = array(
+ protected $defaults = [
// Add required and optional plugin properties.
'id' => '',
'label' => '',
- );
+ ];
/**
- * Constructs a {{ plugin_class }}Manager object.
+ * Constructs a new {{ plugin_class }}Manager object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
@@ -45,7 +45,7 @@ class {{ plugin_class }}Manager extends DefaultPluginManager implements {{ plugi
public function __construct(ModuleHandlerInterface $module_handler, CacheBackendInterface $cache_backend) {
// Add more services as required.
$this->moduleHandler = $module_handler;
- $this->setCacheBackend($cache_backend, '{{ plugin_name }}', array('{{ plugin_name }}'));
+ $this->setCacheBackend($cache_backend, '{{ plugin_name }}', ['{{ plugin_name }}']);
}
/**
diff --git a/templates/module/twig-template-file.twig b/templates/module/twig-template-file.twig
new file mode 100644
index 000000000..91e43c8f8
--- /dev/null
+++ b/templates/module/twig-template-file.twig
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/templates/module/src/update.php.twig b/templates/module/update.php.twig
similarity index 79%
rename from templates/module/src/update.php.twig
rename to templates/module/update.php.twig
index 431304d43..2f8d005f1 100644
--- a/templates/module/src/update.php.twig
+++ b/templates/module/update.php.twig
@@ -1,10 +1,12 @@
{% block file_methods %}
+{% if not file_exists %}
+{% include 'module/php_tag.php.twig' %}
+{% endif %}
/**
* Implements hook_update_N() on Module {{ module }} Update # {{ update_number }}.
*/
function {{ module }}_update_{{ update_number }}(&$sandbox) {
drupal_set_message('Module {{ module }} Update # {{ update_number }} () was executed successfully.');
}
-{% endblock %}
-
+{% endblock %}
diff --git a/templates/profile/info.yml.twig b/templates/profile/info.yml.twig
index 31d0472e2..385baa630 100644
--- a/templates/profile/info.yml.twig
+++ b/templates/profile/info.yml.twig
@@ -14,3 +14,10 @@ dependencies:
- {{ dependency }}
{% endfor %}
{% endif %}
+{% if themes %}
+
+themes:
+{% for theme in themes %}
+ - {{ theme }}
+{% endfor %}
+{% endif %}
diff --git a/templates/theme/info.yml.twig b/templates/theme/info.yml.twig
index e711e06cf..f68e9fb7e 100644
--- a/templates/theme/info.yml.twig
+++ b/templates/theme/info.yml.twig
@@ -5,7 +5,11 @@ package: {{ package }}
core: {{ core }}
libraries:
- {{ machine_name }}/{{ global_library }}
-
+{% if libraries %}
+{% for library in libraries %}
+ - {{ machine_name }}/{{ library.library_name }}
+{% endfor %}
+{% endif %}
base theme: {{ base_theme }}
{% if base_theme == 'classy' %}
#Using Classy as a base theme https://www.drupal.org/theme-guide/8/classy
diff --git a/templates/theme/libraries.yml.twig b/templates/theme/libraries.yml.twig
new file mode 100644
index 000000000..8d2379ea6
--- /dev/null
+++ b/templates/theme/libraries.yml.twig
@@ -0,0 +1,16 @@
+{{ global_library }}:
+ version: 1.0
+ css:
+ theme:
+ #css/your_style_sheet.css : {}
+ js:
+ #js/your_js.js : {}
+{% for library in libraries %}
+{{ library.library_name }}:
+ version: {{ library.library_version }}
+ css:
+ theme:
+ #js/your_js.js : {}
+ js:
+ #js/your_js.js : {}
+{% endfor %}
\ No newline at end of file
diff --git a/services-drupal-install.yml b/uninstall.services.yml
similarity index 66%
rename from services-drupal-install.yml
rename to uninstall.services.yml
index 50ece8702..c1835417a 100644
--- a/services-drupal-install.yml
+++ b/uninstall.services.yml
@@ -1,13 +1,10 @@
services:
- # Installer services
- console.root:
- class: SplString
console.site:
class: Drupal\Console\Utils\Site
- arguments: ['@app.root']
+ arguments: ['@app.root', '@console.configuration_manager']
console.extension_manager:
class: Drupal\Console\Extension\Manager
- arguments: ['@console.site', '@app.root']
+ arguments: ['@console.site', '@http_client', '@app.root']
console.server:
class: Drupal\Console\Command\ServerCommand
arguments: ['@app.root', '@console.configuration_manager']
@@ -18,3 +15,10 @@ services:
arguments: ['@console.extension_manager', '@console.site', '@console.configuration_manager', '@app.root']
tags:
- { name: drupal.command }
+ console.multisite_new:
+ class: Drupal\Console\Command\Multisite\NewCommand
+ arguments: ['@app.root']
+ tags:
+ - { name: drupal.command }
+ http_client:
+ class: GuzzleHttp\Client