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