LayoutBuilderSortTrait.php in Drupal 9
File
core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderSortTrait.php
View source
<?php
namespace Drupal\Tests\layout_builder\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\SortableTestTrait;
trait LayoutBuilderSortTrait {
use SortableTestTrait;
protected function sortableUpdate($item, $from, $to = NULL) {
$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);
}
}