Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
Silex
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
Silex
Commits
f2fc754c
Commit
f2fc754c
authored
Aug 25, 2013
by
Igor Wiedler
Committed by
Fabien Potencier
Aug 29, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only convert attributes on the request that actually exist
parent
d6fe48ea
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
2 deletions
+44
-2
doc/changelog.rst
doc/changelog.rst
+1
-1
src/Silex/EventListener/ConverterListener.php
src/Silex/EventListener/ConverterListener.php
+3
-1
tests/Silex/Tests/ConverterTest.php
tests/Silex/Tests/ConverterTest.php
+40
-0
No files found.
doc/changelog.rst
View file @
f2fc754c
...
...
@@ -4,7 +4,7 @@ Changelog
1.1.1 (2013-XX-XX)
------------------
*
n/a
*
Only convert attributes on the request that actually exist.
1.1.0 (2013-07-04)
------------------
...
...
src/Silex/EventListener/ConverterListener.php
View file @
f2fc754c
...
...
@@ -46,7 +46,9 @@ class ConverterListener implements EventSubscriberInterface
$route
=
$this
->
routes
->
get
(
$request
->
attributes
->
get
(
'_route'
));
if
(
$route
&&
$converters
=
$route
->
getOption
(
'_converters'
))
{
foreach
(
$converters
as
$name
=>
$callback
)
{
$request
->
attributes
->
set
(
$name
,
call_user_func
(
$callback
,
$request
->
attributes
->
get
(
$name
),
$request
));
if
(
$request
->
attributes
->
has
(
$name
))
{
$request
->
attributes
->
set
(
$name
,
call_user_func
(
$callback
,
$request
->
attributes
->
get
(
$name
),
$request
));
}
}
}
}
...
...
tests/Silex/Tests/ConverterTest.php
0 → 100644
View file @
f2fc754c
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace
Silex\Tests
;
use
Silex\Application
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Converter listener test cases.
*
* @author Igor Wiedler <igor@wiedler.ch>
*/
class
ConverterTest
extends
\PHPUnit_Framework_TestCase
{
public
function
testConvertingNonExistentAttributeShouldNotCallConverter
()
{
$called
=
false
;
$converter
=
function
()
use
(
&
$called
)
{
$called
=
true
;
};
$app
=
new
Application
();
$app
->
get
(
'/'
,
function
()
{
return
'hallo'
;
});
$app
[
'controllers'
]
->
convert
(
'foo'
,
$converter
);
$request
=
Request
::
create
(
'/'
);
$app
->
handle
(
$request
);
$this
->
assertFalse
(
$called
);
}
}
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