-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPicoArrayKSort.php
More file actions
32 lines (30 loc) · 839 Bytes
/
PicoArrayKSort.php
File metadata and controls
32 lines (30 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
/**
* Pico ksort plugin.
*
* A small integration for the Twig Template Engine. This plugin directly brings
* the ksort function from PHP into your tpl file. Sort an array by key, nothing
* more.
*
* @author Giovanni Forte <giovanni@teamvodka.eu>
* @link https://teamvodka.eu
* @license https://opensource.org/licenses/MIT The MIT License
* @version 0.1
*/
class PicoArrayKSort extends AbstractPicoPlugin
{
const API_VERSION = 3;
protected $enabled = true;
protected $dependsOn = array();
public function onTwigRegistered(Twig_Environment &$twig)
{
$twig->addFilter(new Twig_SimpleFilter('ksort', function($array) {
return $this->ksort($array);
}));
}
public function ksort($array)
{
ksort($array);
return $array;
}
}