Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
novicell/custom_forms / src / Routing / CustomFormSubmissionHandlerHtmlRouteProvider.php
Size: Mime:
<?php

namespace Drupal\custom_forms\Routing;

use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;

/**
 * Class CustomFormSubmissionHandlerHtmlRouteProvider
 *
 * Adds additional routes for custom forms.
 *
 * @package Drupal\custom_forms\Routing
 */
class CustomFormSubmissionHandlerHtmlRouteProvider extends AdminHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    $entity_type_id = $entity_type->id();

    $route = (new Route('/admin/custom_forms/{custom_form}/handlers/{custom_form_submission_handler}/delete'))
      ->addDefaults([
        '_entity_form' => 'custom_form_submission_handler.delete',
        '_title' => 'Delete',
      ])
      ->setRequirement('custom_form', '\d+')
      ->setRequirement('_entity_access', 'custom_form_submission_handler.delete')
      ->setOptions([
        'parameters' => [
          'custom_form' => ['type' => 'entity:custom_form'],
          'custom_form_submission_handler' => ['type' => 'entity:custom_form_submission_handler'],
        ],
        '_admin_route' => TRUE
      ]);
    $collection->add('entity.custom_form_submission_handler.delete_form', $route);

    $route = (new Route('/admin/custom_forms/{custom_form}/handlers/{custom_form_submission_handler}/settings'))
      ->setDefaults([
        '_entity_form' => 'custom_form_submission_handler.edit',
        '_title' => 'Edit submission handler',
        '_title_callback' => '\Drupal\custom_forms\Controller\CustomFormController::handlerTitle'
      ])
      ->setRequirement('_entity_access', 'custom_form_submission_handler.update')
      ->setRequirement('custom_form', '\d+')
      ->setOptions([
        'parameters' => [
          'custom_form' => ['type' => 'entity:custom_form'],
          'custom_form_submission_handler' => ['type' => 'entity:custom_form_submission_handler'],
        ],
        '_admin_route' => TRUE
      ]);
    $collection->add('entity.custom_form_submission_handler.edit_form', $route);

    return $collection;
  }

  /**
   * @inheritDoc
   */
  protected function getAddFormRoute(EntityTypeInterface $entity_type) {
    if ($route = parent::getAddFormRoute($entity_type)) {
      $parameters = $route->getOption('parameters');
      $parameters['custom_form'] = ['type' => 'entity:custom_form'];
      $route->setOption('parameters', $parameters);
      return $route;
    }
  }

}