l10n_server-2.x-dev/l10n_server/src/Form/L10nServerErrorForm.php

l10n_server/src/Form/L10nServerErrorForm.php
<?php

declare(strict_types=1);

namespace Drupal\l10n_server\Form;

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

/**
 * Form controller for the error entity edit forms.
 */
class L10nServerErrorForm extends ContentEntityForm {

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

    $entity = $this->getEntity();

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

    switch ($result) {
      case SAVED_NEW:
        $this->messenger()->addStatus($this->t('New error %label has been created.', $message_arguments));
        $this->logger('l10n_server')->notice('Created new error %label', $logger_arguments);
        break;

      case SAVED_UPDATED:
        $this->messenger()->addStatus($this->t('The error %label has been updated.', $message_arguments));
        $this->logger('l10n_server')->notice('Updated error %label.', $logger_arguments);
        break;
    }

    $form_state->setRedirect('entity.l10n_server_error.collection');

    return $result;
  }

}

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

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