Skip to content

Commit

Permalink
3956 entity clean up (#3957)
Browse files Browse the repository at this point in the history
* Add new arguments key and target. Make it possible use not only default target for db connections

* Replace drupal_set_message with messenger service

* Fix label
  • Loading branch information
LOBsTerr authored Apr 6, 2019
1 parent 0ca9d6a commit 09114aa
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions templates/module/src/Entity/Form/entity-content.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,11 @@ class {{ entity_class }}Form extends ContentEntityForm {% endblock %}

$status = parent::save($form, $form_state);

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

default:
\Drupal::messenger()->addMessage($this->t('Saved the %label {{ label }}.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.{{ entity_name }}.canonical', ['{{ entity_name }}' => $entity->id()]);
}
{% endblock %}

0 comments on commit 09114aa

Please sign in to comment.