Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

twig is datetime

//
// Just create simple custom function to determine the class name
// and check is equal  to DateTime
//

namespace AppBundleTwig;

use Twig_Extension;
use Twig_SimpleFunction;

class HelperExtension extends Twig_Extension
{
    public function getFunctions()
    {
        return array(
            new Twig_SimpleFunction('class', array($this, 'getClassName')),
        );
    }

    public function getClassName($object)
    {
        if (!is_object($object)) {
            return null;
        }
        return get_class($object);
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #twig #datetime
ADD COMMENT
Topic
Name
2+7 =