mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 12:03:14 +00:00
33 lines
638 B
PHP
33 lines
638 B
PHP
<?php
|
|
|
|
namespace Alchemy\Phrasea\Twig;
|
|
|
|
class JSUniqueID extends \Twig_Extension
|
|
{
|
|
|
|
/**
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getName()
|
|
{
|
|
return 'alchemy_phrasea_jsuniqueid';
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getFilters()
|
|
{
|
|
return array(
|
|
'JSUniqueID' => new \Twig_Filter_Method($this, 'JSUniqueID'),
|
|
);
|
|
}
|
|
|
|
public function JSUniqueID($prefix = null, $suffix = null)
|
|
{
|
|
return $prefix . 'id' . str_replace(array(',', '.'), '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix;
|
|
}
|
|
}
|