Chris@0: entity->bundle->entity; Chris@0: Chris@0: if ($this->operation === 'edit') { Chris@0: $form['#title'] = $this->t('Edit %type_label @label', [ Chris@0: '%type_label' => $media_type->label(), Chris@0: '@label' => $this->entity->label(), Chris@0: ]); Chris@0: } Chris@0: Chris@0: // Media author information for administrators. Chris@0: if (isset($form['uid']) || isset($form['created'])) { Chris@0: $form['author'] = [ Chris@0: '#type' => 'details', Chris@0: '#title' => $this->t('Authoring information'), Chris@0: '#group' => 'advanced', Chris@0: '#attributes' => [ Chris@0: 'class' => ['media-form-author'], Chris@0: ], Chris@0: '#weight' => 90, Chris@0: '#optional' => TRUE, Chris@0: ]; Chris@0: } Chris@0: Chris@0: if (isset($form['uid'])) { Chris@0: $form['uid']['#group'] = 'author'; Chris@0: } Chris@0: Chris@0: if (isset($form['created'])) { Chris@0: $form['created']['#group'] = 'author'; Chris@0: } Chris@0: Chris@0: $form['#attached']['library'][] = 'media/form'; Chris@0: Chris@0: return $form; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function save(array $form, FormStateInterface $form_state) { Chris@0: $saved = parent::save($form, $form_state); Chris@0: $context = ['@type' => $this->entity->bundle(), '%label' => $this->entity->label()]; Chris@0: $logger = $this->logger('media'); Chris@0: $t_args = ['@type' => $this->entity->bundle->entity->label(), '%label' => $this->entity->label()]; Chris@0: Chris@0: if ($saved === SAVED_NEW) { Chris@0: $logger->notice('@type: added %label.', $context); Chris@0: drupal_set_message($this->t('@type %label has been created.', $t_args)); Chris@0: } Chris@0: else { Chris@0: $logger->notice('@type: updated %label.', $context); Chris@0: drupal_set_message($this->t('@type %label has been updated.', $t_args)); Chris@0: } Chris@0: Chris@0: $form_state->setRedirectUrl($this->entity->toUrl('canonical')); Chris@0: return $saved; Chris@0: } Chris@0: Chris@0: }