X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Fmedia%2Fsrc%2FMediaForm.php;h=45cff5fdca5dfbf837ba20f4f448fd5908debeb8;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=dd6b3fd2ad8b36dd8a54fe786c0aee5ba207a9d2;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/modules/media/src/MediaForm.php b/web/core/modules/media/src/MediaForm.php index dd6b3fd2a..45cff5fdc 100644 --- a/web/core/modules/media/src/MediaForm.php +++ b/web/core/modules/media/src/MediaForm.php @@ -59,20 +59,29 @@ class MediaForm extends ContentEntityForm { */ public function save(array $form, FormStateInterface $form_state) { $saved = parent::save($form, $form_state); - $context = ['@type' => $this->entity->bundle(), '%label' => $this->entity->label()]; + $context = ['@type' => $this->entity->bundle(), '%label' => $this->entity->label(), 'link' => $this->entity->toLink($this->t('View'))->toString()]; $logger = $this->logger('media'); - $t_args = ['@type' => $this->entity->bundle->entity->label(), '%label' => $this->entity->label()]; + $t_args = ['@type' => $this->entity->bundle->entity->label(), '%label' => $this->entity->toLink($this->entity->label())->toString()]; if ($saved === SAVED_NEW) { $logger->notice('@type: added %label.', $context); - drupal_set_message($this->t('@type %label has been created.', $t_args)); + $this->messenger()->addStatus($this->t('@type %label has been created.', $t_args)); } else { $logger->notice('@type: updated %label.', $context); - drupal_set_message($this->t('@type %label has been updated.', $t_args)); + $this->messenger()->addStatus($this->t('@type %label has been updated.', $t_args)); + } + + // Redirect the user to the media overview if the user has the 'access media + // overview' permission. If not, redirect to the canonical URL of the media + // item. + if ($this->currentUser()->hasPermission('access media overview')) { + $form_state->setRedirectUrl($this->entity->toUrl('collection')); + } + else { + $form_state->setRedirectUrl($this->entity->toUrl()); } - $form_state->setRedirectUrl($this->entity->toUrl('canonical')); return $saved; }