You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.1 KiB

<?php
/**
* @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru
* @package Majestic
* @subpackage app
* @since 2010-02-25
* @version SVN: $Id$
* @filesource $URL$
*/
abstract class Action
{
public function __construct()
{
$this->extractParams();
$this->execute();
}
protected function extractParams()
{
$params = FrontController::getInstance()->getRouter()->getRoute()->getParams();
if ($params) {
foreach ($params as $name => $value) {
if (is_string($name)) {
$this->$name = $value;
}
}
}
}
abstract protected function execute();
/**
* Redirect
*
* @param mixed $url
* @param mixed $relative Default to true
*/
protected function redirect($url = null, $relative = true)
{
$url = ($url) ? $url : Env::getRequestUri();
if ($relative) {
$url = FrontController::getInstance()->getBaseUrl() . $url;
}
header('Location: ' . $url);
exit();
}
}