Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Bee-color framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jordan Breton
Bee-color framework
Commits
9d6c1051
Commit
9d6c1051
authored
Aug 24, 2019
by
Jordan Breton
✏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added : Absolute redirections
parent
4ccefcd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
8 deletions
+21
-8
engine/core/app/WebApp.php
engine/core/app/WebApp.php
+7
-5
engine/core/response/responses/Redirection.php
engine/core/response/responses/Redirection.php
+14
-3
No files found.
engine/core/app/WebApp.php
View file @
9d6c1051
...
...
@@ -101,7 +101,7 @@ final class WebApp {
$response
->
getCode
(),
$permission
->
getMessage
()
);
}
else
$this
->
redirect
(
$response
->
getUrl
(),
$response
->
getCode
());
}
else
$this
->
redirect
(
$response
->
getUrl
(),
$response
->
getCode
()
,
$response
->
isAbsolute
()
);
}
$responseRouter
=
$this
->
_context
->
getResponseRouter
();
...
...
@@ -149,14 +149,16 @@ final class WebApp {
}
/**
* @param string $url URL de redirection
* @param int|null $code Code de redirection
* @param string $url URL de redirection
* @param int|null $code Code de redirection
* @param bool|null $absolute
*/
private
function
redirect
(
string
$url
,
?int
$code
=
null
){
private
function
redirect
(
string
$url
,
?int
$code
=
null
,
?bool
$absolute
=
false
){
if
(
HTTPStatus
::
existsValue
(
$code
)){
http_response_code
(
$code
);
}
header
(
"Location: "
.
$this
->
_context
->
getRouter
()
->
url
(
$url
));
$url
=
$absolute
?
$url
:
$this
->
_context
->
getRouter
()
->
url
(
$url
);
header
(
"Location:
$url
"
);
exit
(
0
);
}
}
\ No newline at end of file
engine/core/response/responses/Redirection.php
View file @
9d6c1051
...
...
@@ -11,16 +11,20 @@ final class Redirection implements IResponse {
private
$_url
;
/** @var null|int $code */
private
$_code
;
/** @var bool|null $_absolute */
private
$_absolute
;
/**
* RedirectionResponse constructor.
*
* @param string $url URL de redirection
* @param int|null $code Code de redirection
* @param string $url URL de redirection
* @param int|null $code Code de redirection
* @param bool|null $absolute If true, the given url is absolute and must not be parsed by the router.
*/
public
function
__construct
(
string
$url
,
?int
$code
=
null
)
{
public
function
__construct
(
string
$url
,
?int
$code
=
null
,
?bool
$absolute
=
false
)
{
$this
->
_url
=
$url
;
$this
->
_code
=
$code
;
$this
->
_absolute
=
$absolute
;
}
/**
...
...
@@ -37,6 +41,13 @@ final class Redirection implements IResponse {
return
$this
->
_code
;
}
/**
* @return bool
*/
public
function
isAbsolute
():
bool
{
return
$this
->
_absolute
;
}
/**
* @return mixed Données de la réponse
*/
...
...
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