Add namespace.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -13,7 +13,7 @@ abstract class Action
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var PHPView
|
||||
* @var \Majestic\View\PHPView
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
@ -26,7 +26,7 @@ abstract class Action
|
||||
|
||||
protected function extractParams()
|
||||
{
|
||||
foreach (Env::getParam() as $name => $value) {
|
||||
foreach (\Majestic\Env::getParam() as $name => $value) {
|
||||
if (is_string($name)) {
|
||||
$this->$name = $value;
|
||||
}
|
||||
@ -46,7 +46,7 @@ abstract class Action
|
||||
if ($permanently) {
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
}
|
||||
header('Location: ' . (($url) ? $url : Env::getRequestUri()));
|
||||
header('Location: ' . (($url) ? $url : \Majestic\Env::getRequestUri()));
|
||||
exit();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ abstract class Action
|
||||
{
|
||||
$class = get_class($this);
|
||||
$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;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* AjaxAction
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -11,7 +11,7 @@ class ErrorAction extends Action
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ErrorException|ErrorHTTPException
|
||||
* @var \ErrorException|\Majestic\Exception\ErrorHTTPException
|
||||
*/
|
||||
public $exception;
|
||||
|
||||
@ -25,9 +25,9 @@ class ErrorAction extends Action
|
||||
|
||||
protected function execute()
|
||||
{
|
||||
if ($this->exception instanceof Error404Exception) {
|
||||
if ($this->exception instanceof \Majestic\Exception\Error404Exception) {
|
||||
$this->template = 404;
|
||||
} elseif ($this->exception instanceof ErrorHTTPException) {
|
||||
} elseif ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
|
||||
$this->template = 'HTTP';
|
||||
} else {
|
||||
$this->template = 500;
|
||||
@ -51,7 +51,7 @@ class ErrorAction extends Action
|
||||
|
||||
protected function sendHttpCode()
|
||||
{
|
||||
if ($this->exception instanceof ErrorHTTPException) {
|
||||
if ($this->exception instanceof \Majestic\Exception\ErrorHTTPException) {
|
||||
header($this->exception->getHTTPHeader());
|
||||
} else {
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
@ -60,8 +60,8 @@ class ErrorAction extends Action
|
||||
|
||||
protected function logError()
|
||||
{
|
||||
if (!$this->exception instanceof Error404Exception) {
|
||||
ErrorHandler::logError($this->exception);
|
||||
if (!$this->exception instanceof \Majestic\Exception\Error404Exception) {
|
||||
\Majestic\Exception\ErrorHandler::logError($this->exception);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -10,14 +10,14 @@
|
||||
class FrontController
|
||||
{
|
||||
/**
|
||||
* @var Router
|
||||
* @var Router\Router
|
||||
*/
|
||||
protected $router;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $view = 'PHPView';
|
||||
protected $view = '\Majestic\View\PHPView';
|
||||
|
||||
protected $base_url = '';
|
||||
|
||||
@ -30,7 +30,7 @@ class FrontController
|
||||
private function __construct()
|
||||
{
|
||||
// ErrorHandler::init();
|
||||
$this->router = new Router();
|
||||
$this->router = new Router\Router();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -69,12 +69,12 @@ class FrontController
|
||||
/**
|
||||
*
|
||||
* @param null $view
|
||||
* @return PHPView
|
||||
* @return ..\View\PHPView
|
||||
*/
|
||||
public function getView($view = null)
|
||||
{
|
||||
$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()
|
||||
{
|
||||
@ -103,53 +103,53 @@ class FrontController
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$request = Env::getRequestUri(true);
|
||||
$request = \Majestic\Env::getRequestUri(true);
|
||||
$route = $this->getRouter()->route($request);
|
||||
if (!$route) {
|
||||
throw new Error404Exception('Route for "' . $request . '" not found');
|
||||
throw new \Majestic\Exception\Error404Exception('Route for "' . $request . '" not found');
|
||||
}
|
||||
|
||||
$action_class = $route->getAction();
|
||||
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();
|
||||
$layout_class = $route->getLayout();
|
||||
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();
|
||||
$html = $layout->fetch($action);
|
||||
if (Config::get('PROFILER')) {
|
||||
if (\Majestic\Config::get('PROFILER')) {
|
||||
if (is_subclass_of($action, 'AjaxAction')) {
|
||||
Profiler::getInstance()->getJson();
|
||||
\Majestic\Util\Profiler\Profiler::getInstance()->getJson();
|
||||
} else {
|
||||
$html = Profiler::getInstance()->end($html);
|
||||
$html = \Majestic\Util\Profiler\Profiler::getInstance()->end($html);
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
catch (Exception $e) {
|
||||
if (Config::get('DEBUG')) {
|
||||
catch (\Exception $e) {
|
||||
if (\Majestic\Config::get('DEBUG')) {
|
||||
if (!headers_sent()) {
|
||||
if ($e instanceof ErrorHTTPException) {
|
||||
if ($e instanceof \Majestic\Exception\ErrorHTTPException) {
|
||||
header($e->getHTTPHeader());
|
||||
} else {
|
||||
header('HTTP/1.0 500 Internal Server Error');
|
||||
}
|
||||
}
|
||||
ErrorHandler::logError($e);
|
||||
return ErrorHandler::showDebug($e);
|
||||
\Majestic\Exception\ErrorHandler::logError($e);
|
||||
return \Majestic\Exception\ErrorHandler::showDebug($e);
|
||||
}
|
||||
$layout_class = $this->getRouter()->getErrorLayout();
|
||||
|
||||
/**
|
||||
* @var ErrorLayout $layout
|
||||
* @var \Majestic\Layout\ErrorLayout $layout
|
||||
*/
|
||||
$layout = new $layout_class();
|
||||
$layout->setException($e);
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App\Router;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,8 +7,6 @@
|
||||
* @since 2010-02-25
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
class Route
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App\Router;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -33,7 +33,7 @@ class Router
|
||||
if (!$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)) {
|
||||
$this->route_name = $name;
|
||||
$this->route = $route;
|
||||
Env::setParams($route->getParams());
|
||||
\Majestic\Env::setParams($route->getParams());
|
||||
return $this->route;
|
||||
}
|
||||
}
|
||||
@ -94,7 +94,7 @@ class Router
|
||||
/**
|
||||
* @param null|string $name
|
||||
* @return Route
|
||||
* @throws ErrorException
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function getRoute($name = null)
|
||||
{
|
||||
@ -104,7 +104,7 @@ class Router
|
||||
if ($this->routeIsExists($name)) {
|
||||
return $this->getRouteByName($name);
|
||||
} else {
|
||||
throw new ErrorException('Unknown route name: "' . $name . '".');
|
||||
throw new \ErrorException('Unknown route name: "' . $name . '".');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\App;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,9 +7,9 @@
|
||||
* @since 2010-02-17
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
class Config extends \Registry
|
||||
|
||||
class Config extends Registry
|
||||
{
|
||||
|
||||
private static $_class_name = 'Config';
|
||||
@ -33,7 +33,7 @@ class ConfigArray extends \ArrayObject
|
||||
public function offsetGet($index)
|
||||
{
|
||||
if (!$this->offsetExists($index)) {
|
||||
throw new \GeneralException('Configuration variable "' . $index . '" undefined');
|
||||
throw new Exception\GeneralException('Configuration variable "' . $index . '" undefined');
|
||||
}
|
||||
return parent::offsetGet($index);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic;
|
||||
/**
|
||||
* Класс для работы с переменными окружения.
|
||||
*
|
||||
@ -23,7 +23,7 @@ class Env
|
||||
list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI'));
|
||||
if ($trim_base) {
|
||||
// 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) {
|
||||
self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Exception;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Exception;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Exception;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -22,7 +22,7 @@ class ErrorHandler
|
||||
ob_end_clean();
|
||||
}
|
||||
if (error_reporting() !== 0) {
|
||||
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -31,7 +31,7 @@ class ErrorHandler
|
||||
{
|
||||
$error = 0;
|
||||
$exception_name = '';
|
||||
if ($exception instanceof ErrorException) {
|
||||
if ($exception instanceof \ErrorException) {
|
||||
$error = $exception->getSeverity();
|
||||
} else {
|
||||
$exception_name = get_class($exception) . ': ';
|
||||
@ -59,9 +59,9 @@ class ErrorHandler
|
||||
static public function getHTTPErrorConditions()
|
||||
{
|
||||
$text = null;
|
||||
if (!is_null(Env::Server('REQUEST_METHOD')) && !is_null(Env::Server('REQUEST_URI'))) {
|
||||
$text = ', URL: ' . Env::Server('REQUEST_METHOD') . ' ' . Env::Server('REQUEST_URI');
|
||||
$text .= ', referrer: ' . Env::Server('HTTP_REFERER');
|
||||
if (!is_null(\Majestic\Env::Server('REQUEST_METHOD')) && !is_null(\Majestic\Env::Server('REQUEST_URI'))) {
|
||||
$text = ', URL: ' . \Majestic\Env::Server('REQUEST_METHOD') . ' ' . \Majestic\Env::Server('REQUEST_URI');
|
||||
$text .= ', referrer: ' . \Majestic\Env::Server('HTTP_REFERER');
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
@ -109,7 +109,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Exception $exception
|
||||
* @param \Exception $exception
|
||||
* @return string
|
||||
*/
|
||||
static public function showDebug($exception)
|
||||
@ -120,19 +120,19 @@ class ErrorHandler
|
||||
}
|
||||
$class = get_class($exception);
|
||||
|
||||
$method = Env::Server('REQUEST_METHOD', '');
|
||||
$uri = Env::getRequestUri();
|
||||
$method = \Majestic\Env::Server('REQUEST_METHOD', '');
|
||||
$uri = \Majestic\Env::getRequestUri();
|
||||
$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());
|
||||
|
||||
$get = self::wrapArray(Env::Get(), 'GET');
|
||||
$post = self::wrapArray(Env::Post(), 'POST');
|
||||
$session = self::wrapArray(Session::get(), 'SESSION');
|
||||
$files = self::wrapArray(Env::Files(), 'FILES');
|
||||
$cookies = self::wrapArray(Env::Cookie(), 'COOKIE');
|
||||
$server = self::wrapArray(Env::Server(), 'SERVER');
|
||||
$get = self::wrapArray(\Majestic\Env::Get(), 'GET');
|
||||
$post = self::wrapArray(\Majestic\Env::Post(), 'POST');
|
||||
$session = self::wrapArray(\Majestic\Session\Session::get(), 'SESSION');
|
||||
$files = self::wrapArray(\Majestic\Env::Files(), 'FILES');
|
||||
$cookies = self::wrapArray(\Majestic\Env::Cookie(), 'COOKIE');
|
||||
$server = self::wrapArray(\Majestic\Env::Server(), 'SERVER');
|
||||
|
||||
$message = <<<EOD
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Exception;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,4 +7,4 @@
|
||||
* @since 2010-02-26
|
||||
*/
|
||||
|
||||
class GeneralException extends Exception {}
|
||||
class GeneralException extends \Exception {}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Exception;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -9,4 +9,4 @@
|
||||
* Exception from initializtion object
|
||||
*/
|
||||
|
||||
class InitializationException extends Exception {}
|
||||
class InitializationException extends \Exception {}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Form;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,8 +7,6 @@
|
||||
* @since 2010-04-24
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
abstract class Form
|
||||
{
|
||||
|
||||
@ -17,7 +15,7 @@ abstract class Form
|
||||
const ERROR = 'error';
|
||||
|
||||
/**
|
||||
* @var \FormField[]
|
||||
* @var FormField[]
|
||||
*/
|
||||
protected $fields = array();
|
||||
|
||||
@ -38,18 +36,18 @@ abstract class Form
|
||||
/**
|
||||
* @param string $name
|
||||
* @param bool|string $message
|
||||
* @return \FormField
|
||||
* @return FormField
|
||||
*/
|
||||
protected function addField($name, $message = false)
|
||||
{
|
||||
$this->fields[$name] = new \FormField($message);
|
||||
$this->fields[$name] = new FormField($message);
|
||||
return $this->fields[$name];
|
||||
}
|
||||
|
||||
public function isValid($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) {
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Form;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -93,7 +93,7 @@ class FormField
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]|iValidator[] $validators
|
||||
* @param string[]|\Majestic\Validator\iValidator[] $validators
|
||||
* @return FormField
|
||||
*/
|
||||
public function addValidators($validators)
|
||||
@ -105,19 +105,19 @@ class FormField
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|iValidator $validator
|
||||
* @param string|\Majestic\Validator\iValidator $validator
|
||||
* @return FormField
|
||||
* @throws InitializationException
|
||||
* @throws \Majestic\Exception\InitializationException
|
||||
*/
|
||||
public function addValidator($validator)
|
||||
{
|
||||
if ($validator instanceof iValidator) {
|
||||
if ($validator instanceof \Majestic\Validator\iValidator) {
|
||||
$name = get_class($validator);
|
||||
} elseif (is_string($validator)) {
|
||||
$name = $validator . 'Validator';
|
||||
$validator = new $name();
|
||||
} 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;
|
||||
return $this;
|
||||
@ -139,7 +139,7 @@ class FormField
|
||||
$name = $filter . 'Filter';
|
||||
$filter = new $name();
|
||||
} 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;
|
||||
return $this;
|
||||
@ -192,7 +192,7 @@ class FormField
|
||||
if (!$validator->isValid($val, $context)) {
|
||||
$valid = false;
|
||||
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;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Form;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -16,10 +16,10 @@ class FormViewHelper extends ViewHelper
|
||||
{
|
||||
if ($this->data === 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());
|
||||
Session::del($form);
|
||||
$this->data = \Majestic\Session\Session::get($form, array());
|
||||
\Majestic\Session\Session::del($form);
|
||||
}
|
||||
return $this;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Layout;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -10,7 +10,7 @@
|
||||
class ErrorLayout extends Layout
|
||||
{
|
||||
/**
|
||||
* @var GeneralException
|
||||
* @var \Majestic\ExceptionGeneralException
|
||||
*/
|
||||
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;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Layout;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -13,18 +13,18 @@ abstract class Layout
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var PHPView
|
||||
* @var \Majestic\View\PHPView
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->view = FrontController::getInstance()->getView();
|
||||
$this->view = \Majestic\App\FrontController::getInstance()->getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Action $action
|
||||
* @param \Majestic\App\Action $action
|
||||
*/
|
||||
protected function assign($name, $action)
|
||||
{
|
||||
@ -34,7 +34,7 @@ abstract class Layout
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Action $action
|
||||
* @param \Majestic\App\Action $action
|
||||
*/
|
||||
protected function append($name, $action)
|
||||
{
|
||||
@ -44,7 +44,7 @@ abstract class Layout
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param Action $action
|
||||
* @param \Majestic\App\Action $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
|
||||
* @param Action $action
|
||||
* @param \Majestic\App\Action $action
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($action)
|
17
Load.php
17
Load.php
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -18,6 +18,15 @@ class Load
|
||||
|
||||
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
|
||||
* @static
|
||||
@ -62,7 +71,11 @@ class Load
|
||||
|
||||
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()
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Logger;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Logger;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -20,7 +20,7 @@ class FileLogger extends Logger
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->file_path = Config::get('Logger')->filepath;
|
||||
$this->file_path = \Majestic\Config::get('Logger')->filepath;
|
||||
}
|
||||
|
||||
protected function generateOutString($message)
|
||||
@ -35,7 +35,7 @@ class FileLogger extends Logger
|
||||
if (!$this->handler) {
|
||||
$this->handler = @fopen($this->file_path, "a");
|
||||
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);
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Logger;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -31,7 +31,7 @@ abstract class Logger
|
||||
{
|
||||
if (static::$_instance === null) {
|
||||
//$class = get_called_class();
|
||||
$class = Config::get('Logger')->logger;
|
||||
$class = \Majestic\Config::get('Logger')->logger;
|
||||
static::$_instance = new $class();
|
||||
}
|
||||
return static::$_instance;
|
||||
@ -43,7 +43,7 @@ abstract class Logger
|
||||
*/
|
||||
public function log($message)
|
||||
{
|
||||
if (Config::get('LOGGING')) {
|
||||
if (\Majestic\Config::get('LOGGING')) {
|
||||
$this->concreteLog($message);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,8 +7,6 @@
|
||||
* @since 2010-02-16
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
class Db
|
||||
{
|
||||
|
||||
@ -31,23 +29,23 @@ class Db
|
||||
* @param array $config Configuration array.
|
||||
*
|
||||
* @return DbDriver
|
||||
* @throws InitializationException
|
||||
* @throws \Majestic\Exception\InitializationException
|
||||
*/
|
||||
static public function connect($name = 'default', $config = null)
|
||||
{
|
||||
if (!isset(self::$connections[$name])) {
|
||||
if (!$config) {
|
||||
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;
|
||||
}
|
||||
|
||||
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'])) {
|
||||
$driver = $config['driver'];
|
||||
unset($config['driver']);
|
||||
@ -55,8 +53,8 @@ class Db
|
||||
|
||||
$connection = new $driver($config);
|
||||
|
||||
if (!$connection instanceof \DbDriver) {
|
||||
throw new \InitializationException('Database driver must extends DbDriver');
|
||||
if (!$connection instanceof DbDriver) {
|
||||
throw new \Majestic\Exception\InitializationException('Database driver must extends DbDriver');
|
||||
}
|
||||
self::$connections[$name] = $connection;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -36,7 +36,7 @@ abstract class DbDriver
|
||||
$required = array('database', 'username', 'password', 'hostname');
|
||||
foreach ($required as $option) {
|
||||
if (!isset($config[$option])) {
|
||||
throw new GeneralException('Configuration must have a "' . $option . '".');
|
||||
throw new \GeneralException('Configuration must have a "' . $option . '".');
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -53,7 +53,7 @@ abstract class DbStatement
|
||||
* @param mixed $style
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAll($style = \Majestic\Db::FETCH_OBJ)
|
||||
public function fetchAll($style = Db::FETCH_OBJ)
|
||||
{
|
||||
$data = array();
|
||||
while ($row = $this->fetch($style)) {
|
||||
@ -69,7 +69,7 @@ abstract class DbStatement
|
||||
public function fetchColumn($field)
|
||||
{
|
||||
$data = array();
|
||||
while ($row = $this->fetch(\Majestic\Db::FETCH_ASSOC)) {
|
||||
while ($row = $this->fetch(Db::FETCH_ASSOC)) {
|
||||
$data[] = $row[$field];
|
||||
}
|
||||
return $data;
|
||||
@ -81,7 +81,7 @@ abstract class DbStatement
|
||||
*/
|
||||
public function fetchField($field)
|
||||
{
|
||||
$row = $this->fetch(\Majestic\Db::FETCH_ASSOC);
|
||||
$row = $this->fetch(Db::FETCH_ASSOC);
|
||||
if (isset($row[$field])) {
|
||||
return $row[$field];
|
||||
}
|
||||
@ -94,7 +94,7 @@ abstract class DbStatement
|
||||
|
||||
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');
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
/**
|
||||
* Класс модели данных
|
||||
@ -10,15 +10,13 @@
|
||||
* @since 2010-02-16
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
abstract class Model
|
||||
{
|
||||
|
||||
/**
|
||||
* DbDriver instance
|
||||
*
|
||||
* @var \DbDriver
|
||||
* @var DbDriver
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
@ -50,7 +48,7 @@ abstract class Model
|
||||
|
||||
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()
|
||||
{
|
||||
if (!$this->cache) {
|
||||
$this->cache = \Cacher::get(Config::get(__CLASS__, 'MemcacheCache'));
|
||||
$this->cache = \Cacher::get(\Majestic\Config::get(__CLASS__, 'MemcacheCache'));
|
||||
}
|
||||
return $this->cache;
|
||||
}
|
@ -49,14 +49,14 @@ abstract class MongoDbCommand
|
||||
* Execute Mongo command/query
|
||||
*
|
||||
* @return mixed
|
||||
* @throws GeneralException
|
||||
* @throws \Majestic\Exception\GeneralException
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ($this->checkParams()) {
|
||||
return $this->concreteExecute();
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ abstract class MongoModel extends Model
|
||||
/**
|
||||
* @param array $params Parameters for find query
|
||||
* @return array Query result sort rules
|
||||
* @throws GeneralException
|
||||
* @throws \Majestic\Exception\GeneralException
|
||||
* */
|
||||
private function getOrder($params = array())
|
||||
{
|
||||
@ -170,7 +170,7 @@ abstract class MongoModel extends Model
|
||||
} elseif (is_array($params['order'])) {
|
||||
$order = $params['order'];
|
||||
} else {
|
||||
throw new GeneralException('Wrong order parameter given to query.');
|
||||
throw new \Majestic\Exception\GeneralException('Wrong order parameter given to query.');
|
||||
}
|
||||
}
|
||||
return $order;
|
||||
@ -179,7 +179,7 @@ abstract class MongoModel extends Model
|
||||
/**
|
||||
* @param array $params Parameters for find query
|
||||
* @return array Query result sort rules
|
||||
* @throws GeneralException
|
||||
* @throws \Majestic\Exception\GeneralException
|
||||
* */
|
||||
private function getFields($params)
|
||||
{
|
||||
@ -196,7 +196,7 @@ abstract class MongoModel extends Model
|
||||
$fields = $params['fields'];
|
||||
}
|
||||
} else {
|
||||
throw new GeneralException('Wrong fields parameter given to query.');
|
||||
throw new \Majestic\Exception\GeneralException('Wrong fields parameter given to query.');
|
||||
}
|
||||
}
|
||||
return $fields;
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property MySQLi $connection
|
||||
* @property \MySQLi $connection
|
||||
*/
|
||||
class MySQLiDriver extends SqlDbDriver
|
||||
{
|
||||
@ -51,7 +51,7 @@ class MySQLiDriver extends SqlDbDriver
|
||||
|
||||
public function isConnected()
|
||||
{
|
||||
return ($this->connection instanceof MySQLi);
|
||||
return ($this->connection instanceof \MySQLi);
|
||||
}
|
||||
|
||||
public function disconnect()
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
/**
|
||||
* @property MySQLiDriver $driver
|
||||
* @property MySQLi_Result $result
|
||||
* @property \MySQLi_Result $result
|
||||
*/
|
||||
class MySQLiStatement extends DbStatement
|
||||
{
|
||||
@ -23,10 +23,10 @@ class MySQLiStatement extends DbStatement
|
||||
}
|
||||
if (count($this->map) > 0) {
|
||||
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)) {
|
||||
throw new GeneralException('Objects excepts DbExpr not allowed.');
|
||||
throw new \Majestic\Exception\GeneralException('Objects excepts DbExpr not allowed.');
|
||||
}
|
||||
if (isset($this->map[$param])) {
|
||||
$this->params[$param] = &$value;
|
||||
@ -81,29 +81,29 @@ class MySQLiStatement extends DbStatement
|
||||
*
|
||||
* @param mixed $style
|
||||
* @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) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch ($style) {
|
||||
case \Majestic\Db::FETCH_OBJ:
|
||||
case Db::FETCH_OBJ:
|
||||
$row = $this->result->fetch_object();
|
||||
break;
|
||||
case \Majestic\Db::FETCH_NUM:
|
||||
case Db::FETCH_NUM:
|
||||
$row = $this->result->fetch_array(MYSQLI_NUM);
|
||||
break;
|
||||
case \Majestic\Db::FETCH_ASSOC:
|
||||
case Db::FETCH_ASSOC:
|
||||
$row = $this->result->fetch_assoc();
|
||||
break;
|
||||
case \Majestic\Db::FETCH_BOTH:
|
||||
case Db::FETCH_BOTH:
|
||||
$row = $this->result->fetch_array(MYSQLI_BOTH);
|
||||
break;
|
||||
default:
|
||||
throw new GeneralException('Invalid fetch mode "' . $style . '" specified');
|
||||
throw new \Majestic\Exception\GeneralException('Invalid fetch mode "' . $style . '" specified');
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
@ -123,7 +123,7 @@ class MySQLiStatement extends DbStatement
|
||||
public function fetchPairs()
|
||||
{
|
||||
$data = array();
|
||||
while ($row = $this->fetch(\Majestic\Db::FETCH_NUM)) {
|
||||
while ($row = $this->fetch(Db::FETCH_NUM)) {
|
||||
$data[$row[0]] = $row[1];
|
||||
}
|
||||
return $data;
|
||||
@ -158,11 +158,11 @@ class MySQLiStatement extends DbStatement
|
||||
protected function driverExecute($request)
|
||||
{
|
||||
/**
|
||||
* @var MySQLi
|
||||
* @var \MySQLi
|
||||
*/
|
||||
$mysqli = $this->driver->getConnection();
|
||||
if (Config::get('PROFILER_DETAILS')) {
|
||||
$profiler = Profiler::getInstance()->profilerCommand('MySQL', $request);
|
||||
if (\Majestic\Config::get('PROFILER_DETAILS')) {
|
||||
$profiler = \Majestic\Util\Profiler\Profiler::getInstance()->profilerCommand('MySQL', $request);
|
||||
$result = $mysqli->query($request);
|
||||
$profiler->end();
|
||||
} else {
|
||||
@ -170,9 +170,9 @@ class MySQLiStatement extends DbStatement
|
||||
}
|
||||
if ($result === false) {
|
||||
$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;
|
||||
}
|
||||
return true;
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
class SqlCriteria
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -129,7 +129,7 @@ abstract class SqlDbDriver extends DbDriver
|
||||
/**
|
||||
* @param mixed $where
|
||||
* @return string
|
||||
* @throws ErrorException
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function whereExpr($where)
|
||||
{
|
||||
@ -143,7 +143,7 @@ abstract class SqlDbDriver extends DbDriver
|
||||
foreach ($where as $cond => &$term) {
|
||||
if (is_int($cond)) {
|
||||
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) {
|
||||
$term = (string) $term;
|
||||
@ -164,7 +164,7 @@ abstract class SqlDbDriver extends DbDriver
|
||||
/**
|
||||
* @param mixed $group_by
|
||||
* @return string
|
||||
* @throws ErrorException
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function groupByExpr($group_by)
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
/**
|
||||
* Класс модели данных
|
||||
@ -13,7 +13,7 @@
|
||||
/**
|
||||
* @property SqlDbDriver $db
|
||||
*/
|
||||
abstract class SqlModel extends \Majestic\Model
|
||||
abstract class SqlModel extends Model
|
||||
{
|
||||
/**
|
||||
* @param string $ident
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
class SqlResultCollection extends ArrayIterator implements iSqlResultItems
|
||||
class SqlResultCollection extends \ArrayIterator implements iSqlResultItems
|
||||
{
|
||||
private $items;
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
class SqlResultProvider implements iSqlResultItems
|
||||
{
|
||||
@ -38,7 +38,7 @@ class SqlResultProvider implements iSqlResultItems
|
||||
* @param $field string
|
||||
* @param bool $assoc_as_array
|
||||
* @return $this SqlResultProvider
|
||||
* @throws ErrorException
|
||||
* @throws \ErrorException
|
||||
*/
|
||||
public function assoc($field, $assoc_as_array = false)
|
||||
{
|
||||
@ -46,7 +46,7 @@ class SqlResultProvider implements iSqlResultItems
|
||||
$result_items_assoc = array();
|
||||
foreach ($this->result_items_base as $item) {
|
||||
if (!isset($item->{$field})) {
|
||||
throw new ErrorException('Undefined field. ' . $field);
|
||||
throw new \ErrorException('Undefined field. ' . $field);
|
||||
}
|
||||
if ($assoc_as_array) {
|
||||
if (!isset($result_items_assoc[$item->{$field}])) {
|
||||
@ -55,7 +55,7 @@ class SqlResultProvider implements iSqlResultItems
|
||||
$result_items_assoc[$item->{$field}][] = $item;
|
||||
} else {
|
||||
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;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Model;
|
||||
|
||||
interface iSqlResultItems
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Redis;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Redis;
|
||||
/**
|
||||
* @copyright NetMonsters <team@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 array $config Configuration array.
|
||||
*
|
||||
* @throws GeneralException
|
||||
* @throws \Majestic\Exception\GeneralException
|
||||
* @return Redis
|
||||
*/
|
||||
static public function connect($name = 'default', $config = null)
|
||||
@ -31,13 +31,13 @@ class RedisManager
|
||||
if (!isset(self::$connections[$name])) {
|
||||
if (!$config) {
|
||||
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;
|
||||
}
|
||||
|
||||
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';
|
||||
@ -47,16 +47,16 @@ class RedisManager
|
||||
/**
|
||||
* @var Redis
|
||||
*/
|
||||
$connection = new Redis();
|
||||
if (Config::get('PROFILER_DETAILS')) {
|
||||
$connection = new \Redis();
|
||||
if (\Majestic\Config::get('PROFILER_DETAILS')) {
|
||||
$connection = new RedisDebug($connection);
|
||||
}
|
||||
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 (!$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;
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Redis;
|
||||
/**
|
||||
*
|
||||
*
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,7 +7,7 @@
|
||||
* @since 2010-02-17
|
||||
*/
|
||||
|
||||
class Registry extends ArrayObject
|
||||
class Registry extends \ArrayObject
|
||||
{
|
||||
/**
|
||||
* Class name of the singleton registry object.
|
||||
@ -53,7 +53,7 @@ class Registry extends ArrayObject
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$_registry === null) {
|
||||
self::$_registry = new self::$_class_name();
|
||||
self::$_registry = new \Majestic\Registry();
|
||||
}
|
||||
return self::$_registry;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php namespace Majestic\Session;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -7,8 +7,6 @@
|
||||
* @since 2010-03-14
|
||||
*/
|
||||
|
||||
namespace Majestic;
|
||||
|
||||
class Session
|
||||
{
|
||||
/**
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user