openquestions-1.0.x-dev/src/Form/OqApplicationHistoryForm.php
src/Form/OqApplicationHistoryForm.php
<?php
namespace Drupal\openquestions\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for the oq application history entity edit forms.
*/
class OqApplicationHistoryForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$result = parent::save($form, $form_state);
$entity = $this->getEntity();
$message_arguments = ['%label' => $entity->toLink()->toString()];
$logger_arguments = [
'%label' => $entity->label(),
'link' => $entity->toLink($this->t('View'))->toString(),
];
switch ($result) {
case SAVED_NEW:
$this->messenger()->addStatus($this->t('New oq application history %label has been created.', $message_arguments));
$this->logger('openquestions')->notice('Created new oq application history %label', $logger_arguments);
break;
case SAVED_UPDATED:
$this->messenger()->addStatus($this->t('The oq application history %label has been updated.', $message_arguments));
$this->logger('openquestions')->notice('Updated oq application history %label.', $logger_arguments);
break;
}
$form_state->setRedirect('entity.oq_application_history.canonical', ['oq_application_history' => $entity->id()]);
return $result;
}
}
