protected function hasCustomfield()
    {

        $function = function ($object, $name) {
            return method_exists($object, 'hasCustomfield') ? $object->hasCustomfield($name) : false;
        };
        return new Twig_SimpleFunction(
                'hasCustomfield', $function
        );
    }