Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
DisplayBuilderViewsHook
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 entityOperationAlter
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 5
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
12
 displayBuilderProviderInfo
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder_views\Hook;
6
7use Drupal\Core\Entity\EntityInterface;
8use Drupal\Core\Hook\Attribute\Hook;
9use Drupal\Core\StringTranslation\TranslatableMarkup;
10use Drupal\display_builder\InstanceInterface;
11use Drupal\display_builder_views\Plugin\views\display_extender\DisplayExtender;
12
13/**
14 * Hook implementations for the display_builder_views module.
15 */
16class DisplayBuilderViewsHook {
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
32    $id = (string) $entity->id();
33
34    if (\str_starts_with($id, DisplayExtender::getPrefix())) {
35      $operations['build'] = [
36        'title' => new TranslatableMarkup('Build display'),
37        'url' => DisplayExtender::getUrlFromInstanceId($id),
38        'weight' => -1,
39      ];
40      $operations['edit'] = [
41        'title' => new TranslatableMarkup('Edit view'),
42        'url' => DisplayExtender::getDisplayUrlFromInstanceId($id),
43        'weight' => 10,
44      ];
45    }
46  }
47
48  /**
49   * Implements hook_display_builder_provider_info().
50   *
51   * @return array
52   *   An associative array of display builder providers.
53   */
54  #[Hook('display_builder_provider_info')]
55  public function displayBuilderProviderInfo(): array {
56    return [
57      'views' => [
58        'label' => new TranslatableMarkup('Views'),
59        'class' => DisplayExtender::class,
60        'prefix' => DisplayExtender::getPrefix(),
61      ],
62    ];
63  }
64
65}

Paths

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.

DisplayBuilderViewsHook->displayBuilderProviderInfo
58        'label' => new TranslatableMarkup('Views'),
59        'class' => DisplayExtender::class,
60        'prefix' => DisplayExtender::getPrefix(),
DisplayBuilderViewsHook->entityOperationAlter
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) {
 
32    $id = (string) $entity->id();
33
34    if (\str_starts_with($id, DisplayExtender::getPrefix())) {
 
36        'title' => new TranslatableMarkup('Build display'),
37        'url' => DisplayExtender::getUrlFromInstanceId($id),
38        'weight' => -1,
39      ];
40      $operations['edit'] = [
41        'title' => new TranslatableMarkup('Edit view'),
42        'url' => DisplayExtender::getDisplayUrlFromInstanceId($id),
43        'weight' => 10,
44      ];
45    }
46  }
 
46  }
27  public function entityOperationAlter(array &$operations, EntityInterface $entity): void {
28    if (!$entity instanceof InstanceInterface) {
 
32    $id = (string) $entity->id();
33
34    if (\str_starts_with($id, DisplayExtender::getPrefix())) {
 
46  }