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
e96f9be8
Commit
e96f9be8
authored
Nov 05, 2013
by
Fabien Potencier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed the request service in favor of the request_stack one
parent
26e85436
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
70 deletions
+12
-70
src/Silex/Application.php
src/Silex/Application.php
+1
-15
src/Silex/ExceptionListenerWrapper.php
src/Silex/ExceptionListenerWrapper.php
+1
-1
tests/Silex/Tests/ApplicationTest.php
tests/Silex/Tests/ApplicationTest.php
+0
-45
tests/Silex/Tests/MiddlewareTest.php
tests/Silex/Tests/MiddlewareTest.php
+2
-2
tests/Silex/Tests/RouterTest.php
tests/Silex/Tests/RouterTest.php
+4
-4
tests/Silex/Tests/WebTestCaseTest.php
tests/Silex/Tests/WebTestCaseTest.php
+4
-3
No files found.
src/Silex/Application.php
View file @
e96f9be8
...
@@ -138,12 +138,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
...
@@ -138,12 +138,6 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
return
new
RedirectableUrlMatcher
(
$app
[
'routes'
],
$app
[
'request_context'
]);
return
new
RedirectableUrlMatcher
(
$app
[
'routes'
],
$app
[
'request_context'
]);
});
});
$this
[
'request_error'
]
=
$this
->
protect
(
function
()
{
throw
new
\RuntimeException
(
'Accessed request service outside of request scope. Try moving that call to a before handler or controller.'
);
});
$this
[
'request'
]
=
$this
[
'request_error'
];
$this
[
'request.http_port'
]
=
80
;
$this
[
'request.http_port'
]
=
80
;
$this
[
'request.https_port'
]
=
443
;
$this
[
'request.https_port'
]
=
443
;
$this
[
'debug'
]
=
false
;
$this
[
'debug'
]
=
false
;
...
@@ -533,17 +527,9 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
...
@@ -533,17 +527,9 @@ class Application extends \Pimple implements HttpKernelInterface, TerminableInte
$this
->
boot
();
$this
->
boot
();
}
}
$current
=
HttpKernelInterface
::
SUB_REQUEST
===
$type
?
$this
[
'request'
]
:
$this
[
'request_error'
];
$this
[
'request'
]
=
$request
;
$this
->
flush
();
$this
->
flush
();
$response
=
$this
[
'kernel'
]
->
handle
(
$request
,
$type
,
$catch
);
return
$this
[
'kernel'
]
->
handle
(
$request
,
$type
,
$catch
);
$this
[
'request'
]
=
$current
;
return
$response
;
}
}
/**
/**
...
...
src/Silex/ExceptionListenerWrapper.php
View file @
e96f9be8
...
@@ -49,7 +49,7 @@ class ExceptionListenerWrapper
...
@@ -49,7 +49,7 @@ class ExceptionListenerWrapper
$code
=
$exception
instanceof
HttpExceptionInterface
?
$exception
->
getStatusCode
()
:
500
;
$code
=
$exception
instanceof
HttpExceptionInterface
?
$exception
->
getStatusCode
()
:
500
;
$response
=
call_user_func
(
$this
->
callback
,
$exception
,
$code
);
$response
=
call_user_func
(
$this
->
callback
,
$exception
,
$
event
->
getRequest
(),
$
code
);
$this
->
ensureResponse
(
$response
,
$event
);
$this
->
ensureResponse
(
$response
,
$event
);
}
}
...
...
tests/Silex/Tests/ApplicationTest.php
View file @
e96f9be8
...
@@ -416,30 +416,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
...
@@ -416,30 +416,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$app
->
handle
(
Request
::
create
(
'/'
),
HttpKernelInterface
::
MASTER_REQUEST
,
false
);
$app
->
handle
(
Request
::
create
(
'/'
),
HttpKernelInterface
::
MASTER_REQUEST
,
false
);
}
}
/**
* @expectedException \RuntimeException
*/
public
function
testAccessingRequestOutsideOfScopeShouldThrowRuntimeException
()
{
$app
=
new
Application
();
$request
=
$app
[
'request'
];
}
/**
* @expectedException \RuntimeException
*/
public
function
testAccessingRequestOutsideOfScopeShouldThrowRuntimeExceptionAfterHandling
()
{
$app
=
new
Application
();
$app
->
get
(
'/'
,
function
()
{
return
'hello'
;
});
$app
->
handle
(
Request
::
create
(
'/'
),
HttpKernelInterface
::
MASTER_REQUEST
,
false
);
$request
=
$app
[
'request'
];
}
public
function
testSubRequest
()
public
function
testSubRequest
()
{
{
$app
=
new
Application
();
$app
=
new
Application
();
...
@@ -453,27 +429,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
...
@@ -453,27 +429,6 @@ class ApplicationTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'foo'
,
$app
->
handle
(
Request
::
create
(
'/'
))
->
getContent
());
$this
->
assertEquals
(
'foo'
,
$app
->
handle
(
Request
::
create
(
'/'
))
->
getContent
());
}
}
public
function
testSubRequestDoesNotReplaceMainRequestAfterHandling
()
{
$mainRequest
=
Request
::
create
(
'/'
);
$subRequest
=
Request
::
create
(
'/sub'
);
$app
=
new
Application
();
$app
->
get
(
'/sub'
,
function
(
Request
$request
)
{
return
new
Response
(
'foo'
);
});
$app
->
get
(
'/'
,
function
(
Request
$request
)
use
(
$subRequest
,
$app
)
{
$response
=
$app
->
handle
(
$subRequest
,
HttpKernelInterface
::
SUB_REQUEST
);
// request in app must be the main request here
$response
->
setContent
(
$response
->
getContent
()
.
' '
.
$app
[
'request'
]
->
getPathInfo
());
return
$response
;
});
$this
->
assertEquals
(
'foo /'
,
$app
->
handle
(
$mainRequest
)
->
getContent
());
}
public
function
testRegisterShouldReturnSelf
()
public
function
testRegisterShouldReturnSelf
()
{
{
$app
=
new
Application
();
$app
=
new
Application
();
...
...
tests/Silex/Tests/MiddlewareTest.php
View file @
e96f9be8
...
@@ -191,8 +191,8 @@ class MiddlewareTest extends \PHPUnit_Framework_TestCase
...
@@ -191,8 +191,8 @@ class MiddlewareTest extends \PHPUnit_Framework_TestCase
{
{
$app
=
new
Application
();
$app
=
new
Application
();
$app
->
before
(
function
()
use
(
$app
)
{
$app
->
before
(
function
(
Request
$request
)
use
(
$app
)
{
$app
[
'project'
]
=
$
app
[
'request'
]
->
get
(
'project'
);
$app
[
'project'
]
=
$
request
->
get
(
'project'
);
});
});
$app
->
match
(
'/foo/{project}'
,
function
()
use
(
$app
)
{
$app
->
match
(
'/foo/{project}'
,
function
()
use
(
$app
)
{
...
...
tests/Silex/Tests/RouterTest.php
View file @
e96f9be8
...
@@ -152,12 +152,12 @@ class RouterTest extends \PHPUnit_Framework_TestCase
...
@@ -152,12 +152,12 @@ class RouterTest extends \PHPUnit_Framework_TestCase
{
{
$app
=
new
Application
();
$app
=
new
Application
();
$app
->
get
(
'/foo'
,
function
()
use
(
$app
)
{
$app
->
get
(
'/foo'
,
function
(
Request
$request
)
use
(
$app
)
{
return
new
Response
(
$
app
[
'request'
]
->
getRequestUri
());
return
new
Response
(
$
request
->
getRequestUri
());
});
});
$app
->
error
(
function
(
$e
)
use
(
$app
)
{
$app
->
error
(
function
(
$e
,
Request
$request
,
$code
)
use
(
$app
)
{
return
new
Response
(
$
app
[
'request'
]
->
getRequestUri
());
return
new
Response
(
$
request
->
getRequestUri
());
});
});
foreach
(
array
(
'/foo'
,
'/bar'
)
as
$path
)
{
foreach
(
array
(
'/foo'
,
'/bar'
)
as
$path
)
{
...
...
tests/Silex/Tests/WebTestCaseTest.php
View file @
e96f9be8
...
@@ -13,6 +13,7 @@ namespace Silex\Tests;
...
@@ -13,6 +13,7 @@ namespace Silex\Tests;
use
Silex\Application
;
use
Silex\Application
;
use
Silex\WebTestCase
;
use
Silex\WebTestCase
;
use
Symfony\Component\HttpFoundation\Request
;
/**
/**
* Functional test cases.
* Functional test cases.
...
@@ -33,9 +34,9 @@ class WebTestCaseTest extends WebTestCase
...
@@ -33,9 +34,9 @@ class WebTestCaseTest extends WebTestCase
return
'<h1>title</h1>'
;
return
'<h1>title</h1>'
;
});
});
$app
->
match
(
'/server'
,
function
()
use
(
$app
)
{
$app
->
match
(
'/server'
,
function
(
Request
$request
)
use
(
$app
)
{
$user
=
$
app
[
'request'
]
->
server
->
get
(
'PHP_AUTH_USER'
);
$user
=
$
request
->
server
->
get
(
'PHP_AUTH_USER'
);
$pass
=
$
app
[
'request'
]
->
server
->
get
(
'PHP_AUTH_PW'
);
$pass
=
$
request
->
server
->
get
(
'PHP_AUTH_PW'
);
return
"<h1>
$user
:
$pass
</h1>"
;
return
"<h1>
$user
:
$pass
</h1>"
;
});
});
...
...
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