added support for is*() methods for attributes (foo.bar now looks for foo->getBar() or foo->isBar())

This commit is contained in:
Fabien Potencier
2010-11-16 10:51:23 +01:00
parent 62551da95e
commit 001685ba13
3 changed files with 4 additions and 0 deletions
+1
View File
@@ -13,6 +13,7 @@ Backward incompatibilities:
(the old behavior is still possible by adding the "only" keyword)
* Moved Exceptions to Twig_Error_* (Twig_SyntaxError/Twig_RuntimeError are now Twig_Error_Syntax/Twig_Error_Runtime)
* added support for is*() methods for attributes (foo.bar now looks for foo->getBar() or foo->isBar())
* changed all exceptions to extend Twig_Error
* fixed unary expressions ({{ not(1 or 0) }})
* fixed child templates (with an extend tag) that uses one or more imports
@@ -90,6 +90,7 @@ If a variable or attribute does not exist you will get back a `null` value
> * if not, and if `foo` is an object, check that `bar` is a valid method
> (even if `bar` is the constructor - use `__construct()` instead);
> * if not, and if `foo` is an object, check that `getBar` is a valid method;
> * if not, and if `foo` is an object, check that `isBar` is a valid method (as of Twig 0.9.9);
> * if not, return a `null` value.
>
>`foo['bar']` on the other hand works mostly the same with the a small
+2
View File
@@ -152,6 +152,8 @@ abstract class Twig_Template implements Twig_TemplateInterface
$method = $item;
} elseif (isset(self::$cache[$class]['methods']['get'.$lcItem])) {
$method = 'get'.$item;
} elseif (isset(self::$cache[$class]['methods']['is'.$lcItem])) {
$method = 'is'.$item;
} elseif (isset(self::$cache[$class]['methods']['__call'])) {
$method = $item;
} else {