Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| PageLayoutHook | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| entityOperationAlter | |
0.00% |
0 / 14 |
|
0.00% |
0 / 5 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder_page_layout\Hook; |
| 6 | |
| 7 | use Drupal\Core\Entity\EntityInterface; |
| 8 | use Drupal\Core\Hook\Attribute\Hook; |
| 9 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
| 10 | use Drupal\display_builder\InstanceInterface; |
| 11 | use Drupal\display_builder_page_layout\Plugin\display_builder\Buildable\PageLayout; |
| 12 | |
| 13 | /** |
| 14 | * Hook implementations for the display_builder_page_layout module. |
| 15 | */ |
| 16 | class PageLayoutHook { |
| 17 | |
| 18 | /** |
| 19 | * Implements hook_entity_operation_alter(). |
| 20 | * |
| 21 | * @param array $operations |
| 22 | * An associative array of operations. |
| 23 | * @param \Drupal\Core\Entity\EntityInterface $entity |
| 24 | * The entity for which the operations are being altered. |
| 25 | */ |
| 26 | #[Hook('entity_operation_alter')] |
| 27 | public function entityOperationAlter(array &$operations, EntityInterface $entity): void { |
| 28 | if (!$entity instanceof InstanceInterface) { |
| 29 | return; |
| 30 | } |
| 31 | $id = (string) $entity->id(); |
| 32 | |
| 33 | if (\str_starts_with($id, PageLayout::getPrefix())) { |
| 34 | $operations['build'] = [ |
| 35 | 'title' => new TranslatableMarkup('Build display'), |
| 36 | 'url' => PageLayout::getUrlFromInstanceId($id), |
| 37 | 'weight' => -1, |
| 38 | ]; |
| 39 | $operations['edit'] = [ |
| 40 | 'title' => new TranslatableMarkup('Edit display'), |
| 41 | 'url' => PageLayout::getDisplayUrlFromInstanceId($id), |
| 42 | 'weight' => 10, |
| 43 | ]; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | } |
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.
| 27 | public function entityOperationAlter(array &$operations, EntityInterface $entity): void { |
| 28 | if (!$entity instanceof InstanceInterface) { |
| 29 | return; |
| 27 | public function entityOperationAlter(array &$operations, EntityInterface $entity): void { |
| 28 | if (!$entity instanceof InstanceInterface) { |
| 31 | $id = (string) $entity->id(); |
| 32 | |
| 33 | if (\str_starts_with($id, PageLayout::getPrefix())) { |
| 35 | 'title' => new TranslatableMarkup('Build display'), |
| 36 | 'url' => PageLayout::getUrlFromInstanceId($id), |
| 37 | 'weight' => -1, |
| 38 | ]; |
| 39 | $operations['edit'] = [ |
| 40 | 'title' => new TranslatableMarkup('Edit display'), |
| 41 | 'url' => PageLayout::getDisplayUrlFromInstanceId($id), |
| 42 | 'weight' => 10, |
| 43 | ]; |
| 44 | } |
| 45 | } |
| 45 | } |
| 27 | public function entityOperationAlter(array &$operations, EntityInterface $entity): void { |
| 28 | if (!$entity instanceof InstanceInterface) { |
| 31 | $id = (string) $entity->id(); |
| 32 | |
| 33 | if (\str_starts_with($id, PageLayout::getPrefix())) { |
| 45 | } |