Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[template] Replace deprecated drupal_set_message #3867

Merged
merged 1 commit into from May 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion templates/module/post-update.php.twig
Expand Up @@ -6,7 +6,7 @@
* Implements hook_post_update_NAME() on Module {{ module }} Post Update {{ post_update_name }}.
*/
function {{ module }}_post_update_{{ post_update_name }}(&$sandbox) {
drupal_set_message('Module {{ module }} Post Update # {{ post_update_name }} () was executed successfully.');
\Drupal::messenger()->addMessage('Module {{ module }} Post Update # {{ post_update_name }} () was executed successfully.');
}

{% endblock %}
Expand Up @@ -116,7 +116,7 @@ class {{ entity_class }}RevisionDeleteForm extends ConfirmFormBase {% endblock %
$this->{{ entity_class }}Storage->deleteRevision($this->revision->getRevisionId());

$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()]));
\Drupal::messenger()->addMessage(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',
['{{ entity_name }}' => $this->revision->id()]
Expand Down
Expand Up @@ -129,7 +129,7 @@ class {{ entity_class }}RevisionRevertForm extends ConfirmFormBase {% endblock %
$this->revision->save();

$this->logger('content')->notice('{{ label }}: reverted %title revision %revision.', ['%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
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)]));
\Drupal::messenger()->addMessage(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',
['{{ entity_name }}' => $this->revision->id()]
Expand Down
4 changes: 2 additions & 2 deletions templates/module/src/Entity/Form/entity-content.php.twig
Expand Up @@ -68,13 +68,13 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %}

switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label {{ label }}.', [
\Drupal::messenger()->addMessage($this->t('Created the %label {{ label }}.', [
'%label' => $entity->label(),
]));
break;

default:
drupal_set_message($this->t('Saved the %label {{ label }}.', [
\Drupal::messenger()->addMessage($this->t('Saved the %label {{ label }}.', [
'%label' => $entity->label(),
]));
}
Expand Down
2 changes: 1 addition & 1 deletion templates/module/src/Form/entity-delete.php.twig
Expand Up @@ -47,7 +47,7 @@ class {{ entity_class }}DeleteForm extends EntityConfirmFormBase {% endblock %}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();

drupal_set_message(
\Drupal::messenger()->addMessage(
$this->t('content @type: deleted @label.',
[
'@type' => $this->entity->bundle(),
Expand Down
4 changes: 2 additions & 2 deletions templates/module/src/Form/entity.php.twig
Expand Up @@ -58,13 +58,13 @@ class {{ entity_class }}Form extends EntityForm {% endblock %}

switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label {{ label }}.', [
\Drupal::messenger()->addMessage($this->t('Created the %label {{ label }}.', [
'%label' => ${{ entity_name | machine_name }}->label(),
]));
break;

default:
drupal_set_message($this->t('Saved the %label {{ label }}.', [
\Drupal::messenger()->addMessage($this->t('Saved the %label {{ label }}.', [
'%label' => ${{ entity_name | machine_name }}->label(),
]));
}
Expand Down
4 changes: 2 additions & 2 deletions templates/module/src/Form/form-alter.php.twig
Expand Up @@ -12,15 +12,15 @@ use Drupal\Core\Form\FormStateInterface;
{% endif %}
*/
function {{ module }}_form_{{ form_id }}_alter(&$form, FormStateInterface $form_state) {
drupal_set_message('{{ module }}_form_{{ form_id }}_alter() executed.');
\Drupal::messenger()->addMessage('{{ module }}_form_{{ form_id }}_alter() executed.');
{% else %}
/**
* Implements hook_form_alter() on behalf of {{ module }}.module.
*/
function {{ module }}_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Change form id here
if ($form_id == 'form_test_alter_form') {
drupal_set_message('form_test_form_alter() executed.');
\Drupal::messenger()->addMessage('form_test_form_alter() executed.');
{% endif %}

{%- if metadata.unset -%}
Expand Down
2 changes: 1 addition & 1 deletion templates/module/src/Form/form.php.twig
Expand Up @@ -108,7 +108,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::messenger()->addMessage($key . ': ' . $value);
}

}
Expand Down
2 changes: 1 addition & 1 deletion templates/module/src/cache-context.php.twig
Expand Up @@ -35,7 +35,7 @@ class {{ class }} implements CacheContextInterface {% endblock %}
* {@inheritdoc}
*/
public static function getLabel() {
drupal_set_message('Lable of cache context');
\Drupal::messenger()->addMessage('Lable of cache context');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion templates/module/src/event-subscriber.php.twig
Expand Up @@ -50,7 +50,7 @@ class {{ class }} implements EventSubscriberInterface {% endblock %}
* @param GetResponseEvent $event
*/
public function {{ callback }}(Event $event) {
drupal_set_message('Event {{ event_name }} thrown by Subscriber in module {{ module }}.', 'status', TRUE);
\Drupal::messenger()->addMessage('Event {{ event_name }} thrown by Subscriber in module {{ module }}.', 'status', TRUE);
}
{% endfor %}
{% endblock %}
2 changes: 1 addition & 1 deletion templates/module/update.php.twig
Expand Up @@ -6,7 +6,7 @@
* 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.');
\Drupal::messenger()->addMessage('Module {{ module }} Update # {{ update_number }} () was executed successfully.');
}

{% endblock %}