Add namespace.

This commit is contained in:
2014-06-02 18:58:49 +04:00
parent aec1a60985
commit 1ba341b064
159 changed files with 265 additions and 264 deletions

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -13,7 +13,7 @@ abstract class Action
protected $template; protected $template;
/** /**
* @var PHPView * @var \Majestic\View\PHPView
*/ */
protected $view; protected $view;
@ -26,7 +26,7 @@ abstract class Action
protected function extractParams() protected function extractParams()
{ {
foreach (Env::getParam() as $name => $value) { foreach (\Majestic\Env::getParam() as $name => $value) {
if (is_string($name)) { if (is_string($name)) {
$this->$name = $value; $this->$name = $value;
} }
@ -46,7 +46,7 @@ abstract class Action
if ($permanently) { if ($permanently) {
header('HTTP/1.1 301 Moved Permanently'); header('HTTP/1.1 301 Moved Permanently');
} }
header('Location: ' . (($url) ? $url : Env::getRequestUri())); header('Location: ' . (($url) ? $url : \Majestic\Env::getRequestUri()));
exit(); exit();
} }
@ -54,7 +54,7 @@ abstract class Action
{ {
$class = get_class($this); $class = get_class($this);
$template = ($this->template) ? $this->template : substr($class, 0, -6 /*strlen('Action')*/); $template = ($this->template) ? $this->template : substr($class, 0, -6 /*strlen('Action')*/);
$dir = array_slice(explode('/', Load::getFilePath($class)), -2, 1); $dir = array_slice(explode('/', \Majestic\Load::getFilePath($class)), -2, 1);
return '/actions/' . array_pop($dir) . '/' . $template; return '/actions/' . array_pop($dir) . '/' . $template;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* AjaxAction * AjaxAction
* *

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -11,7 +11,7 @@ class ErrorAction extends Action
{ {
/** /**
* @var ErrorException|ErrorHTTPException * @var \ErrorException|\Majestic\Exception\ErrorHTTPException
*/ */
public $exception; public $exception;
@ -25,9 +25,9 @@ class ErrorAction extends Action
protected function execute() protected function execute()
{ {
if ($this->exception instanceof Error404Exception) { if ($this->exception instanceof \Majestic\Exception\Error404Exception) {
$this->template = 404; $this->template = 404;
} elseif ($this->exception instanceof ErrorHTTPException) { } elseif ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
$this->template = 'HTTP'; $this->template = 'HTTP';
} else { } else {
$this->template = 500; $this->template = 500;
@ -51,7 +51,7 @@ class ErrorAction extends Action
protected function sendHttpCode() protected function sendHttpCode()
{ {
if ($this->exception instanceof ErrorHTTPException) { if ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
header($this->exception->getHTTPHeader()); header($this->exception->getHTTPHeader());
} else { } else {
header('HTTP/1.0 500 Internal Server Error'); header('HTTP/1.0 500 Internal Server Error');
@ -60,8 +60,8 @@ class ErrorAction extends Action
protected function logError() protected function logError()
{ {
if (!$this->exception instanceof Error404Exception) { if (!$this->exception instanceof \Majestic\Exception\Error404Exception) {
ErrorHandler::logError($this->exception); \Majestic\Exception\ErrorHandler::logError($this->exception);
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -10,14 +10,14 @@
class FrontController class FrontController
{ {
/** /**
* @var Router * @var Router\Router
*/ */
protected $router; protected $router;
/** /**
* @var string * @var string
*/ */
protected $view = 'PHPView'; protected $view = '\Majestic\View\PHPView';
protected $base_url = ''; protected $base_url = '';
@ -30,7 +30,7 @@ class FrontController
private function __construct() private function __construct()
{ {
// ErrorHandler::init(); // ErrorHandler::init();
$this->router = new Router(); $this->router = new Router\Router();
} }
/** /**
@ -69,12 +69,12 @@ class FrontController
/** /**
* *
* @param null $view * @param null $view
* @return PHPView * @return ..\View\PHPView
*/ */
public function getView($view = null) public function getView($view = null)
{ {
$view = ($view) ? $view : $this->view; $view = ($view) ? $view : $this->view;
return new $view(Config::get($view)); return new $view(\Majestic\Config::get($view));
} }
/** /**
@ -93,7 +93,7 @@ class FrontController
} }
/** /**
* @return Router * @return Router\Router
*/ */
public function getRouter() public function getRouter()
{ {
@ -103,53 +103,53 @@ class FrontController
public function execute() public function execute()
{ {
try { try {
$request = Env::getRequestUri(true); $request = \Majestic\Env::getRequestUri(true);
$route = $this->getRouter()->route($request); $route = $this->getRouter()->route($request);
if (!$route) { if (!$route) {
throw new Error404Exception('Route for "' . $request . '" not found'); throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found');
} }
$action_class = $route->getAction(); $action_class = $route->getAction();
if (!class_exists($action_class)) { if (!class_exists($action_class)) {
throw new GeneralException('Action class "' . $action_class . '" not found.'); throw new \Majestic\Exception\GeneralException('Action class "' . $action_class . '" not found.');
} }
$action = new $action_class(); $action = new $action_class();
$layout_class = $route->getLayout(); $layout_class = $route->getLayout();
if (!class_exists($layout_class)) { if (!class_exists($layout_class)) {
throw new GeneralException('Layout class "' . $layout_class . '" not found.'); throw new \Majestic\Exception\GeneralException('Layout class "' . $layout_class . '" not found.');
} }
/** /**
* @var Layout $layout * @var \Majestic\Layout\Layout $layout
*/ */
$layout = new $layout_class(); $layout = new $layout_class();
$html = $layout->fetch($action); $html = $layout->fetch($action);
if (Config::get('PROFILER')) { if (\Majestic\Config::get('PROFILER')) {
if (is_subclass_of($action, 'AjaxAction')) { if (is_subclass_of($action, 'AjaxAction')) {
Profiler::getInstance()->getJson(); \Majestic\Util\Profiler\Profiler::getInstance()->getJson();
} else { } else {
$html = Profiler::getInstance()->end($html); $html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html);
} }
} }
return $html; return $html;
} }
catch (Exception $e) { catch (\Exception $e) {
if (Config::get('DEBUG')) { if (\Majestic\Config::get('DEBUG')) {
if (!headers_sent()) { if (!headers_sent()) {
if ($e instanceof ErrorHTTPException) { if ($e instanceof \Majestic\Exception\ErrorHTTPException) {
header($e->getHTTPHeader()); header($e->getHTTPHeader());
} else { } else {
header('HTTP/1.0 500 Internal Server Error'); header('HTTP/1.0 500 Internal Server Error');
} }
} }
ErrorHandler::logError($e); \Majestic\Exception\ErrorHandler::logError($e);
return ErrorHandler::showDebug($e); return \Majestic\Exception\ErrorHandler::showDebug($e);
} }
$layout_class = $this->getRouter()->getErrorLayout(); $layout_class = $this->getRouter()->getErrorLayout();
/** /**
* @var ErrorLayout $layout * @var \Majestic\Layout\ErrorLayout $layout
*/ */
$layout = new $layout_class(); $layout = new $layout_class();
$layout->setException($e); $layout->setException($e);

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App\Router;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-02-25 * @since 2010-02-25
*/ */
namespace Majestic;
class Route class Route
{ {

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App\Router;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -33,7 +33,7 @@ class Router
if (!$layout) { if (!$layout) {
$layout = $this->default_layout; $layout = $this->default_layout;
} }
$this->routes[$name] = new \Majestic\Route($route, $action, $params, $layout); $this->routes[$name] = new Route($route, $action, $params, $layout);
} }
/** /**
@ -48,7 +48,7 @@ class Router
if ($route->match($req)) { if ($route->match($req)) {
$this->route_name = $name; $this->route_name = $name;
$this->route = $route; $this->route = $route;
Env::setParams($route->getParams()); \Majestic\Env::setParams($route->getParams());
return $this->route; return $this->route;
} }
} }
@ -94,7 +94,7 @@ class Router
/** /**
* @param null|string $name * @param null|string $name
* @return Route * @return Route
* @throws ErrorException * @throws \ErrorException
*/ */
public function getRoute($name = null) public function getRoute($name = null)
{ {
@ -104,7 +104,7 @@ class Router
if ($this->routeIsExists($name)) { if ($this->routeIsExists($name)) {
return $this->getRouteByName($name); return $this->getRouteByName($name);
} else { } else {
throw new ErrorException('Unknown route name: "' . $name . '".'); throw new \ErrorException('Unknown route name: "' . $name . '".');
} }
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\App;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,9 +7,9 @@
* @since 2010-02-17 * @since 2010-02-17
*/ */
namespace Majestic;
class Config extends \Registry
class Config extends Registry
{ {
private static $_class_name = 'Config'; private static $_class_name = 'Config';
@ -33,7 +33,7 @@ class ConfigArray extends \ArrayObject
public function offsetGet($index) public function offsetGet($index)
{ {
if (!$this->offsetExists($index)) { if (!$this->offsetExists($index)) {
throw new \GeneralException('Configuration variable "' . $index . '" undefined'); throw new Exception\GeneralException('Configuration variable "' . $index . '" undefined');
} }
return parent::offsetGet($index); return parent::offsetGet($index);
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic;
/** /**
* Класс для работы с переменными окружения. * Класс для работы с переменными окружения.
* *
@ -23,7 +23,7 @@ class Env
list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI')); list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI'));
if ($trim_base) { if ($trim_base) {
// removes base url // removes base url
$base = FrontController::getInstance()->getBaseUrl(); $base = \Majestic\App\FrontController::getInstance()->getBaseUrl();
if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) { if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) {
self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length); self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length);
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -8,7 +8,7 @@
*/ */
class Error404Exception extends ErrorHTTPException { class Error404Exception extends ErrorHTTPException {
function __construct($message = '', $code = null, Exception $previous = NULL ) function __construct($message = '', $code = null, \Exception $previous = NULL )
{ {
parent::__construct($message, 404, $previous); parent::__construct($message, 404, $previous);
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -22,7 +22,7 @@ class ErrorHandler
ob_end_clean(); ob_end_clean();
} }
if (error_reporting() !== 0) { if (error_reporting() !== 0) {
throw new ErrorException($errstr, 0, $errno, $errfile, $errline); throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
} }
return true; return true;
} }
@ -31,7 +31,7 @@ class ErrorHandler
{ {
$error = 0; $error = 0;
$exception_name = ''; $exception_name = '';
if ($exception instanceof ErrorException) { if ($exception instanceof \ErrorException) {
$error = $exception->getSeverity(); $error = $exception->getSeverity();
} else { } else {
$exception_name = get_class($exception) . ': '; $exception_name = get_class($exception) . ': ';
@ -59,9 +59,9 @@ class ErrorHandler
static public function getHTTPErrorConditions() static public function getHTTPErrorConditions()
{ {
$text = null; $text = null;
if (!is_null(Env::Server('REQUEST_METHOD')) && !is_null(Env::Server('REQUEST_URI'))) { if (!is_null(\Majestic\Env::Server('REQUEST_METHOD')) && !is_null(\Majestic\Env::Server('REQUEST_URI'))) {
$text = ', URL: ' . Env::Server('REQUEST_METHOD') . ' ' . Env::Server('REQUEST_URI'); $text = ', URL: ' . \Majestic\Env::Server('REQUEST_METHOD') . ' ' . \Majestic\Env::Server('REQUEST_URI');
$text .= ', referrer: ' . Env::Server('HTTP_REFERER'); $text .= ', referrer: ' . \Majestic\Env::Server('HTTP_REFERER');
} }
return $text; return $text;
} }
@ -109,7 +109,7 @@ class ErrorHandler
} }
/** /**
* @param Exception $exception * @param \Exception $exception
* @return string * @return string
*/ */
static public function showDebug($exception) static public function showDebug($exception)
@ -120,19 +120,19 @@ class ErrorHandler
} }
$class = get_class($exception); $class = get_class($exception);
$method = Env::Server('REQUEST_METHOD', ''); $method = \Majestic\Env::Server('REQUEST_METHOD', '');
$uri = Env::getRequestUri(); $uri = \Majestic\Env::getRequestUri();
$source = self::getSource($exception->getFile(), $exception->getLine()); $source = self::getSource($exception->getFile(), $exception->getLine());
$time = date('r', Env::Server('REQUEST_TIME', time())); $time = date('r', \Majestic\Env::Server('REQUEST_TIME', time()));
$trace = nl2br($exception->getTraceAsString()); $trace = nl2br($exception->getTraceAsString());
$get = self::wrapArray(Env::Get(), 'GET'); $get = self::wrapArray(\Majestic\Env::Get(), 'GET');
$post = self::wrapArray(Env::Post(), 'POST'); $post = self::wrapArray(\Majestic\Env::Post(), 'POST');
$session = self::wrapArray(Session::get(), 'SESSION'); $session = self::wrapArray(\Majestic\Session\Session::get(), 'SESSION');
$files = self::wrapArray(Env::Files(), 'FILES'); $files = self::wrapArray(\Majestic\Env::Files(), 'FILES');
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE'); $cookies = self::wrapArray(\Majestic\Env::Cookie(), 'COOKIE');
$server = self::wrapArray(Env::Server(), 'SERVER'); $server = self::wrapArray(\Majestic\Env::Server(), 'SERVER');
$message = <<<EOD $message = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,4 +7,4 @@
* @since 2010-02-26 * @since 2010-02-26
*/ */
class GeneralException extends Exception {} class GeneralException extends \Exception {}

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Exception;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -9,4 +9,4 @@
* Exception from initializtion object * Exception from initializtion object
*/ */
class InitializationException extends Exception {} class InitializationException extends \Exception {}

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-04-24 * @since 2010-04-24
*/ */
namespace Majestic;
abstract class Form abstract class Form
{ {
@ -17,7 +15,7 @@ abstract class Form
const ERROR = 'error'; const ERROR = 'error';
/** /**
* @var \FormField[] * @var FormField[]
*/ */
protected $fields = array(); protected $fields = array();
@ -38,18 +36,18 @@ abstract class Form
/** /**
* @param string $name * @param string $name
* @param bool|string $message * @param bool|string $message
* @return \FormField * @return FormField
*/ */
protected function addField($name, $message = false) protected function addField($name, $message = false)
{ {
$this->fields[$name] = new \FormField($message); $this->fields[$name] = new FormField($message);
return $this->fields[$name]; return $this->fields[$name];
} }
public function isValid($data) public function isValid($data)
{ {
if (!is_array($data)) { if (!is_array($data)) {
throw new \InitializationException(__CLASS__ . '::' . __METHOD__ . ' expects an array'); throw new \Majestic\Exception\InitializationException(__CLASS__ . '::' . __METHOD__ . ' expects an array');
} }
foreach ($this->fields as $field_name => $field) { foreach ($this->fields as $field_name => $field) {

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -93,7 +93,7 @@ class FormField
} }
/** /**
* @param string[]|iValidator[] $validators * @param string[]|\Majestic\Validator\iValidator[] $validators
* @return FormField * @return FormField
*/ */
public function addValidators($validators) public function addValidators($validators)
@ -105,19 +105,19 @@ class FormField
} }
/** /**
* @param string|iValidator $validator * @param string|\Majestic\Validator\iValidator $validator
* @return FormField * @return FormField
* @throws InitializationException * @throws \Majestic\Exception\InitializationException
*/ */
public function addValidator($validator) public function addValidator($validator)
{ {
if ($validator instanceof iValidator) { if ($validator instanceof \Majestic\Validator\iValidator) {
$name = get_class($validator); $name = get_class($validator);
} elseif (is_string($validator)) { } elseif (is_string($validator)) {
$name = $validator . 'Validator'; $name = $validator . 'Validator';
$validator = new $name(); $validator = new $name();
} else { } else {
throw new InitializationException('Invalid validator provided to addValidator; must be string or iValidator'); throw new \Majestic\Exception\InitializationException('Invalid validator provided to addValidator; must be string or iValidator');
} }
$this->validators[$name] = $validator; $this->validators[$name] = $validator;
return $this; return $this;
@ -139,7 +139,7 @@ class FormField
$name = $filter . 'Filter'; $name = $filter . 'Filter';
$filter = new $name(); $filter = new $name();
} else { } else {
throw new InitializationException('Invalid filter provided to addFilter; must be string or iFilter'); throw new \Majestic\Exception\InitializationException('Invalid filter provided to addFilter; must be string or iFilter');
} }
$this->filters[$name] = $filter; $this->filters[$name] = $filter;
return $this; return $this;
@ -192,7 +192,7 @@ class FormField
if (!$validator->isValid($val, $context)) { if (!$validator->isValid($val, $context)) {
$valid = false; $valid = false;
if (!$this->default_message) { if (!$this->default_message) {
throw new InitializationException('Define default message for array fields'); throw new \Majestic\Validator\InitializationException('Define default message for array fields');
} }
$this->message = $this->default_message; $this->message = $this->default_message;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Form;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -16,10 +16,10 @@ class FormViewHelper extends ViewHelper
{ {
if ($this->data === null) { if ($this->data === null) {
if ($form == null) { if ($form == null) {
throw new InitializationException('Form name required for helper init'); throw new \Majestic\ExceptionInitializationException('Form name required for helper init');
} }
$this->data = Session::get($form, array()); $this->data = \Majestic\Session\Session::get($form, array());
Session::del($form); \Majestic\Session\Session::del($form);
} }
return $this; return $this;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Layout;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -10,7 +10,7 @@
class ErrorLayout extends Layout class ErrorLayout extends Layout
{ {
/** /**
* @var GeneralException * @var \Majestic\ExceptionGeneralException
*/ */
protected $exception; protected $exception;
@ -19,9 +19,9 @@ class ErrorLayout extends Layout
} }
/** /**
* @param Exception $exception * @param \Exception $exception
*/ */
public function setException(Exception $exception) public function setException(\Exception $exception)
{ {
$this->exception = $exception; $this->exception = $exception;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Layout;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -13,18 +13,18 @@ abstract class Layout
protected $template; protected $template;
/** /**
* @var PHPView * @var \Majestic\View\PHPView
*/ */
protected $view; protected $view;
public function __construct() public function __construct()
{ {
$this->view = FrontController::getInstance()->getView(); $this->view = \Majestic\App\FrontController::getInstance()->getView();
} }
/** /**
* @param string $name * @param string $name
* @param Action $action * @param \Majestic\App\Action $action
*/ */
protected function assign($name, $action) protected function assign($name, $action)
{ {
@ -34,7 +34,7 @@ abstract class Layout
/** /**
* @param string $name * @param string $name
* @param Action $action * @param \Majestic\App\Action $action
*/ */
protected function append($name, $action) protected function append($name, $action)
{ {
@ -44,7 +44,7 @@ abstract class Layout
/** /**
* @param string $name * @param string $name
* @param Action $action * @param \Majestic\App\Action $action
*/ */
protected function prepend($name, $action) protected function prepend($name, $action)
{ {
@ -55,7 +55,7 @@ abstract class Layout
/** /**
* Execute Action, insert action's result html into layout template and return Layout html * Execute Action, insert action's result html into layout template and return Layout html
* @param Action $action * @param \Majestic\App\Action $action
* @return string * @return string
*/ */
public function fetch($action) public function fetch($action)

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -18,6 +18,15 @@ class Load
static protected $builder = null; static protected $builder = null;
/**
* @var \Composer\Autoload\ClassLoader
*/
static protected $class_loader;
static public function setClassLoader($class_loader) {
self::$class_loader = $class_loader;
}
/** /**
* Add exclude path for autoload. Should be called before setAutoloadFrom * Add exclude path for autoload. Should be called before setAutoloadFrom
* @static * @static
@ -62,7 +71,11 @@ class Load
static public function getFilePath($class) static public function getFilePath($class)
{ {
return self::$autoload[$class]; if (self::$class_loader) {
return self::$class_loader->findFile($class);
} else {
return self::$autoload[$class];
}
} }
static protected function buildAutoload() static protected function buildAutoload()

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -20,7 +20,7 @@ class FileLogger extends Logger
protected function __construct() protected function __construct()
{ {
$this->file_path = Config::get('Logger')->filepath; $this->file_path = \Majestic\Config::get('Logger')->filepath;
} }
protected function generateOutString($message) protected function generateOutString($message)
@ -35,7 +35,7 @@ class FileLogger extends Logger
if (!$this->handler) { if (!$this->handler) {
$this->handler = @fopen($this->file_path, "a"); $this->handler = @fopen($this->file_path, "a");
if (!$this->handler) { if (!$this->handler) {
throw new GeneralException('Could not open file ' . $this->file_path); throw new \Majestic\Exception\GeneralException('Could not open file ' . $this->file_path);
} }
} }
fwrite($this->handler, $out); fwrite($this->handler, $out);

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Logger;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -31,7 +31,7 @@ abstract class Logger
{ {
if (static::$_instance === null) { if (static::$_instance === null) {
//$class = get_called_class(); //$class = get_called_class();
$class = Config::get('Logger')->logger; $class = \Majestic\Config::get('Logger')->logger;
static::$_instance = new $class(); static::$_instance = new $class();
} }
return static::$_instance; return static::$_instance;
@ -43,7 +43,7 @@ abstract class Logger
*/ */
public function log($message) public function log($message)
{ {
if (Config::get('LOGGING')) { if (\Majestic\Config::get('LOGGING')) {
$this->concreteLog($message); $this->concreteLog($message);
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-02-16 * @since 2010-02-16
*/ */
namespace Majestic;
class Db class Db
{ {
@ -31,23 +29,23 @@ class Db
* @param array $config Configuration array. * @param array $config Configuration array.
* *
* @return DbDriver * @return DbDriver
* @throws InitializationException * @throws \Majestic\Exception\InitializationException
*/ */
static public function connect($name = 'default', $config = null) static public function connect($name = 'default', $config = null)
{ {
if (!isset(self::$connections[$name])) { if (!isset(self::$connections[$name])) {
if (!$config) { if (!$config) {
if (!is_object(\Majestic\Config::get(__CLASS__))) { if (!is_object(\Majestic\Config::get(__CLASS__))) {
throw new \InitializationException('Trying to get property of non-object'); throw new \Majestic\Exception\InitializationException('Trying to get property of non-object');
} }
$config = \Majestic\Config::get(__CLASS__)->$name; $config = \Majestic\Config::get(__CLASS__)->$name;
} }
if (!is_array($config)) { if (!is_array($config)) {
throw new \InitializationException('Connection parameters must be an array'); throw new \Majestic\Exception\InitializationException('Connection parameters must be an array');
} }
$driver = 'MySQLiDriver'; $driver = '\Majestic\Model\MySQLiDriver';
if (isset($config['driver'])) { if (isset($config['driver'])) {
$driver = $config['driver']; $driver = $config['driver'];
unset($config['driver']); unset($config['driver']);
@ -55,8 +53,8 @@ class Db
$connection = new $driver($config); $connection = new $driver($config);
if (!$connection instanceof \DbDriver) { if (!$connection instanceof DbDriver) {
throw new \InitializationException('Database driver must extends DbDriver'); throw new \Majestic\Exception\InitializationException('Database driver must extends DbDriver');
} }
self::$connections[$name] = $connection; self::$connections[$name] = $connection;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -36,7 +36,7 @@ abstract class DbDriver
$required = array('database', 'username', 'password', 'hostname'); $required = array('database', 'username', 'password', 'hostname');
foreach ($required as $option) { foreach ($required as $option) {
if (!isset($config[$option])) { if (!isset($config[$option])) {
throw new GeneralException('Configuration must have a "' . $option . '".'); throw new \GeneralException('Configuration must have a "' . $option . '".');
} }
} }
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -53,7 +53,7 @@ abstract class DbStatement
* @param mixed $style * @param mixed $style
* @return array * @return array
*/ */
public function fetchAll($style = \Majestic\Db::FETCH_OBJ) public function fetchAll($style = Db::FETCH_OBJ)
{ {
$data = array(); $data = array();
while ($row = $this->fetch($style)) { while ($row = $this->fetch($style)) {
@ -69,7 +69,7 @@ abstract class DbStatement
public function fetchColumn($field) public function fetchColumn($field)
{ {
$data = array(); $data = array();
while ($row = $this->fetch(\Majestic\Db::FETCH_ASSOC)) { while ($row = $this->fetch(Db::FETCH_ASSOC)) {
$data[] = $row[$field]; $data[] = $row[$field];
} }
return $data; return $data;
@ -81,7 +81,7 @@ abstract class DbStatement
*/ */
public function fetchField($field) public function fetchField($field)
{ {
$row = $this->fetch(\Majestic\Db::FETCH_ASSOC); $row = $this->fetch(Db::FETCH_ASSOC);
if (isset($row[$field])) { if (isset($row[$field])) {
return $row[$field]; return $row[$field];
} }
@ -94,7 +94,7 @@ abstract class DbStatement
abstract protected function assemble(); abstract protected function assemble();
abstract public function fetch($style = \Majestic\Db::FETCH_OBJ); abstract public function fetch($style = Db::FETCH_OBJ);
abstract public function fetchObject($class = 'stdClass'); abstract public function fetchObject($class = 'stdClass');

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* Класс модели данных * Класс модели данных
@ -10,15 +10,13 @@
* @since 2010-02-16 * @since 2010-02-16
*/ */
namespace Majestic;
abstract class Model abstract class Model
{ {
/** /**
* DbDriver instance * DbDriver instance
* *
* @var \DbDriver * @var DbDriver
*/ */
protected $db; protected $db;
@ -50,7 +48,7 @@ abstract class Model
public function __construct($connection = 'default') public function __construct($connection = 'default')
{ {
$this->db = \Majestic\Db::connect($connection); $this->db = Db::connect($connection);
} }
/** /**
@ -101,7 +99,7 @@ abstract class Model
public function getCache() public function getCache()
{ {
if (!$this->cache) { if (!$this->cache) {
$this->cache = \Cacher::get(Config::get(__CLASS__, 'MemcacheCache')); $this->cache = \Cacher::get(\Majestic\Config::get(__CLASS__, 'MemcacheCache'));
} }
return $this->cache; return $this->cache;
} }

View File

@ -49,14 +49,14 @@ abstract class MongoDbCommand
* Execute Mongo command/query * Execute Mongo command/query
* *
* @return mixed * @return mixed
* @throws GeneralException * @throws \Majestic\Exception\GeneralException
*/ */
public function execute() public function execute()
{ {
if ($this->checkParams()) { if ($this->checkParams()) {
return $this->concreteExecute(); return $this->concreteExecute();
} else { } else {
throw new GeneralException(get_called_class() . ' error. Bind all required params first.'); throw new \Majestic\Exception\GeneralException(get_called_class() . ' error. Bind all required params first.');
} }
} }

View File

@ -159,7 +159,7 @@ abstract class MongoModel extends Model
/** /**
* @param array $params Parameters for find query * @param array $params Parameters for find query
* @return array Query result sort rules * @return array Query result sort rules
* @throws GeneralException * @throws \Majestic\Exception\GeneralException
* */ * */
private function getOrder($params = array()) private function getOrder($params = array())
{ {
@ -170,7 +170,7 @@ abstract class MongoModel extends Model
} elseif (is_array($params['order'])) { } elseif (is_array($params['order'])) {
$order = $params['order']; $order = $params['order'];
} else { } else {
throw new GeneralException('Wrong order parameter given to query.'); throw new \Majestic\Exception\GeneralException('Wrong order parameter given to query.');
} }
} }
return $order; return $order;
@ -179,7 +179,7 @@ abstract class MongoModel extends Model
/** /**
* @param array $params Parameters for find query * @param array $params Parameters for find query
* @return array Query result sort rules * @return array Query result sort rules
* @throws GeneralException * @throws \Majestic\Exception\GeneralException
* */ * */
private function getFields($params) private function getFields($params)
{ {
@ -196,7 +196,7 @@ abstract class MongoModel extends Model
$fields = $params['fields']; $fields = $params['fields'];
} }
} else { } else {
throw new GeneralException('Wrong fields parameter given to query.'); throw new \Majestic\Exception\GeneralException('Wrong fields parameter given to query.');
} }
} }
return $fields; return $fields;

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -8,7 +8,7 @@
*/ */
/** /**
* @property MySQLi $connection * @property \MySQLi $connection
*/ */
class MySQLiDriver extends SqlDbDriver class MySQLiDriver extends SqlDbDriver
{ {
@ -51,7 +51,7 @@ class MySQLiDriver extends SqlDbDriver
public function isConnected() public function isConnected()
{ {
return ($this->connection instanceof MySQLi); return ($this->connection instanceof \MySQLi);
} }
public function disconnect() public function disconnect()

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -9,7 +9,7 @@
/** /**
* @property MySQLiDriver $driver * @property MySQLiDriver $driver
* @property MySQLi_Result $result * @property \MySQLi_Result $result
*/ */
class MySQLiStatement extends DbStatement class MySQLiStatement extends DbStatement
{ {
@ -23,10 +23,10 @@ class MySQLiStatement extends DbStatement
} }
if (count($this->map) > 0) { if (count($this->map) > 0) {
if (!is_string($param) && !is_int($param)) { if (!is_string($param) && !is_int($param)) {
throw new GeneralException('Placeholder must be an integer or string'); throw new \Majestic\Exception\GeneralException('Placeholder must be an integer or string');
} }
if (is_object($value) && ! ($value instanceof DbExpr)) { if (is_object($value) && ! ($value instanceof DbExpr)) {
throw new GeneralException('Objects excepts DbExpr not allowed.'); throw new \Majestic\Exception\GeneralException('Objects excepts DbExpr not allowed.');
} }
if (isset($this->map[$param])) { if (isset($this->map[$param])) {
$this->params[$param] = &$value; $this->params[$param] = &$value;
@ -81,29 +81,29 @@ class MySQLiStatement extends DbStatement
* *
* @param mixed $style * @param mixed $style
* @return mixed * @return mixed
* @throws GeneralException * @throws \Majestic\Exception\GeneralException
*/ */
public function fetch($style = \Majestic\Db::FETCH_OBJ) public function fetch($style = Db::FETCH_OBJ)
{ {
if (!$this->result) { if (!$this->result) {
return false; return false;
} }
switch ($style) { switch ($style) {
case \Majestic\Db::FETCH_OBJ: case Db::FETCH_OBJ:
$row = $this->result->fetch_object(); $row = $this->result->fetch_object();
break; break;
case \Majestic\Db::FETCH_NUM: case Db::FETCH_NUM:
$row = $this->result->fetch_array(MYSQLI_NUM); $row = $this->result->fetch_array(MYSQLI_NUM);
break; break;
case \Majestic\Db::FETCH_ASSOC: case Db::FETCH_ASSOC:
$row = $this->result->fetch_assoc(); $row = $this->result->fetch_assoc();
break; break;
case \Majestic\Db::FETCH_BOTH: case Db::FETCH_BOTH:
$row = $this->result->fetch_array(MYSQLI_BOTH); $row = $this->result->fetch_array(MYSQLI_BOTH);
break; break;
default: default:
throw new GeneralException('Invalid fetch mode "' . $style . '" specified'); throw new \Majestic\Exception\GeneralException('Invalid fetch mode "' . $style . '" specified');
} }
return $row; return $row;
} }
@ -123,7 +123,7 @@ class MySQLiStatement extends DbStatement
public function fetchPairs() public function fetchPairs()
{ {
$data = array(); $data = array();
while ($row = $this->fetch(\Majestic\Db::FETCH_NUM)) { while ($row = $this->fetch(Db::FETCH_NUM)) {
$data[$row[0]] = $row[1]; $data[$row[0]] = $row[1];
} }
return $data; return $data;
@ -158,11 +158,11 @@ class MySQLiStatement extends DbStatement
protected function driverExecute($request) protected function driverExecute($request)
{ {
/** /**
* @var MySQLi * @var \MySQLi
*/ */
$mysqli = $this->driver->getConnection(); $mysqli = $this->driver->getConnection();
if (Config::get('PROFILER_DETAILS')) { if (\Majestic\Config::get('PROFILER_DETAILS')) {
$profiler = Profiler::getInstance()->profilerCommand('MySQL', $request); $profiler = \Majestic\Util\Profiler\Profiler::getInstance()->profilerCommand('MySQL', $request);
$result = $mysqli->query($request); $result = $mysqli->query($request);
$profiler->end(); $profiler->end();
} else { } else {
@ -170,9 +170,9 @@ class MySQLiStatement extends DbStatement
} }
if ($result === false) { if ($result === false) {
$message = $mysqli->error . "\nQuery: \"" . $request . '"'; $message = $mysqli->error . "\nQuery: \"" . $request . '"';
throw new GeneralException($message, $mysqli->errno); throw new \Majestic\Exception\GeneralException($message, $mysqli->errno);
} }
if ($result instanceof MySQLi_Result) { if ($result instanceof \MySQLi_Result) {
$this->result = $result; $this->result = $result;
} }
return true; return true;

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
class SqlCriteria class SqlCriteria
{ {

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -129,7 +129,7 @@ abstract class SqlDbDriver extends DbDriver
/** /**
* @param mixed $where * @param mixed $where
* @return string * @return string
* @throws ErrorException * @throws \ErrorException
*/ */
public function whereExpr($where) public function whereExpr($where)
{ {
@ -143,7 +143,7 @@ abstract class SqlDbDriver extends DbDriver
foreach ($where as $cond => &$term) { foreach ($where as $cond => &$term) {
if (is_int($cond)) { if (is_int($cond)) {
if (is_int($term)) { if (is_int($term)) {
throw new ErrorException('Condition in where expression as integer. ' . $term); throw new \ErrorException('Condition in where expression as integer. ' . $term);
} }
if ($term instanceof DbExpr) { if ($term instanceof DbExpr) {
$term = (string) $term; $term = (string) $term;
@ -164,7 +164,7 @@ abstract class SqlDbDriver extends DbDriver
/** /**
* @param mixed $group_by * @param mixed $group_by
* @return string * @return string
* @throws ErrorException * @throws \ErrorException
*/ */
public function groupByExpr($group_by) public function groupByExpr($group_by)
{ {

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
/** /**
* Класс модели данных * Класс модели данных
@ -13,7 +13,7 @@
/** /**
* @property SqlDbDriver $db * @property SqlDbDriver $db
*/ */
abstract class SqlModel extends \Majestic\Model abstract class SqlModel extends Model
{ {
/** /**
* @param string $ident * @param string $ident

View File

@ -1,6 +1,6 @@
<?php <?php namespace Majestic\Model;
class SqlResultCollection extends ArrayIterator implements iSqlResultItems class SqlResultCollection extends \ArrayIterator implements iSqlResultItems
{ {
private $items; private $items;

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
class SqlResultProvider implements iSqlResultItems class SqlResultProvider implements iSqlResultItems
{ {
@ -38,7 +38,7 @@ class SqlResultProvider implements iSqlResultItems
* @param $field string * @param $field string
* @param bool $assoc_as_array * @param bool $assoc_as_array
* @return $this SqlResultProvider * @return $this SqlResultProvider
* @throws ErrorException * @throws \ErrorException
*/ */
public function assoc($field, $assoc_as_array = false) public function assoc($field, $assoc_as_array = false)
{ {
@ -46,7 +46,7 @@ class SqlResultProvider implements iSqlResultItems
$result_items_assoc = array(); $result_items_assoc = array();
foreach ($this->result_items_base as $item) { foreach ($this->result_items_base as $item) {
if (!isset($item->{$field})) { if (!isset($item->{$field})) {
throw new ErrorException('Undefined field. ' . $field); throw new \ErrorException('Undefined field. ' . $field);
} }
if ($assoc_as_array) { if ($assoc_as_array) {
if (!isset($result_items_assoc[$item->{$field}])) { if (!isset($result_items_assoc[$item->{$field}])) {
@ -55,7 +55,7 @@ class SqlResultProvider implements iSqlResultItems
$result_items_assoc[$item->{$field}][] = $item; $result_items_assoc[$item->{$field}][] = $item;
} else { } else {
if (isset($result_items_assoc[$item->{$field}])) { if (isset($result_items_assoc[$item->{$field}])) {
throw new ErrorException('Field not unique. May be use assoc_as_array. ' . $field); throw new \ErrorException('Field not unique. May be use assoc_as_array. ' . $field);
} }
$result_items_assoc[$item->{$field}] = $item; $result_items_assoc[$item->{$field}] = $item;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Model;
interface iSqlResultItems interface iSqlResultItems
{ {

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Redis;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Redis;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -23,7 +23,7 @@ class RedisManager
* @param string $name connection name. If not set 'default' will be used. * @param string $name connection name. If not set 'default' will be used.
* @param array $config Configuration array. * @param array $config Configuration array.
* *
* @throws GeneralException * @throws \Majestic\Exception\GeneralException
* @return Redis * @return Redis
*/ */
static public function connect($name = 'default', $config = null) static public function connect($name = 'default', $config = null)
@ -31,13 +31,13 @@ class RedisManager
if (!isset(self::$connections[$name])) { if (!isset(self::$connections[$name])) {
if (!$config) { if (!$config) {
if (!is_object(\Majestic\Config::get('Redis'))) { if (!is_object(\Majestic\Config::get('Redis'))) {
throw new GeneralException('Redis config no existence'); throw new \Majestic\Exception\GeneralException('Redis config no existence');
} }
$config = \Majestic\Config::get('Redis')->$name; $config = \Majestic\Config::get('Redis')->$name;
} }
if (!is_array($config)) { if (!is_array($config)) {
throw new GeneralException('Connection parameters must be an array'); throw new \Majestic\Exception\GeneralException('Connection parameters must be an array');
} }
$host = isset($config['host']) ? $config['host'] : 'localhost'; $host = isset($config['host']) ? $config['host'] : 'localhost';
@ -47,16 +47,16 @@ class RedisManager
/** /**
* @var Redis * @var Redis
*/ */
$connection = new Redis(); $connection = new \Redis();
if (Config::get('PROFILER_DETAILS')) { if (\Majestic\Config::get('PROFILER_DETAILS')) {
$connection = new RedisDebug($connection); $connection = new RedisDebug($connection);
} }
if (!$connection->connect($host, $port)) { if (!$connection->connect($host, $port)) {
throw new GeneralException('Failed to connect to Redis server at ' . $host . ':' . $port); throw new \Majestic\Exception\GeneralException('Failed to connect to Redis server at ' . $host . ':' . $port);
} }
if ($database) { if ($database) {
if (!$connection->select($database)) { if (!$connection->select($database)) {
throw new GeneralException('Failed to select Redis database with index ' . $database); throw new \Majestic\Exception\GeneralException('Failed to select Redis database with index ' . $database);
} }
} }
self::$connections[$name] = $connection; self::$connections[$name] = $connection;

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Redis;
/** /**
* *
* *

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,7 +7,7 @@
* @since 2010-02-17 * @since 2010-02-17
*/ */
class Registry extends ArrayObject class Registry extends \ArrayObject
{ {
/** /**
* Class name of the singleton registry object. * Class name of the singleton registry object.
@ -53,7 +53,7 @@ class Registry extends ArrayObject
public static function getInstance() public static function getInstance()
{ {
if (self::$_registry === null) { if (self::$_registry === null) {
self::$_registry = new self::$_class_name(); self::$_registry = new \Majestic\Registry();
} }
return self::$_registry; return self::$_registry;
} }

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru

View File

@ -1,4 +1,4 @@
<?php <?php namespace Majestic\Session;
/** /**
* @copyright NetMonsters <team@netmonsters.ru> * @copyright NetMonsters <team@netmonsters.ru>
* @link http://netmonsters.ru * @link http://netmonsters.ru
@ -7,8 +7,6 @@
* @since 2010-03-14 * @since 2010-03-14
*/ */
namespace Majestic;
class Session class Session
{ {
/** /**

Some files were not shown because too many files have changed in this diff Show More