Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (30 sloc) 1.09 KB
<?php
namespace Drupal\simple\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Class SimpleEntityForm
*/
class SimpleEntityForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = &$this->entity;
$message_params = [
'%entity_label' => $entity->id(),
'%content_entity_label' => $entity->getEntityType()->getLabel()->render(),
'%bundle_label' => $entity->bundle->entity->label(),
];
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %bundle_label - %content_entity_label entity: %entity_label.', $message_params ));
break;
default:
drupal_set_message($this->t('Saved the %bundle_label - %content_entity_label entity: %entity_label.', $message_params));
}
$content_entity_id = $entity->getEntityType()->id();
$form_state->setRedirect("entity.{$content_entity_id}.canonical", [$content_entity_id => $entity->id()]);
}
}