Commit da3c0f7c authored by s_leu's avatar s_leu Committed by Andrei Mateescu
Browse files

Issue #3315048: Drop adding/editing of wse_config via enity form

parent e6464d48
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ use Drupal\wse_config\WseConfigInterface;
 *     "views_data" = "Drupal\views\EntityViewsData",
 *     "access" = "Drupal\wse_config\WseConfigAccessControlHandler",
 *     "form" = {
 *       "add" = "Drupal\wse_config\Form\WseConfigForm",
 *       "edit" = "Drupal\wse_config\Form\WseConfigForm",
 *       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm"
 *     },
 *     "route_provider" = {
@@ -51,9 +49,7 @@ use Drupal\wse_config\WseConfigInterface;
 *     "revision_log_message" = "revision_log_message"
 *   },
 *   links = {
 *     "add-form" = "/admin/config/development/configuration/config-content/add",
 *     "canonical" = "/wse-config/{wse_config}",
 *     "edit-form" = "/admin/config/development/configuration/config-content/{wse_config}/edit",
 *     "delete-form" = "/admin/config/development/configuration/config-content/{wse_config}/delete",
 *     "collection" = "/admin/config/development/configuration/config-content"
 *   },
+0 −37
Original line number Diff line number Diff line
<?php

namespace Drupal\wse_config\Form;

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

/**
 * Form controller for the wse_config entity edit forms.
 */
class WseConfigForm 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' => render($link)];

    if ($result == SAVED_NEW) {
      $this->messenger()->addStatus($this->t('New wse config %label has been created.', $message_arguments));
      $this->logger('wse_config')->notice('Created new wse config %label', $logger_arguments);
    }
    else {
      $this->messenger()->addStatus($this->t('The wse config %label has been updated.', $message_arguments));
      $this->logger('wse_config')->notice('Updated new wse config %label.', $logger_arguments);
    }

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

}
+0 −5
Original line number Diff line number Diff line
wse_config.add_form:
  route_name: entity.wse_config.add_form
  title: 'Add workspace config'
  appears_on:
    - entity.wse_config.collection
+0 −4
Original line number Diff line number Diff line
@@ -2,10 +2,6 @@ entity.wse_config.view:
  title: View
  route_name: entity.wse_config.canonical
  base_route: entity.wse_config.canonical
entity.wse_config.edit_form:
  title: Edit
  route_name: entity.wse_config.edit_form
  base_route: entity.wse_config.canonical
entity.wse_config.delete_form:
  title: Delete
  route_name: entity.wse_config.delete_form