JsOnceTestController.php
Same filename in other branches
Namespace
Drupal\js_once_test\ControllerFile
-
core/
modules/ system/ tests/ modules/ js_once_test/ src/ Controller/ JsOnceTestController.php
View source
<?php
namespace Drupal\js_once_test\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Controller for testing the @drupal/once library integration.
*/
class JsOnceTestController extends ControllerBase {
/**
* Provides elements for testing @drupal/once.
*
* @return array
* The render array.
*/
public function onceTest() {
$output = [
'#attached' => [
'library' => [
'core/once',
],
],
];
foreach (range(1, 5) as $item) {
$output['item' . $item] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => 'Item ' . $item,
'#attributes' => [
'data-drupal-item' => $item,
],
];
}
return $output;
}
/**
* Provides elements for testing jQuery Once BC support.
*
* @return array
* The render array.
*/
public function onceBcTest() {
$output = [
'#attached' => [
'library' => [
'core/jquery.once',
],
],
];
foreach (range(1, 5) as $item) {
$output['item' . $item] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => 'Item ' . $item,
'#attributes' => [
'data-drupal-item' => $item,
],
];
}
return $output;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
JsOnceTestController | Controller for testing the @drupal/once library integration. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.