comparison core/modules/media/src/MediaForm.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 1fec387a4317
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
57 /** 57 /**
58 * {@inheritdoc} 58 * {@inheritdoc}
59 */ 59 */
60 public function save(array $form, FormStateInterface $form_state) { 60 public function save(array $form, FormStateInterface $form_state) {
61 $saved = parent::save($form, $form_state); 61 $saved = parent::save($form, $form_state);
62 $context = ['@type' => $this->entity->bundle(), '%label' => $this->entity->label()]; 62 $context = ['@type' => $this->entity->bundle(), '%label' => $this->entity->label(), 'link' => $this->entity->toLink($this->t('View'))->toString()];
63 $logger = $this->logger('media'); 63 $logger = $this->logger('media');
64 $t_args = ['@type' => $this->entity->bundle->entity->label(), '%label' => $this->entity->label()]; 64 $t_args = ['@type' => $this->entity->bundle->entity->label(), '%label' => $this->entity->toLink($this->entity->label())->toString()];
65 65
66 if ($saved === SAVED_NEW) { 66 if ($saved === SAVED_NEW) {
67 $logger->notice('@type: added %label.', $context); 67 $logger->notice('@type: added %label.', $context);
68 drupal_set_message($this->t('@type %label has been created.', $t_args)); 68 $this->messenger()->addStatus($this->t('@type %label has been created.', $t_args));
69 } 69 }
70 else { 70 else {
71 $logger->notice('@type: updated %label.', $context); 71 $logger->notice('@type: updated %label.', $context);
72 drupal_set_message($this->t('@type %label has been updated.', $t_args)); 72 $this->messenger()->addStatus($this->t('@type %label has been updated.', $t_args));
73 } 73 }
74 74
75 $form_state->setRedirectUrl($this->entity->toUrl('canonical')); 75 // Redirect the user to the media overview if the user has the 'access media
76 // overview' permission. If not, redirect to the canonical URL of the media
77 // item.
78 if ($this->currentUser()->hasPermission('access media overview')) {
79 $form_state->setRedirectUrl($this->entity->toUrl('collection'));
80 }
81 else {
82 $form_state->setRedirectUrl($this->entity->toUrl());
83 }
84
76 return $saved; 85 return $saved;
77 } 86 }
78 87
79 } 88 }