front-controller #17

Merged
maxime.batista merged 12 commits from front-controller into salva 1 year ago

I did the FRONT CONTROLLERRRRR. (Salva version lol)

When you create a new controller

When you create a new controller, define the path to call it here (image 1).
Don't forget to associate a controller with a role.

The action's main method

The main method have to return a ViewHttpResponse.

If you create a new action, please make sure that the action's main method have the same name than the action (image 2 and 3) and to make the main method public.

I did the FRONT CONTROLLERRRRR. (Salva version lol) # When you create a new controller When you create a new controller, define the path to call it here (image 1). Don't forget to associate a controller with a role. # The action's main method The main method have to return a `ViewHttpResponse`. If you create a new action, please make sure that the action's main method have the same name than the action (image 2 and 3) and to make the main method public.
22 KiB
4.4 KiB
50 KiB
yanis.dahmane-bounoua added 10 commits 1 year ago
continuous-integration/drone/push Build is passing Details
5737bd6e6b
Add start of homepage and FrontControler (don't run it)
continuous-integration/drone/push Build is passing Details
ec47461703
wip FRONT CONTROLLER
continuous-integration/drone/push Build is passing Details
3422ef8780
Corrections conflicts
continuous-integration/drone/push Build is passing Details
61a6b5afd5
wip FrontController
continuous-integration/drone/push Build is passing Details
5314c3bd2d
WIP
continuous-integration/drone/push Build is passing Details
ff9f41f18c
FrontController done
continuous-integration/drone/push Build is passing Details
810477cf4c
Doc done
maxime.batista approved these changes 1 year ago
* @return void
*/
public function run() : void {
$this->initializeRouterMap();

move this call in the constructor, or better, inline its content in the createRouter method.

move this call in the constructor, or better, inline its content in the `createRouter` method.
} else {
$this->diplayViewByKind(ViewHttpResponse::twig("error.html.twig", [], HttpCodes::NOT_FOUND));
}
// $this->handleMatch($match["target"]);

remove comments

remove comments
$this->router->map("GET", "/", "UserController");
$this->router->map("GET", "/[a:action]?", "UserController");
$this->router->map("GET", "/tactic/[a:action]/[i:idTactic]?", "EditorController");
// $this->router->map("GET", "/tactic/[i:id]/edit", "EditorController");

remove those comments

remove those comments
}
/**
* Call

call what

call what
}
// private function sanitizeParam($params) {
// foreach ($key, $value : )

remove those comments

remove those comments
// foreach ($key, $value : )
// }
private function tryToCall($controller, $action, array $params){

explicitly set its return type to HttpResponse

explicitly set its return type to `HttpResponse`
unset($params["action"]);
$controller = $this->initControllerByRole($controller);
try {
if (is_callable(array($controller, $action))){
- if (is_callable(array($controller, $action))){
+ if (is_callable([$controller, $action])) {
```diff - if (is_callable(array($controller, $action))){ + if (is_callable([$controller, $action])) { ```
}
}
// A décommenter/remplacer quand méthode de connexion disponible

you can inline those two lines

- $controller = new $controller();
- return $controller;
+ return new $controller();
you can inline those two lines ```diff - $controller = new $controller(); - return $controller; + return new $controller(); ```
// return "null";
// }
$_SESSION['role'] = 'public'; // Remplacer par appel de la méthode de connexion

useless here, don't try to anticipate future code

useless here, don't try to anticipate future code
}
/**
* Redirect the return by the response's type
- $controller = new $controller();
- return $controller;
+ return new $controller();
```diff - $controller = new $controller(); - return $controller; + return new $controller(); ```
* @return void
*/
private function handleResponseByType(HttpResponse $response) : void {
// $response = call_user_func_array($match['target'], $match['params']);
-  @param array $match
+  @param HttpRequest $response
```diff - @param array $match + @param HttpRequest $response ```
http_response_code($response->getCode());
if ($response instanceof ViewHttpResponse) {
$this->diplayViewByKind($response);

remove this comment

remove this comment
$file = $response->getFile();
$args = $response->getArguments();
switch ($response->getViewKind()) {

typo here in display

typo here in `display`
maxime.batista requested changes 1 year ago
maxime.batista left a comment

meant to request changes*

  • merge master and use ./format.sh and ./verify.sh scripts
  • please remove all unused imports
  • remove all your commented code
  • some phpdoc clauses are not updated
meant to request changes* - merge master and use `./format.sh` and `./verify.sh` scripts - please remove all unused imports - remove all your commented code - some phpdoc clauses are not updated
maxime.batista force-pushed front-controller from dc4c95026c to 81439e341d 1 year ago
maxime.batista force-pushed front-controller from 81439e341d to 0a4ef19436 1 year ago
maxime.batista merged commit 5d4bb84368 into salva 1 year ago
maxime.batista referenced this issue from a commit 1 year ago
maxime.batista deleted branch front-controller 1 year ago
maxime.batista referenced this issue from a commit 1 year ago

Reviewers

maxime.batista requested changes 1 year ago
continuous-integration/drone/push Build is passing
The pull request has been merged as 5d4bb84368.
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: IQBall/Application-Web#17
Loading…
There is no content yet.