cc-1.0.x-dev/modules/cc_account/src/Form/CcAccountForm.php

modules/cc_account/src/Form/CcAccountForm.php
<?php

namespace Drupal\cc_account\Form;

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

/**
 * Form controller for the cryptocurrency account edit forms.
 */
class CcAccountForm extends ContentEntityForm {

  /**
   * {@inheritdoc}
   */
  public function save(array $form, FormStateInterface $form_state) {
    $result = parent::save($form, $form_state);
    $entity = $this->getEntity();

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

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

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

    $form_state->setRedirect('entity.cc_account.canonical', ['cc_account' => $entity->id()]);

    return $result;
  }

}

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

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