Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
ProfileRouteProvider
0.00% covered (danger)
0.00%
0 / 25
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 2
56
0.00% covered (danger)
0.00%
0 / 1
 getRoutes
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 getEditPluginFormRoute
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
30
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder\Routing;
6
7use Drupal\Core\Entity\EntityTypeInterface;
8use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
9use Symfony\Component\Routing\Route;
10
11/**
12 * Provides routes for display builder entities.
13 */
14class ProfileRouteProvider extends AdminHtmlRouteProvider {
15
16  /**
17   * {@inheritdoc}
18   */
19  public function getRoutes(EntityTypeInterface $entity_type) {
20    $collection = parent::getRoutes($entity_type);
21    $entity_type_id = $entity_type->id();
22
23    if ($add_page_route = $this->getEditPluginFormRoute($entity_type)) {
24      $collection->add("entity.{$entity_type_id}.edit_plugin_form", $add_page_route);
25    }
26
27    return $collection;
28  }
29
30  /**
31   * Gets the edit-plugin-form route.
32   *
33   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
34   *   The entity type.
35   *
36   * @return \Symfony\Component\Routing\Route|null
37   *   The generated route, if available.
38   */
39  protected function getEditPluginFormRoute(EntityTypeInterface $entity_type): ?Route {
40    if ($entity_type->hasLinkTemplate('edit-plugin-form')
41      && \is_string($entity_type->getLinkTemplate('edit-plugin-form'))) {
42      $entity_type_id = $entity_type->id();
43      $route = new Route($entity_type->getLinkTemplate('edit-plugin-form'));
44      // Use the edit form handler, if available, otherwise default.
45      $operation = 'default';
46
47      if ($entity_type->getFormClass('edit-plugin')) {
48        $operation = 'edit-plugin';
49      }
50      $route
51        ->setDefaults([
52          '_entity_form' => "{$entity_type_id}.{$operation}",
53          '_title_callback' => '\Drupal\display_builder\Form\ProfileIslandPluginForm::editFormTitle',
54        ])
55        ->setRequirement('_entity_access', "{$entity_type_id}.update")
56        ->setOption('parameters', [
57          $entity_type_id => ['type' => 'entity:' . $entity_type_id],
58        ]);
59
60      // Entity types with serial IDs can specify this in their route
61      // requirements, improving the matching process.
62      if ($this->getEntityTypeIdKeyType($entity_type) === 'integer') {
63        $route->setRequirement($entity_type_id, '\d+');
64      }
65
66      return $route;
67    }
68
69    return NULL;
70  }
71
72}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

ProfileRouteProvider->getEditPluginFormRoute
39  protected function getEditPluginFormRoute(EntityTypeInterface $entity_type): ?Route {
40    if ($entity_type->hasLinkTemplate('edit-plugin-form')
41      && \is_string($entity_type->getLinkTemplate('edit-plugin-form'))) {
42      $entity_type_id = $entity_type->id();
43      $route = new Route($entity_type->getLinkTemplate('edit-plugin-form'));
44      // Use the edit form handler, if available, otherwise default.
45      $operation = 'default';
46
47      if ($entity_type->getFormClass('edit-plugin')) {
48        $operation = 'edit-plugin';
49      }
50      $route
51        ->setDefaults([
51        ->setDefaults([
52          '_entity_form' => "{$entity_type_id}.{$operation}",
53          '_title_callback' => '\Drupal\display_builder\Form\ProfileIslandPluginForm::editFormTitle',
54        ])
55        ->setRequirement('_entity_access', "{$entity_type_id}.update")
56        ->setOption('parameters', [
57          $entity_type_id => ['type' => 'entity:' . $entity_type_id],
58        ]);
59
60      // Entity types with serial IDs can specify this in their route
61      // requirements, improving the matching process.
62      if ($this->getEntityTypeIdKeyType($entity_type) === 'integer') {
63        $route->setRequirement($entity_type_id, '\d+');
64      }
65
66      return $route;
66      return $route;
69    return NULL;
ProfileRouteProvider->getRoutes
19  public function getRoutes(EntityTypeInterface $entity_type) {
20    $collection = parent::getRoutes($entity_type);
21    $entity_type_id = $entity_type->id();
22
23    if ($add_page_route = $this->getEditPluginFormRoute($entity_type)) {
24      $collection->add("entity.{$entity_type_id}.edit_plugin_form", $add_page_route);
25    }
26
27    return $collection;
27    return $collection;