comparison core/modules/layout_builder/src/Controller/ChooseSectionController.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
6 use Drupal\Core\DependencyInjection\ContainerInjectionInterface; 6 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
7 use Drupal\Core\Layout\LayoutPluginManagerInterface; 7 use Drupal\Core\Layout\LayoutPluginManagerInterface;
8 use Drupal\Core\Plugin\PluginFormInterface; 8 use Drupal\Core\Plugin\PluginFormInterface;
9 use Drupal\Core\StringTranslation\StringTranslationTrait; 9 use Drupal\Core\StringTranslation\StringTranslationTrait;
10 use Drupal\Core\Url; 10 use Drupal\Core\Url;
11 use Drupal\layout_builder\LayoutBuilderHighlightTrait;
11 use Drupal\layout_builder\SectionStorageInterface; 12 use Drupal\layout_builder\SectionStorageInterface;
12 use Symfony\Component\DependencyInjection\ContainerInterface; 13 use Symfony\Component\DependencyInjection\ContainerInterface;
13 14
14 /** 15 /**
15 * Defines a controller to choose a new section. 16 * Defines a controller to choose a new section.
16 * 17 *
17 * @internal 18 * @internal
19 * Controller classes are internal.
18 */ 20 */
19 class ChooseSectionController implements ContainerInjectionInterface { 21 class ChooseSectionController implements ContainerInjectionInterface {
20 22
21 use AjaxHelperTrait; 23 use AjaxHelperTrait;
24 use LayoutBuilderHighlightTrait;
22 use StringTranslationTrait; 25 use StringTranslationTrait;
23 26
24 /** 27 /**
25 * The layout manager. 28 * The layout manager.
26 * 29 *
57 * 60 *
58 * @return array 61 * @return array
59 * The render array. 62 * The render array.
60 */ 63 */
61 public function build(SectionStorageInterface $section_storage, $delta) { 64 public function build(SectionStorageInterface $section_storage, $delta) {
62 $output['#title'] = $this->t('Choose a layout');
63
64 $items = []; 65 $items = [];
65 $definitions = $this->layoutManager->getFilteredDefinitions('layout_builder', [], ['section_storage' => $section_storage]); 66 $definitions = $this->layoutManager->getFilteredDefinitions('layout_builder', [], ['section_storage' => $section_storage]);
66 foreach ($definitions as $plugin_id => $definition) { 67 foreach ($definitions as $plugin_id => $definition) {
67 $layout = $this->layoutManager->createInstance($plugin_id); 68 $layout = $this->layoutManager->createInstance($plugin_id);
68 $item = [ 69 $item = [
96 '#items' => $items, 97 '#items' => $items,
97 '#attributes' => [ 98 '#attributes' => [
98 'class' => [ 99 'class' => [
99 'layout-selection', 100 'layout-selection',
100 ], 101 ],
102 'data-layout-builder-target-highlight-id' => $this->sectionAddHighlightId($delta),
101 ], 103 ],
102 ]; 104 ];
103 105
104 return $output; 106 return $output;
105 } 107 }