public function ApiDocForm::save in Apigee API Catalog 8
Form submission handler for the 'save' action.
Normally this method should be overridden to provide specific messages to the user and redirect the form after the entity has been saved.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Overrides EntityForm::save
File
- src/
Entity/ Form/ ApiDocForm.php, line 85
Class
- ApiDocForm
- Form controller for API Doc edit forms.
Namespace
Drupal\apigee_api_catalog\Entity\FormCode
public function save(array $form, FormStateInterface $form_state) {
$entity = $this
->getEntity();
$insert = $entity
->isNew();
parent::save($form, $form_state);
$singular_label = $this->entity
->getEntityType()
->getSingularLabel();
if ($insert) {
$this
->messenger()
->addMessage($this
->t('Created the %label @entity_type_label.', [
'%label' => $entity
->label(),
'@entity_type_label' => $singular_label,
]));
}
else {
$this
->messenger()
->addMessage($this
->t('Saved the %label @entity_type_label.', [
'%label' => $entity
->label(),
'@entity_type_label' => $singular_label,
]));
}
$form_state
->setRedirect('entity.apidoc.collection');
}