From 4890cb727fa578cd5c047780b377158652824e03 Mon Sep 17 00:00:00 2001 From: Alessandro Feitoza Date: Fri, 15 Mar 2024 09:02:40 -0300 Subject: [PATCH 1/7] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd219f5..6560f62 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ Essa estrutura já está dockerizada, então basta ter o docker compose rodando Primeiro basta clonar o repositório -`git clone bla bla bla` +`git clone https://github.com/digitalcollege-classes/php-oo` Agora entre na pasta com o terminal -`cd setup-php-docker` +`cd php-oo` E agora basta rodar o docker From 3e3cee4ce0720ac16cef6cdb77c23bcd0ef2a808 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 13:12:40 -0300 Subject: [PATCH 2/7] Commit em arquivo agrupamento das rotas --- config/routes.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/config/routes.php b/config/routes.php index 7a6665f..63a7812 100644 --- a/config/routes.php +++ b/config/routes.php @@ -3,16 +3,26 @@ use App\Controller\CursoController; use App\Controller\HomeController; use App\Controller\ErrorController; +use App\Entity\Curso; return [ - // url a ser acessada => [Controller, metodo] - '/' => [HomeController::class, 'index'], + // Rotas do HomeController + HomeController::class => [ + '/' => 'index', + ], + // Rotas do ErrorController + ErrorController::class => [ + '/erro-404' => 'notFound', + ], - '/erro-404' => [ErrorController::class, 'notFound'], - - '/cursos/listar' => [CursoController::class, 'listar'], - '/cursos/adicionar' => [CursoController::class, 'add'], - '/cursos/editar' => [CursoController::class, 'editar'], - '/cursos/excluir' => [CursoController::class, 'excluir'], + // Rotas do CursoController + CursoController::class => [ + 'cursos' => [ + '/listar' => 'listar', + '/adicionar' => 'add', + '/editar' => 'editar', + '/excluir' => 'excluir', + '/alunos' => 'alunos', + ]], ]; \ No newline at end of file From 71ec2dca6cbdcfa5c942f8ab8284fc227f3c8759 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 13:16:06 -0300 Subject: [PATCH 3/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20do=20foreach=20na=20log?= =?UTF-8?q?ica=20das=20routes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.php | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/public/index.php b/public/index.php index 3ee4cda..36443a5 100644 --- a/public/index.php +++ b/public/index.php @@ -1,17 +1,35 @@ $actions) { + if ($controller === CursoController::class && isset($actions['cursos'])) { + $prefixo = '/cursos'; + $rota = substr($url, strlen($prefixo)); -(new $controller())->$method(); \ No newline at end of file + if (isset($actions['cursos'][$rota])) { + $controllerFound = true; + $method = $actions['cursos'][$rota]; + (new CursoController())->$method(); + break; + } + } elseif (isset($actions[$url])) { + $controllerFound = true; + $method = $actions[$url]; + (new $controller())->$method(); + break; + } +} + +if (!$controllerFound) { + header('location: /erro-404'); + exit; +} \ No newline at end of file From 5b006c9b19e9254243dc96e4e0b76387fc960955 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 14:48:32 -0300 Subject: [PATCH 4/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20na=20class=20CursosCont?= =?UTF-8?q?rller=20a=20route=20alunos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.php | 13 +++++++------ src/Controller/CursoController.php | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/routes.php b/config/routes.php index 63a7812..679a694 100644 --- a/config/routes.php +++ b/config/routes.php @@ -19,10 +19,11 @@ // Rotas do CursoController CursoController::class => [ 'cursos' => [ - '/listar' => 'listar', - '/adicionar' => 'add', - '/editar' => 'editar', - '/excluir' => 'excluir', - '/alunos' => 'alunos', - ]], + '/listar' => 'listar', + '/adicionar' => 'add', + '/editar' => 'editar', + '/excluir' => 'excluir', + '/alunos' => 'alunos', + ] + ], ]; \ No newline at end of file diff --git a/src/Controller/CursoController.php b/src/Controller/CursoController.php index a687d29..20a9f5d 100644 --- a/src/Controller/CursoController.php +++ b/src/Controller/CursoController.php @@ -25,4 +25,9 @@ public function excluir(): void { echo "Excluir"; } + + public function alunos(): void + { + echo "alunos"; + } } \ No newline at end of file From 59a4dd018ebcad4d7f7cd67ea0b6974fffd8de36 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 15:45:53 -0300 Subject: [PATCH 5/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20routes=20alunos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/config/routes.php b/config/routes.php index 679a694..ec79e27 100644 --- a/config/routes.php +++ b/config/routes.php @@ -3,6 +3,7 @@ use App\Controller\CursoController; use App\Controller\HomeController; use App\Controller\ErrorController; +use App\Controller\AlunoController; use App\Entity\Curso; return [ @@ -26,4 +27,17 @@ '/alunos' => 'alunos', ] ], -]; \ No newline at end of file + + // Rotas do AlunoController + AlunoController::class => [ + 'aluno' => [ + '/matricula' => 'matricula', + '/nome' => 'nome', + '/curso' => 'curso', + '/turno' => 'turno', + '/notas' => 'notas', + ] + ], +]; + +?> From 9d26a840cbecf3ab127f5cf38c5236806aa71392 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 15:46:43 -0300 Subject: [PATCH 6/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20logica=20alunos=20?= =?UTF-8?q?no=20index.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/public/index.php b/public/index.php index 36443a5..2f33cc0 100644 --- a/public/index.php +++ b/public/index.php @@ -3,6 +3,7 @@ require_once "../vendor/autoload.php"; use App\Controller\CursoController; +use App\Controller\AlunoController; $routes = include "../config/routes.php"; @@ -21,6 +22,16 @@ (new CursoController())->$method(); break; } + } elseif ($controller === AlunoController::class && isset($actions['aluno'])) { + $prefixo = '/aluno'; + $rota = substr($url, strlen($prefixo)); + + if (isset($actions['aluno'][$rota])) { + $controllerFound = true; + $method = $actions['aluno'][$rota]; + (new AlunoController())->$method(); + break; + } } elseif (isset($actions[$url])) { $controllerFound = true; $method = $actions[$url]; @@ -32,4 +43,4 @@ if (!$controllerFound) { header('location: /erro-404'); exit; -} \ No newline at end of file +} From 7ce0fa5b2bc58b315eee1eb1984e6ac3b7e93046 Mon Sep 17 00:00:00 2001 From: Marcos Date: Mon, 18 Mar 2024 15:47:32 -0300 Subject: [PATCH 7/7] =?UTF-8?q?cria=C3=A7=C3=A3o=20da=20class=20alunos=20n?= =?UTF-8?q?a=20pasta=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/AlunoController.php | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Controller/AlunoController.php diff --git a/src/Controller/AlunoController.php b/src/Controller/AlunoController.php new file mode 100644 index 0000000..553d990 --- /dev/null +++ b/src/Controller/AlunoController.php @@ -0,0 +1,36 @@ +Nome"; + } + + public function curso(): void + { + echo "Curso"; + } + + public function turma(): void + { + echo "Turma"; + } + + public function notas(): void + { + echo "Notas"; + } +} + +?>