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

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
7 use Drupal\Core\Ajax\ReplaceCommand; 7 use Drupal\Core\Ajax\ReplaceCommand;
8 use Drupal\layout_builder\SectionStorageInterface; 8 use Drupal\layout_builder\SectionStorageInterface;
9 9
10 /** 10 /**
11 * Provides AJAX responses to rebuild the Layout Builder. 11 * Provides AJAX responses to rebuild the Layout Builder.
12 *
13 * @internal
14 */ 12 */
15 trait LayoutRebuildTrait { 13 trait LayoutRebuildTrait {
16
17 /**
18 * The class resolver.
19 *
20 * @var \Drupal\Core\DependencyInjection\ClassResolverInterface
21 */
22 protected $classResolver;
23 14
24 /** 15 /**
25 * Rebuilds the layout. 16 * Rebuilds the layout.
26 * 17 *
27 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage 18 * @param \Drupal\layout_builder\SectionStorageInterface $section_storage
47 * An AJAX response to either rebuild the layout and close the dialog, or 38 * An AJAX response to either rebuild the layout and close the dialog, or
48 * reload the page. 39 * reload the page.
49 */ 40 */
50 protected function rebuildLayout(SectionStorageInterface $section_storage) { 41 protected function rebuildLayout(SectionStorageInterface $section_storage) {
51 $response = new AjaxResponse(); 42 $response = new AjaxResponse();
52 $layout_controller = $this->classResolver->getInstanceFromDefinition(LayoutBuilderController::class); 43 $layout = [
53 $layout = $layout_controller->layout($section_storage, TRUE); 44 '#type' => 'layout_builder',
45 '#section_storage' => $section_storage,
46 ];
54 $response->addCommand(new ReplaceCommand('#layout-builder', $layout)); 47 $response->addCommand(new ReplaceCommand('#layout-builder', $layout));
55 return $response; 48 return $response;
56 } 49 }
57 50
58 } 51 }