MVC PHP, , PHP.
, - Command + Factory.
.
interface ControllerCommand
{
public function execute($action);
}
:
class UserController implements ControllerCommand
{
public function execute($action)
{
if ($action == 'login')
{
$data['view_file'] = 'views/home.tpl.php';
}
else if ($action == 'edit_profile')
{
$data['view_file'] = 'views/profile.tpl.php';
$data['registration_status'] = $this->editProfile();
}
return $data;
}
}
:
$data = ControllerCommandFactory::execute($action);
if (!is_null($data)) { extract($data); }
require $view_file;
, Controllercommand execute .
MVC , theodore [at] phpexperts.pro.