protected function LayoutBuilderAtBase::updateLayoutOverride in Layout Builder Asymmetric Translation 8.2
Update layout override.
Parameters
$url:
bool $update_text_block:
string $custom_block_content_body:
Throws
\Behat\Mink\Exception\ExpectationException
1 call to LayoutBuilderAtBase::updateLayoutOverride()
- LayoutBuilderAtReplicateTest::testAsymmetricTranslationWithReplicate in tests/
src/ Functional/ LayoutBuilderAtReplicateTest.php - Tests that layout overrides have copied blocks.
File
- tests/
src/ Functional/ LayoutBuilderAtBase.php, line 206
Class
- LayoutBuilderAtBase
- Base class for Layout Builder Asymmetric Translations.
Namespace
Drupal\Tests\layout_builder_at\FunctionalCode
protected function updateLayoutOverride($url, $update_text_block = FALSE, $custom_block_content_body = self::translatedContentBlockBody) {
$user = $this->loggedInUser;
$this
->drupalLogin($this->fullAdmin);
$assert_session = $this
->assertSession();
$layout_url = $url . '/layout';
$this
->drupalGet($layout_url);
$assert_session
->statusCodeEquals(200);
$page = $this
->getSession()
->getPage();
if ($update_text_block) {
$id = $assert_session
->elementExists('css', '.layout-builder__region > div:nth-child(4) > div');
$groups = _contextual_id_to_links($id
->getAttribute('data-contextual-id'));
$contextual_links_manager = \Drupal::service('plugin.manager.menu.contextual_link');
$items = [];
foreach ($groups as $group => $args) {
$args += [
'route_parameters' => [],
'metadata' => [],
];
$items += $contextual_links_manager
->getContextualLinksArrayByGroup($group, $args['route_parameters'], $args['metadata']);
}
$item = $items['layout_builder_block_update'];
$item['localized_options']['language'] = \Drupal::languageManager()
->getLanguage($item['metadata']['langcode']);
$update_url = Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : [], $item['localized_options'])
->toString();
$this
->drupalGet($update_url);
$button = $assert_session
->elementExists('css', '.button--primary');
$edit = [
'settings[block_form][body][0][value]' => $custom_block_content_body,
];
$this
->drupalPostForm(NULL, $edit, $button
->getValue());
}
$page
->pressButton('Save layout');
$this
->drupalLogin($user);
}