/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $linkit_profile = $this->entity; // Prevent leading and trailing spaces in linkit profile labels. $linkit_profile->set('label', trim($linkit_profile->label())); $status = $linkit_profile->save(); $edit_link = $this->entity->link($this->t('Edit')); switch ($status) { case SAVED_NEW: drupal_set_message($this->t('Created new profile %label.', ['%label' => $linkit_profile->label()])); $this->logger('linkit')->notice('Created new profile %label.', ['%label' => $linkit_profile->label(), 'link' => $edit_link]); $form_state->setRedirect('linkit.matchers', [ 'linkit_profile' => $linkit_profile->id(), ]); break; case SAVED_UPDATED: drupal_set_message($this->t('Updated profile %label.', ['%label' => $linkit_profile->label()])); $this->logger('linkit')->notice('Updated profile %label.', ['%label' => $linkit_profile->label(), 'link' => $edit_link]); $form_state->setRedirectUrl($linkit_profile->urlInfo('edit-form')); break; } }