trait LayoutBuilderSortTrait in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait
- 9 core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait
LayoutBuilderSortTrait, provides callback for simulated layout change.
Hierarchy
- trait \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderSortTrait uses SortableTestTrait
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderSortTrait.php, line 10
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptView source
trait LayoutBuilderSortTrait {
use SortableTestTrait;
/**
* {@inheritdoc}
*/
protected function sortableUpdate($item, $from, $to = NULL) {
// If container does not change, $from and $to are equal.
$to = $to ?: $from;
$script = <<<JS
(function (src, from, to) {
var sourceElement = document.querySelector(src);
var fromElement = document.querySelector(from);
var toElement = document.querySelector(to);
Drupal.layoutBuilderBlockUpdate(sourceElement, fromElement, toElement)
})('{<span class="php-variable">$item</span>}', '{<span class="php-variable">$from</span>}', '{<span class="php-variable">$to</span>}')
JS;
$options = [
'script' => $script,
'args' => [],
];
$this
->getSession()
->getDriver()
->getWebDriverSession()
->execute($options);
}
}