Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| ViewsController | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| title | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getBuilder | |
0.00% |
0 / 7 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder_views\Controller; |
| 6 | |
| 7 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
| 8 | use Drupal\display_builder\Controller\IntegrationControllerBase; |
| 9 | use Drupal\views\ViewEntityInterface; |
| 10 | |
| 11 | /** |
| 12 | * Returns responses for Display Builder ui routes. |
| 13 | */ |
| 14 | class ViewsController extends IntegrationControllerBase { |
| 15 | |
| 16 | /** |
| 17 | * Provides a generic title callback for a display used in pages. |
| 18 | * |
| 19 | * @param \Drupal\views\ViewEntityInterface $view |
| 20 | * The view to be edited. |
| 21 | * @param string $display |
| 22 | * The display ID being edited. |
| 23 | * |
| 24 | * @return \Drupal\Core\StringTranslation\TranslatableMarkup |
| 25 | * The title for the display page, if found. |
| 26 | */ |
| 27 | public function title(ViewEntityInterface $view, string $display): TranslatableMarkup { |
| 28 | $params = [ |
| 29 | '@view' => $view->label(), |
| 30 | '@display' => $view->getDisplay($display)['display_title'] ?? '', |
| 31 | ]; |
| 32 | |
| 33 | return $this->t('Display builder for @view @display', $params); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Load the display builder for views. |
| 38 | * |
| 39 | * @param \Drupal\views\ViewEntityInterface $view |
| 40 | * The view to be edited. |
| 41 | * @param string $display |
| 42 | * The display ID being edited. |
| 43 | * |
| 44 | * @return array |
| 45 | * The display builder renderable. |
| 46 | */ |
| 47 | public function getBuilder(ViewEntityInterface $view, string $display): array { |
| 48 | // The view here is not a "real" View storage, but the copy from the |
| 49 | // tempstore provided by `view_ui` module. So, we have access to the state |
| 50 | // not yet saved in config. |
| 51 | $view = $view->getExecutable(); |
| 52 | $view->setDisplay($display); |
| 53 | $extenders = $view->getDisplay()->getExtenders(); |
| 54 | |
| 55 | if (!isset($extenders['display_builder'])) { |
| 56 | return []; |
| 57 | } |
| 58 | /** @var \Drupal\display_builder\DisplayBuildableInterface $extender */ |
| 59 | $extender = $extenders['display_builder']; |
| 60 | |
| 61 | return $this->renderBuilder($extender); |
| 62 | } |
| 63 | |
| 64 | } |
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.
| 47 | public function getBuilder(ViewEntityInterface $view, string $display): array { |
| 48 | // The view here is not a "real" View storage, but the copy from the |
| 49 | // tempstore provided by `view_ui` module. So, we have access to the state |
| 50 | // not yet saved in config. |
| 51 | $view = $view->getExecutable(); |
| 52 | $view->setDisplay($display); |
| 53 | $extenders = $view->getDisplay()->getExtenders(); |
| 54 | |
| 55 | if (!isset($extenders['display_builder'])) { |
| 56 | return []; |
| 59 | $extender = $extenders['display_builder']; |
| 60 | |
| 61 | return $this->renderBuilder($extender); |
| 27 | public function title(ViewEntityInterface $view, string $display): TranslatableMarkup { |
| 28 | $params = [ |
| 29 | '@view' => $view->label(), |
| 30 | '@display' => $view->getDisplay($display)['display_title'] ?? '', |
| 31 | ]; |
| 32 | |
| 33 | return $this->t('Display builder for @view @display', $params); |