Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
80178e6d
Commit
80178e6d
authored
Aug 07, 2014
by
Alexei Tenitski
Committed by
Alexander Makarov
Aug 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #2925 and #4290 (Twig does not properly support null attribute and relationship values)
parent
071105e9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
0 deletions
+32
-0
Extension.php
extensions/twig/Extension.php
+5
-0
Template.php
extensions/twig/Template.php
+27
-0
No files found.
extensions/twig/Extension.php
View file @
80178e6d
...
...
@@ -54,6 +54,11 @@ class Extension extends \Twig_Extension
];
}
public
function
initRuntime
(
\Twig_Environment
$environment
)
{
$environment
->
setBaseTemplateClass
(
'yii\twig\Template'
);
}
/**
* @inheritdoc
*/
...
...
extensions/twig/Template.php
0 → 100755
View file @
80178e6d
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\twig
;
/**
* Template base class
*
* @author Alexei Tenitski <alexei@ten.net.nz>
*/
abstract
class
Template
extends
\Twig_Template
{
protected
function
getAttribute
(
$object
,
$item
,
array
$arguments
=
array
(),
$type
=
\Twig_Template
::
ANY_CALL
,
$isDefinedTest
=
false
,
$ignoreStrictCheck
=
false
)
{
// Twig uses isset() to check if attribute exists which does not work when attribute exists but is null
if
(
$object
instanceof
\yii\db\BaseActiveRecord
)
{
return
$object
->
$item
;
}
return
parent
::
getAttribute
(
$object
,
$item
,
$arguments
,
$type
,
$isDefinedTest
,
$ignoreStrictCheck
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment