Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
0.00% |
0 / 6 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
||
| PageLayoutController | |
0.00% |
0 / 6 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
||
| getTitle | |
0.00% |
0 / 1 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| getBuilder | |
0.00% |
0 / 2 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| duplicate | |
0.00% |
0 / 3 |
n/a |
0 / 0 |
n/a |
0 / 0 |
|
0.00% |
0 / 1 |
2 | |||||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Drupal\display_builder_page_layout\Controller; |
| 6 | |
| 7 | use Drupal\Core\StringTranslation\TranslatableMarkup; |
| 8 | use Drupal\display_builder\Controller\IntegrationControllerBase; |
| 9 | use Drupal\display_builder_page_layout\PageLayoutInterface; |
| 10 | |
| 11 | /** |
| 12 | * Returns responses for Display Builder ui routes. |
| 13 | */ |
| 14 | class PageLayoutController extends IntegrationControllerBase { |
| 15 | |
| 16 | /** |
| 17 | * Returns a page title. |
| 18 | * |
| 19 | * @param \Drupal\display_builder_page_layout\PageLayoutInterface $page_layout |
| 20 | * The page layout entity. |
| 21 | * |
| 22 | * @return \Drupal\Core\StringTranslation\TranslatableMarkup |
| 23 | * The page title. |
| 24 | */ |
| 25 | public function getTitle(PageLayoutInterface $page_layout): TranslatableMarkup { |
| 26 | return $this->t('Build %label page layout', ['%label' => $page_layout->label()]); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Load the display builder for page layout. |
| 31 | * |
| 32 | * @param \Drupal\display_builder_page_layout\PageLayoutInterface $page_layout |
| 33 | * The page layout entity. |
| 34 | * |
| 35 | * @return array |
| 36 | * The display builder renderable. |
| 37 | */ |
| 38 | public function getBuilder(PageLayoutInterface $page_layout): array { |
| 39 | /** @var \Drupal\display_builder\DisplayBuildableInterface $buildable */ |
| 40 | $buildable = $this->displayBuildableManager->createInstance('page_layout', ['entity' => $page_layout]); |
| 41 | |
| 42 | return $this->renderBuilder($buildable); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Creates a duplicate of a page layout and presents the add page layout form. |
| 47 | * |
| 48 | * This function serves as the controller for the 'duplicate-form' route |
| 49 | * (e.g., admin/structure/page-layout/my_page_layout/duplicate). |
| 50 | * It duplicates the provided page layout, assigns a new label |
| 51 | * (e.g., "Duplicate of Original Label"), and then redirects the user |
| 52 | * to the entity creation form to save the new page layout. |
| 53 | * |
| 54 | * @param \Drupal\display_builder_page_layout\PageLayoutInterface $page_layout |
| 55 | * The page layout entity to duplicate. |
| 56 | * |
| 57 | * @return array |
| 58 | * The entity form for the duplicated entity, in 'add' mode. |
| 59 | */ |
| 60 | public function duplicate(PageLayoutInterface $page_layout) { |
| 61 | $duplicate = $page_layout->createDuplicate(); |
| 62 | $duplicate->set('label', $this->t('Duplicate of @label', ['@label' => $page_layout->label()])); |
| 63 | |
| 64 | return $this->entityFormBuilder()->getForm($duplicate, 'add'); |
| 65 | } |
| 66 | |
| 67 | } |
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.