sports_league-8.x-1.x-dev/modules/sl_standings/src/Form/SLStandingsRostersForm.php

modules/sl_standings/src/Form/SLStandingsRostersForm.php
<?php

declare(strict_types=1);

namespace Drupal\sl_standings\Form;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for the sl standings rosters entity edit forms.
 */
final class SLStandingsRostersForm extends ContentEntityForm {

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state): int {
    $result = parent::save($form, $form_state);

    $message_args = ['%label' => $this->entity->toLink()->toString()];
    $logger_args = [
      '%label' => $this->entity->label(),
      'link' => $this->entity->toLink($this->t('View'))->toString(),
    ];

    switch ($result) {
      case SAVED_NEW:
        $this->messenger()->addStatus($this->t('New sl standings rosters %label has been created.', $message_args));
        $this->logger('sl_standings_rosters')->notice('New sl standings rosters %label has been created.', $logger_args);
        break;

      case SAVED_UPDATED:
        $this->messenger()->addStatus($this->t('The sl standings rosters %label has been updated.', $message_args));
        $this->logger('sl_standings_rosters')->notice('The sl standings rosters %label has been updated.', $logger_args);
        break;

      default:
        throw new \LogicException('Could not save the entity.');
    }

    $form_state->setRedirectUrl($this->entity->toUrl('collection'));

    return $result;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc