TwigArray.php in Bamboo Twig 8.3
File
bamboo_twig_extensions/src/TwigExtension/TwigArray.php
View source
<?php
namespace Drupal\bamboo_twig_extensions\TwigExtension;
class TwigArray extends \Twig_Extension {
public function getFilters() {
return [
new \Twig_SimpleFilter('bamboo_extensions_shuffle', [
$this,
'shuffle',
]),
];
}
public function getName() {
return 'bamboo_twig_extensions.twig.array';
}
public function shuffle($iterator) {
$extension = new \Twig_Extensions_Extension_Array();
$filters = $extension
->getFilters();
foreach ($filters as $filter) {
if ($filter
->getName() == 'shuffle') {
$callable = $filter
->getCallable();
return $callable($iterator);
}
}
return FALSE;
}
}
Classes
Name |
Description |
TwigArray |
Provides bridge for Array functions and filters. |