Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
FernandoCalmet committed Sep 15, 2020
1 parent 985801c commit b7eb69a
Show file tree
Hide file tree
Showing 53 changed files with 327 additions and 273 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ composer database
composer start
```

## Test Login

```note
email: [email protected]
password: AnyPass1000
```

## :page_facing_up: LICENCIA

Licencia MIT. Puedes verla en el [Archivo de Licencia](LICENSE.md) para más información.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"scripts": {
"database": "php extras/bin/database.php",
"start": "php -S localhost:8080 -t public public/index.phtml"
"start": "php -S localhost:8080 -t public public/index.php"
},
"require": {
"vlucas/phpdotenv": "^5.2",
Expand Down
16 changes: 8 additions & 8 deletions public/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^page_404$ partials/error/page404.phtml [L,NC]
RewriteRule ^page_500$ partials/error/page500.phtml [L,NC]
DirectoryIndex index.php
RewriteRule ^page_404$ partials/error/page404.php [L,NC]
RewriteRule ^page_500$ partials/error/page500.php [L,NC]
ErrorDocument 404 /page_404
ErrorDocument 500 /page_500
DirectoryIndex index.phtml
# RewriteRule ^ index.phtml [QSA,L]
RewriteRule ^notas$ notes.phtml [L,NC]
RewriteRule ^tareas$ tasks.phtml [L,NC]
RewriteRule ^usuarios$ users.phtml [L,NC]
RewriteRule ^perfil$ profile.phtml [L,NC]
RewriteRule ^notas$ notes.php [L,NC]
RewriteRule ^tareas$ tasks.php [L,NC]
RewriteRule ^usuarios$ users.php [L,NC]
RewriteRule ^perfil$ profile.php [L,NC]
RewriteRule ^logout$ logout.php [L,NC]
11 changes: 3 additions & 8 deletions public/index.phtml → public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
header("Location: /perfil");
} */

if (isset($_GET['logout'])) {
new \App\Controller\User\Logout();
header("Location: /");
}

if (isset($_POST['login_email']) && isset($_POST['login_password'])) {
if (!empty($_POST['login_email']) && !empty($_POST['login_password'])) {
try {
Expand All @@ -31,11 +26,11 @@
}
?>

<?php require_once __DIR__ . '/partials/head.phtml'; ?>
<?php require_once __DIR__ . '/partials/head.php'; ?>

<body>
<div>
<?php require_once __DIR__ . '/partials/nav.phtml'; ?>
<?php require_once __DIR__ . '/partials/nav.php'; ?>
</div>

<h1>Inicio</h1>
Expand All @@ -51,7 +46,7 @@
</div>

<div>
<?php require_once __DIR__ . '/partials/footer.phtml'; ?>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
</div>
</body>

Expand Down
24 changes: 24 additions & 0 deletions public/logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
require __DIR__ . '/../src/App/App.php';

if (!isset($_SESSION)) {
session_start();
}

$_SESSION = array();
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 60 * 60,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
}
unset($_SESSION['user']);
session_destroy();
header('Location: /');
die();
23 changes: 23 additions & 0 deletions public/notes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

require __DIR__ . '/../src/App/App.php';

?>

<?php require_once __DIR__ . '/partials/head.php'; ?>

<body>
<div>
<?php require_once __DIR__ . '/partials/nav.php'; ?>
</div>

<h1>Notas</h1>

<div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
</div>
</body>

</html>
27 changes: 0 additions & 27 deletions public/notes.phtml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions public/partials/nav.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<nav>
<?php if (isset($_SESSION['user'])) { ?>
<ul>
<li><a href="/">Inicio</a></li>
<li><a href="/perfil">Perfil</a></li>
<li><a href="/usuarios">Usuarios</a></li>
<li><a href="/notas">Notas</a></li>
<li><a href="/tareas">Tareas</a></li>
<li><a href="/logout">Cerrar Sesión</a></li>
</ul>
<?php } else { ?>
<ul>
<li><a href="/">Inicio</a></li>
</ul>
<?php } ?>
</nav>
10 changes: 0 additions & 10 deletions public/partials/nav.phtml

This file was deleted.

23 changes: 23 additions & 0 deletions public/profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

require __DIR__ . '/../src/App/App.php';

?>

<?php require_once __DIR__ . '/partials/head.php'; ?>

<body>
<div>
<?php require_once __DIR__ . '/partials/nav.php'; ?>
</div>

<h1>Perfil</h1>

<div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
</div>
</body>

</html>
27 changes: 0 additions & 27 deletions public/profile.phtml

This file was deleted.

23 changes: 23 additions & 0 deletions public/tasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

require __DIR__ . '/../src/App/App.php';

?>

<?php require_once __DIR__ . '/partials/head.php'; ?>

<body>
<div>
<?php require_once __DIR__ . '/partials/nav.php'; ?>
</div>

<h1>Tareas</h1>

<div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
</div>
</body>

</html>
27 changes: 0 additions & 27 deletions public/tasks.phtml

This file was deleted.

23 changes: 23 additions & 0 deletions public/users.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

require __DIR__ . '/../src/App/App.php';

?>

<?php require_once __DIR__ . '/partials/head.php'; ?>

<body>
<div>
<?php require_once __DIR__ . '/partials/nav.php'; ?>
</div>

<h1>Usuarios</h1>

<div>
<?php require_once __DIR__ . '/partials/footer.php'; ?>
</div>
</body>

</html>
27 changes: 0 additions & 27 deletions public/users.phtml

This file was deleted.

20 changes: 12 additions & 8 deletions src/Controller/Note/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,30 @@
namespace App\Controller\Note;

use App\Controller\BaseController;
use App\Service\Note\Find;
use App\Service\Note\Create;
use App\Service\Note\Update;
use App\Service\Note\Delete;

abstract class Base extends BaseController
{
protected function getServiceFindNote(): \App\Service\Note\Find
protected function getServiceFindNote(): Find
{
return new \App\Service\Note\Find($this->_noteRepository);
return new Find($this->_noteRepository);
}

protected function getServiceCreateNote(): \App\Service\Note\Create
protected function getServiceCreateNote(): Create
{
return new \App\Service\Note\Create($this->_noteRepository);
return new Create($this->_noteRepository);
}

protected function getServiceUpdateNote(): \App\Service\Note\Update
protected function getServiceUpdateNote(): Update
{
return new \App\Service\Note\Update($this->_noteRepository);
return new Update($this->_noteRepository);
}

protected function getServiceDeleteNote(): \App\Service\Note\Delete
protected function getServiceDeleteNote(): Delete
{
return new \App\Service\Note\Delete($this->_noteRepository);
return new Delete($this->_noteRepository);
}
}
Loading

0 comments on commit b7eb69a

Please sign in to comment.