Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bfe145d

Browse files
Controller para el cliente
1 parent 0601665 commit bfe145d

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
/**
3+
* Home controller
4+
*/
5+
class HomeController extends Controller
6+
{
7+
/**
8+
* Home controller
9+
*/
10+
public function __construct()
11+
{
12+
var_dump(__CLASS__);
13+
}
14+
15+
/**
16+
* Método estándar
17+
*/
18+
public function exec()
19+
{
20+
echo '<h1>Hola mundo!</h1>';
21+
}
22+
}

‎index.php‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
print_r($router->getUri());
88
echo '</pre>';
99

10-
$controlador = $router->getController();
10+
$controller = $router->getController();
1111
$method = $router->getMethod();
1212
$param = $router->getParam();
13-
echo "Controlador: {$controlador} </br>";
13+
echo "Controlador: {$controller} </br>";
1414
echo "Método: {$method} </br>";
1515
echo "Param: {$param} </br>";
1616

17-
$controller = new $controlador();
17+
require PATH_CONTROLLERS . "{$controller}/{$controller}Controller.php";
18+
$controller .= 'Controller';
19+
20+
$controller = new $controller;
21+
1822
$controller->$method();

‎system/config.php‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// Valores de rutas
1010
/////////////////////////////////////
1111

12+
define('PATH_CONTROLLERS', 'app/controllers/');
13+
1214
//////////////////////////////////////
1315
// Valores de core
1416
/////////////////////////////////////

‎system/core/Controller.php‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Controlador base
44
*/
5-
class Controller
5+
abstractclass Controller
66
{
77
/**
88
* @var object
@@ -14,14 +14,11 @@ class Controller
1414
*/
1515
public function __construct()
1616
{
17-
echo__CLASS__ . ' instanciado';
17+
1818
}
1919

2020
/**
2121
* Metodo estándar
2222
*/
23-
public function exec()
24-
{
25-
echo '</br>Ejecutando método exec()</br>';
26-
}
23+
abstract public function exec();
2724
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /