Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 25 |
|
0.00% |
0 / 11 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ProfileRouteProvider | |
0.00% |
0 / 25 |
|
0.00% |
0 / 11 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 2 |
56 | |
0.00% |
0 / 1 |
| getRoutes | |
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| getEditPluginFormRoute | |
0.00% |
0 / 20 |
|
0.00% |
0 / 8 |
|
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
30 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder\Routing; |
| 6 | |
| 7 | use Drupal\Core\Entity\EntityTypeInterface; |
| 8 | use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider; |
| 9 | use Symfony\Component\Routing\Route; |
| 10 | |
| 11 | /** |
| 12 | * Provides routes for display builder entities. |
| 13 | */ |
| 14 | class 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 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 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; |
| 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') { |
| 66 | return $route; |
| 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')) { |
| 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; |
| 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')) { |
| 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') { |
| 66 | return $route; |
| 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'))) { |
| 69 | return NULL; |
| 39 | protected function getEditPluginFormRoute(EntityTypeInterface $entity_type): ?Route { |
| 40 | if ($entity_type->hasLinkTemplate('edit-plugin-form') |
| 69 | return NULL; |
| 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; |
| 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)) { |
| 27 | return $collection; |