You are here

class CommentDeleteSubmitter in Comment Delete 8

Submit callback handler for deleting comment.

@package Drupal\comment_delete

Hierarchy

  • class \Drupal\Component\DependencyInjection\Container implements \Symfony\Component\DependencyInjection\ContainerInterface

Expanded class hierarchy of CommentDeleteSubmitter

1 file declares its use of CommentDeleteSubmitter
comment_delete.module in ./comment_delete.module
comment_delete.module

File

src/CommentDeleteSubmitter.php, line 13

Namespace

Drupal\comment_delete
View source
class CommentDeleteSubmitter extends Container {

  /**
   * Submit handler for the comment delete form.
   *
   * @param array $form
   *   The form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   */
  public static function submitForm(array &$form, FormStateInterface $form_state) {

    /** @var \Drupal\comment_delete\CommentDeleteManager $comment_delete_manager */
    $comment_delete_manager = \Drupal::service('comment_delete.manager');

    /** @var \Drupal\comment\Form\DeleteForm $form_object */
    $form_object = $form_state
      ->getFormObject();

    /** @var \Drupal\comment\Entity\Comment $comment */
    $comment = $form_object
      ->getEntity();
    $comment_delete_manager
      ->delete($comment, $form_state
      ->getValue('delete_operation'));
    if ($comment_delete_manager
      ->isAjaxRequest()) {

      // No redirect on Ajax request. Presumably the module or custom
      // integration adding Ajax support to comments handles the Ajax response.
      $form_state
        ->disableRedirect();
    }
    else {
      $entity_type = $comment
        ->getCommentedEntityTypeId();
      $form_state
        ->setRedirect("entity.{$entity_type}.canonical", [
        $entity_type => $comment
          ->getCommentedEntityId(),
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommentDeleteSubmitter::submitForm public static function Submit handler for the comment delete form.
Container::$aliases protected property The aliases of the container.
Container::$frozen protected property Whether the container parameters can still be changed.
Container::$loading protected property The currently loading services.
Container::$parameters protected property The parameters of the container.
Container::$privateServices protected property The instantiated private services.
Container::$serviceDefinitions protected property The service definitions of the container.
Container::$services protected property The instantiated services.
Container::createService protected function Creates a service from a service definition. 1
Container::get public function Gets a service. 2
Container::getAlternatives protected function Provides alternatives for a given array and key.
Container::getParameter public function Gets a parameter.
Container::getParameterAlternatives protected function Provides alternatives in case a parameter was not found.
Container::getServiceAlternatives protected function Provides alternatives in case a service was not found.
Container::getServiceIds public function Gets all defined service IDs.
Container::has public function Returns true if the given service is defined.
Container::hasParameter public function Checks if a parameter exists.
Container::initialized public function
Container::reset public function Resets shared services from the container.
Container::resolveServicesAndParameters protected function Resolves arguments that represent services or variables to the real values. 1
Container::set public function Sets a service. Overrides Container::set
Container::setParameter public function Sets a parameter.
Container::__clone private function Ensure that cloning doesn't work.
Container::__construct public function Constructs a new Container instance. 1
Container::__sleep public function