mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
Implement TWIG_GET_CLASS_NAME and make use of it.
This commit is contained in:
@@ -339,6 +339,18 @@ static void TWIG_THROW_EXCEPTION(char *exception_name, char *message, ...)
|
||||
zend_throw_exception_ex(*pce, 0 TSRMLS_CC, buffer);
|
||||
}
|
||||
|
||||
char *TWIG_GET_CLASS_NAME(zval *object)
|
||||
{
|
||||
char *class_name;
|
||||
zend_uint class_name_len;
|
||||
|
||||
if (Z_TYPE_P(object) != IS_OBJECT) {
|
||||
return "";
|
||||
}
|
||||
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
|
||||
return class_name;
|
||||
}
|
||||
|
||||
static void twig_add_method_to_class(zend_function *mptr TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key)
|
||||
{
|
||||
zval *retval = va_arg(args, zval*);
|
||||
@@ -479,7 +491,7 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
}
|
||||
*/
|
||||
if (Z_TYPE_P(object) == IS_OBJECT) {
|
||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist", Z_STRVAL_P(item), TWIG_GET_CLASS(object));
|
||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" in object (with ArrayAccess) of type \"%s\" does not exist", Z_STRVAL_P(item), TWIG_GET_CLASS_NAME(object));
|
||||
} else {
|
||||
TWIG_THROW_EXCEPTION("Twig_Error_Runtime", "Key \"%s\" for array with keys \"%s\" does not exist", Z_STRVAL_P(item), TWIG_IMPLODE_ARRAY_KEYS(", ", object));
|
||||
}
|
||||
@@ -525,11 +537,9 @@ PHP_FUNCTION(twig_template_get_attributes)
|
||||
}
|
||||
}
|
||||
*/
|
||||
char *class_name;
|
||||
zend_uint class_name_len;
|
||||
char *class_name = TWIG_GET_CLASS_NAME(object);
|
||||
zval *tmp_self_cache;
|
||||
|
||||
zend_get_object_classname(object, &class_name, &class_name_len TSRMLS_CC);
|
||||
tmp_self_cache = TWIG_GET_STATIC_PROPERTY(template, "cache");
|
||||
|
||||
if (!TWIG_GET_ARRAY_ELEMENT(tmp_self_cache, class_name)) {
|
||||
|
||||
Reference in New Issue
Block a user