podcast_publisher-1.0.0-alpha3/src/Form/PodcastForm.php
src/Form/PodcastForm.php
<?php
namespace Drupal\podcast_publisher\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for the podcast entity edit forms.
*/
class PodcastForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->getEntity();
$result = $entity->save();
$link = $entity->toLink($this->t('View'))->toRenderable();
$message_arguments = ['%label' => $this->entity->label()];
$logger_arguments = $message_arguments + ['link' => \Drupal::service('renderer')->render($link)];
if ($result == SAVED_NEW) {
$this->messenger()->addStatus($this->t('New podcast %label has been created.', $message_arguments));
$this->logger('podcast_publisher')->notice('Created new podcast %label', $logger_arguments);
}
else {
$this->messenger()->addStatus($this->t('The podcast %label has been updated.', $message_arguments));
$this->logger('podcast_publisher')->notice('Updated new podcast %label.', $logger_arguments);
}
$form_state->setRedirect('entity.podcast.canonical', ['podcast' => $entity->id()]);
}
}
