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
24bce51f
Commit
24bce51f
authored
Nov 04, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the deprecated TwigCoreExtension class
parent
a4c7c51f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
83 deletions
+0
-83
src/Silex/Provider/TwigCoreExtension.php
src/Silex/Provider/TwigCoreExtension.php
+0
-56
src/Silex/Provider/TwigServiceProvider.php
src/Silex/Provider/TwigServiceProvider.php
+0
-3
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
+0
-24
No files found.
src/Silex/Provider/TwigCoreExtension.php
deleted
100644 → 0
View file @
a4c7c51f
<?php
/*
* This file is part of the Silex framework.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
Silex\Provider
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpKernel\HttpKernelInterface
;
/**
* Twig extension.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated deprecated since 1.2, will be removed in 1.3. Use HttpFragmentServiceProvider instead
*/
class
TwigCoreExtension
extends
\Twig_Extension
{
public
function
getFunctions
()
{
return
array
(
'render'
=>
new
\Twig_Function_Method
(
$this
,
'render'
,
array
(
'needs_environment'
=>
true
,
'is_safe'
=>
array
(
'html'
))),
);
}
public
function
render
(
\Twig_Environment
$twig
,
$uri
)
{
$globals
=
$twig
->
getGlobals
();
$request
=
$globals
[
'app'
][
'request'
];
$subRequest
=
Request
::
create
(
$uri
,
'get'
,
array
(),
$request
->
cookies
->
all
(),
array
(),
$request
->
server
->
all
());
if
(
$request
->
getSession
())
{
$subRequest
->
setSession
(
$request
->
getSession
());
}
$response
=
$globals
[
'app'
]
->
handle
(
$subRequest
,
HttpKernelInterface
::
SUB_REQUEST
,
false
);
if
(
!
$response
->
isSuccessful
())
{
throw
new
\RuntimeException
(
sprintf
(
'Error when rendering "%s" (Status code is %s).'
,
$request
->
getUri
(),
$response
->
getStatusCode
()));
}
return
$response
->
getContent
();
}
public
function
getName
()
{
return
'silex'
;
}
}
src/Silex/Provider/TwigServiceProvider.php
View file @
24bce51f
...
@@ -68,9 +68,6 @@ class TwigServiceProvider implements ServiceProviderInterface
...
@@ -68,9 +68,6 @@ class TwigServiceProvider implements ServiceProviderInterface
$app
[
'fragment.renderer.hinclude'
]
->
setTemplating
(
$twig
);
$app
[
'fragment.renderer.hinclude'
]
->
setTemplating
(
$twig
);
$twig
->
addExtension
(
new
HttpKernelExtension
(
$app
[
'fragment.handler'
]));
$twig
->
addExtension
(
new
HttpKernelExtension
(
$app
[
'fragment.handler'
]));
}
else
{
// fallback for BC, to be removed in 1.3
$twig
->
addExtension
(
new
TwigCoreExtension
());
}
}
if
(
isset
(
$app
[
'form.factory'
]))
{
if
(
isset
(
$app
[
'form.factory'
]))
{
...
...
tests/Silex/Tests/Provider/TwigServiceProviderTest.php
View file @
24bce51f
...
@@ -39,30 +39,6 @@ class TwigServiceProviderTest extends \PHPUnit_Framework_TestCase
...
@@ -39,30 +39,6 @@ class TwigServiceProviderTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'Hello john!'
,
$response
->
getContent
());
$this
->
assertEquals
(
'Hello john!'
,
$response
->
getContent
());
}
}
public
function
testRenderFunction
()
{
$app
=
new
Application
();
$app
->
register
(
new
TwigServiceProvider
(),
array
(
'twig.templates'
=>
array
(
'hello'
=>
'{{ render("/foo") }}'
,
'foo'
=>
'foo'
,
),
));
$app
->
get
(
'/hello'
,
function
()
use
(
$app
)
{
return
$app
[
'twig'
]
->
render
(
'hello'
);
});
$app
->
get
(
'/foo'
,
function
()
use
(
$app
)
{
return
$app
[
'twig'
]
->
render
(
'foo'
);
});
$request
=
Request
::
create
(
'/hello'
);
$response
=
$app
->
handle
(
$request
);
$this
->
assertEquals
(
'foo'
,
$response
->
getContent
());
}
public
function
testLoaderPriority
()
public
function
testLoaderPriority
()
{
{
$app
=
new
Application
();
$app
=
new
Application
();
...
...
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