Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
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
IntegrationControllerBase
0.00% covered (danger)
0.00%
0 / 10
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
 __construct
0.00% covered (danger)
0.00%
0 / 1
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
 renderBuilder
0.00% covered (danger)
0.00%
0 / 9
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
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder\Controller;
6
7use Drupal\Core\Controller\ControllerBase;
8use Drupal\Core\DependencyInjection\AutowireTrait;
9use Drupal\display_builder\DisplayBuildableInterface;
10use Drupal\display_builder\DisplayBuildablePluginManager;
11use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
12use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
13
14/**
15 * Shared logic between integrations controllers.
16 */
17abstract class IntegrationControllerBase extends ControllerBase {
18
19  use AutowireTrait;
20
21  /**
22   * {@inheritdoc}
23   */
24  public function __construct(
25    protected DisplayBuildablePluginManager $displayBuildableManager,
26  ) {}
27
28  /**
29   * Render a Display Builder profile entity view.
30   *
31   * @param \Drupal\display_builder\DisplayBuildableInterface $buildable
32   *   The integration using the display builder.
33   *
34   * @return array
35   *   A renderable array
36   */
37  protected function renderBuilder(DisplayBuildableInterface $buildable): array {
38    /** @var \Drupal\display_builder\ProfileInterface $profile */
39    $profile = $buildable->getProfile();
40
41    if (!$profile) {
42      throw new NotFoundHttpException();
43    }
44
45    if (!$profile->access('view')) {
46      throw new AccessDeniedHttpException();
47    }
48
49    $instance_id = $buildable->getInstanceId();
50    $buildable->initInstanceIfMissing();
51    $view_builder = $this->entityTypeManager()->getViewBuilder('display_builder_profile');
52
53    return $view_builder->view($profile, $instance_id);
54  }
55
56}

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.

IntegrationControllerBase->__construct
25    protected DisplayBuildablePluginManager $displayBuildableManager,
26  ) {}
IntegrationControllerBase->renderBuilder
37  protected function renderBuilder(DisplayBuildableInterface $buildable): array {
38    /** @var \Drupal\display_builder\ProfileInterface $profile */
39    $profile = $buildable->getProfile();
40
41    if (!$profile) {
42      throw new NotFoundHttpException();
45    if (!$profile->access('view')) {
46      throw new AccessDeniedHttpException();
49    $instance_id = $buildable->getInstanceId();
50    $buildable->initInstanceIfMissing();
51    $view_builder = $this->entityTypeManager()->getViewBuilder('display_builder_profile');
52
53    return $view_builder->view($profile, $instance_id);
54  }