Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
feat: add twig filter for format file sizes
Browse files Browse the repository at this point in the history
Signed-off-by: Domingo Oropeza <doropeza@teclib.com>
  • Loading branch information
DIOHz0r committed Mar 9, 2018
1 parent 832b19e commit e9efe9b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/GlpiLocalesExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,21 @@ public function getFunctions() {
public function getName() {
return 'glpi_locales_extension';
}

public function getFilters()
{
return array(
new \Twig_SimpleFilter('fileSize', array($this, 'fileSizeFilter')),
);
}

/**
* Format a size passing a size in octet
* @param int $number
* @return string
*/
public function fileSizeFilter($number)
{
return Toolbox::getSize($number);
}
}

0 comments on commit e9efe9b

Please sign in to comment.