Radical reorg of some classes

This commit is contained in:
Samuel Georges 2015-01-28 18:03:35 +11:00
parent 9e500985ff
commit b1b700368f
71 changed files with 112 additions and 615 deletions

View File

@ -11,7 +11,7 @@ use Backend\Classes\FormField;
use Backend\Classes\ControllerBehavior;
use October\Rain\Support\Util;
use October\Rain\Router\Helper as RouterHelper;
use System\Classes\ApplicationException;
use ApplicationException;
use Exception;
/**

View File

@ -3,7 +3,7 @@
use Str;
use Lang;
use Event;
use System\Classes\SystemException;
use SystemException;
use Backend\Classes\ControllerBehavior;
use League\Csv\Writer;
use SplTempFileObject;

View File

@ -5,7 +5,7 @@ use Lang;
use Event;
use Form as FormHelper;
use Backend\Classes\ControllerBehavior;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Database\Model;
/**

View File

@ -15,10 +15,10 @@ use Exception;
use BackendAuth;
use Backend\Models\UserPreferences;
use Backend\Models\BackendPreferences;
use System\Classes\SystemException;
use System\Classes\ApplicationException;
use SystemException;
use ApplicationException;
use October\Rain\Extension\Extendable;
use October\Rain\Support\ValidationException;
use ValidationException;
use Illuminate\Database\Eloquent\MassAssignmentException;
use Illuminate\Http\RedirectResponse;

View File

@ -2,7 +2,7 @@
use Str;
use Lang;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Extension\ExtensionBase;
use System\Traits\ViewMaker;

View File

@ -2,8 +2,8 @@
use Str;
use File;
use Yaml;
use Closure;
use October\Rain\Support\Yaml;
use Illuminate\Container\Container;
use System\Classes\PluginManager;

View File

@ -8,7 +8,7 @@ use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\SettingsManager;
use Exception;

View File

@ -11,8 +11,8 @@ use Backend\Models\User;
use Backend\Models\AccessLog;
use Backend\Classes\Controller;
use System\Classes\UpdateManager;
use System\Classes\ApplicationException;
use October\Rain\Support\ValidationException;
use ApplicationException;
use ValidationException;
use Exception;
/**

View File

@ -2,7 +2,7 @@
use Backend\Widgets\Grid;
use Backend\Classes\FormWidgetBase;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* Grid

View File

@ -3,7 +3,7 @@
use Lang;
use Backend\Widgets\Table;
use Backend\Classes\FormWidgetBase;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* Data Table

View File

@ -4,10 +4,10 @@ use Str;
use Input;
use Validator;
use System\Models\File;
use System\Classes\SystemException;
use SystemException;
use Backend\Classes\FormField;
use Backend\Classes\FormWidgetBase;
use October\Rain\Support\ValidationException;
use ValidationException;
use Exception;
/**

View File

@ -2,7 +2,7 @@
use Lang;
use Backend\Classes\FormWidgetBase;
use System\Classes\SystemException;
use SystemException;
/**
* Record Finder

View File

@ -2,7 +2,7 @@
use Lang;
use Backend\Classes\FormWidgetBase;
use System\Classes\SystemException;
use SystemException;
use Illuminate\Database\Eloquent\Relations\Relation as RelationBase;
/**

View File

@ -3,7 +3,7 @@
use Exception;
use BackendAuth;
use October\Rain\Database\Model;
use System\Classes\SystemException;
use SystemException;
use October\Rain\Auth\Models\Preferences as PreferencesBase;
/**

View File

@ -5,7 +5,7 @@ use File;
use Lang;
use Input;
use Block;
use System\Classes\SystemException;
use SystemException;
/**
* Collapsable Widget Trait

View File

@ -1,8 +1,8 @@
<?php namespace Backend\Traits;
use Request;
use System\Classes\SystemException;
use System\Classes\ApplicationException;
use SystemException;
use ApplicationException;
/**
* Inspectable Container Trait

View File

@ -4,7 +4,7 @@ use Str;
use File;
use Lang;
use Block;
use System\Classes\SystemException;
use SystemException;
/**
* Searchable Widget Trait

View File

@ -5,7 +5,7 @@ use File;
use Lang;
use Input;
use Block;
use System\Classes\SystemException;
use SystemException;
/**
* Selectable Widget Trait

View File

@ -2,7 +2,7 @@
use Lang;
use Backend\Classes\WidgetManager;
use System\Classes\SystemException;
use SystemException;
/**
* Config Maker Trait

View File

@ -4,7 +4,7 @@ use DB as Db;
use Event;
use Backend\Classes\WidgetBase;
use Backend\Classes\FilterScope;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Support\Util;
/**

View File

@ -10,7 +10,7 @@ use Backend\Classes\FormTabs;
use Backend\Classes\FormField;
use Backend\Classes\WidgetBase;
use Backend\Classes\WidgetManager;
use System\Classes\ApplicationException;
use ApplicationException;
use Backend\Classes\FormWidgetBase;
use October\Rain\Database\Model;

View File

@ -12,7 +12,7 @@ use Carbon\Carbon;
use October\Rain\Router\Helper as RouterHelper;
use Backend\Classes\ListColumn;
use Backend\Classes\WidgetBase;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Database\Model;
use DateTime;

View File

@ -6,7 +6,7 @@ use Request;
use Backend\Classes\WidgetBase;
use Backend\Classes\WidgetManager;
use Backend\Models\UserPreferences;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* Report Container Widget

View File

@ -3,7 +3,7 @@
use Input;
use Request;
use Backend\Classes\WidgetBase;
use System\Classes\SystemException;
use SystemException;
/**
* Table Widget.

View File

@ -2,9 +2,9 @@
use Validator;
use Cms\Classes\CodeBase;
use System\Classes\SystemException;
use SystemException;
use Cms\Classes\FileHelper;
use October\Rain\Support\ValidationException;
use ValidationException;
use Cms\Classes\ViewBag;
use Cache;
use Config;

View File

@ -3,7 +3,7 @@
use File;
use Twig_Error;
use Cms\Classes\SectionParser;
use System\Classes\ApplicationException;
use ApplicationException;
use Exception;
/**

View File

@ -5,8 +5,8 @@ use Lang;
use Cache;
use Config;
use Validator;
use System\Classes\ApplicationException;
use October\Rain\Support\ValidationException;
use ApplicationException;
use ValidationException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use ArrayAccess;

View File

@ -1,7 +1,7 @@
<?php namespace Cms\Classes;
use Illuminate\Support\Collection as CollectionBase;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* This class represents a collection of Cms Objects.

View File

@ -1,6 +1,6 @@
<?php namespace Cms\Classes;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* This class provides helper methods to make the CmsObject behave like a Model

View File

@ -11,7 +11,7 @@
use Flash;
use Cms\Classes\Page;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* This class provides helper methods for inspectable properties.

View File

@ -4,7 +4,7 @@ use File;
use Lang;
use Cache;
use Config;
use System\Classes\SystemException;
use SystemException;
/**
* Parses the PHP code section of CMS objects.

View File

@ -3,7 +3,7 @@
use Str;
use Illuminate\Container\Container;
use System\Classes\PluginManager;
use System\Classes\SystemException;
use SystemException;
/**
* Component manager

View File

@ -1,7 +1,7 @@
<?php namespace Cms\Classes;
use File;
use October\Rain\Support\Markdown;
use Markdown;
/**
* The CMS content file class.

View File

@ -23,9 +23,9 @@ use Cms\Models\MaintenanceSettings;
use System\Models\RequestLog;
use System\Classes\ErrorHandler;
use System\Classes\CombineAssets;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Twig\Extension as SystemTwigExtension;
use October\Rain\Support\ValidationException;
use ValidationException;
use Illuminate\Http\RedirectResponse;
/**

View File

@ -1,7 +1,7 @@
<?php namespace Cms\Classes;
use Cms\Classes\Theme;
use System\Classes\ApplicationException;
use ApplicationException;
use Cms\Classes\Layout;
use Lang;

View File

@ -5,7 +5,7 @@ use File;
use Cache;
use Config;
use Event;
use System\Classes\SystemException;
use SystemException;
use October\Rain\Router\Router as RainRouter;
use October\Rain\Router\Helper as RouterHelper;

View File

@ -2,14 +2,14 @@
use URL;
use File;
use Yaml;
use Lang;
use Cache;
use Event;
use Config;
use DbDongle;
use October\Rain\Support\Yaml;
use System\Models\Parameters;
use System\Classes\SystemException;
use SystemException;
use Cms\Models\ThemeData;
use DirectoryIterator;

View File

@ -23,7 +23,7 @@ use Cms\Classes\Content;
use Cms\Classes\CmsCompoundObject;
use Cms\Classes\ComponentManager;
use Cms\Classes\ComponentPartial;
use System\Classes\ApplicationException;
use ApplicationException;
use Backend\Traits\InspectableContainer;
use October\Rain\Router\Router as RainRouter;

View File

@ -1,10 +1,10 @@
<?php namespace Cms\FormWidgets;
use Lang;
use Backend\Classes\FormWidgetBase;
use Cms\Classes\ComponentManager;
use Cms\Classes\ComponentHelpers;
use Cms\Classes\UnknownComponent;
use Lang;
use Exception;
/**

View File

@ -10,7 +10,7 @@ use Twig_SimpleFilter;
use Twig_SimpleFunction;
use Cms\Classes\Controller;
use Cms\Classes\CmsException;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* The CMS Twig extension class implements the basic CMS Twig functions and filters.

View File

@ -13,9 +13,8 @@ use Cms\Classes\Theme;
use Cms\Classes\Asset;
use Backend\Classes\WidgetBase;
use System\Classes\PluginManager;
use System\Classes\ApplicationException;
use October\Rain\Support\Inflector;
use October\Rain\Support\ValidationException;
use ApplicationException;
use ValidationException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use RecursiveIteratorIterator;

View File

@ -1,15 +1,14 @@
<?php namespace Cms\Widgets;
use Backend\Classes\WidgetBase;
use Str;
use Lang;
use Input;
use Request;
use Response;
use Cms\Classes\Theme;
use System\Classes\PluginManager;
use Cms\Classes\ComponentHelpers;
use October\Rain\Support\Inflector;
use Input;
use Response;
use Request;
use Str;
use Lang;
use Backend\Classes\WidgetBase;
/**
* Component list widget.

View File

@ -256,7 +256,7 @@ class ServiceProvider extends ModuleServiceProvider
'studly' => ['Str', 'studly'],
'trans' => ['Lang', 'get'],
'transchoice' => ['Lang', 'choice'],
'md' => ['October\Rain\Support\Markdown', 'parse'],
'md' => ['Markdown', 'parse'],
]);
});

View File

@ -47,11 +47,13 @@ return [
'Flash' => 'October\Rain\Support\Facades\Flash',
'Http' => 'October\Rain\Support\Facades\Http',
'Str' => 'October\Rain\Support\Facades\Str',
'Markdown' => 'October\Rain\Support\Facades\Markdown',
'Yaml' => 'October\Rain\Support\Facades\Yaml',
'DbDongle' => 'October\Rain\Support\Facades\DbDongle',
'Backend' => 'Backend\Facades\Backend',
'BackendMenu' => 'Backend\Facades\BackendMenu',
'BackendAuth' => 'Backend\Facades\BackendAuth',
'SystemException' => 'System\Classes\SystemException',
'ApplicationException' => 'System\Classes\ApplicationException',
'ValidationException' => 'October\Rain\Support\ValidationException',
'SystemException' => 'October\Rain\Exception\SystemException',
'ApplicationException' => 'October\Rain\Exception\ApplicationException',
'ValidationException' => 'October\Rain\Exception\ValidationException',
];

View File

@ -3,7 +3,7 @@
use Cache;
use DbDongle;
use System\Classes\ModelBehavior;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* Settings model extension

View File

@ -1,12 +0,0 @@
<?php namespace System\Classes;
/**
* This class represents an application exception.
* Application exceptions are not logged in the error log.
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class ApplicationException extends ExceptionBase
{
}

View File

@ -14,7 +14,7 @@ use Assetic\Asset\FileAsset;
use Assetic\Asset\GlobAsset;
use Assetic\Asset\AssetCache;
use Assetic\Cache\FilesystemCache;
use System\Classes\ApplicationException;
use ApplicationException;
use DateTime;
/**

View File

@ -1,7 +1,7 @@
<?php namespace System\Classes;
use Controller as BaseController;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\CombineAssets;
use Exception;

View File

@ -1,15 +1,11 @@
<?php namespace System\Classes;
use App;
use View;
use Config;
use Request;
use Response;
use Cms\Classes\Theme;
use Cms\Classes\Router;
use Cms\Classes\Controller;
use System\Classes\BaseException;
use System\Classes\ApplicationException;
use October\Rain\Exception\ErrorHandler as ErrorHandlerBase;
/**
* System Error Handler, this class handles application exception events.
@ -17,96 +13,8 @@ use System\Classes\ApplicationException;
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class ErrorHandler
class ErrorHandler extends ErrorHandlerBase
{
/**
* @var System\Classes\ExceptionBase A prepared mask exception used to mask any exception fired.
*/
protected static $activeMask;
/**
* @var array A collection of masks, so multiples can be applied in order.
*/
protected static $maskLayers = [];
/**
* All exceptions are piped through this method from the framework workflow. This method will mask
* any foreign exceptions with a "scent" of the native application's exception, so it can render
* correctly when displayed on the error page.
* @param Exception $proposedException The exception candidate that has been thrown.
* @return View Object containing the error page.
*/
public function handleException(\Exception $proposedException, $httpCode = 500)
{
// Disable the error handler for test and CLI environment
if (App::runningUnitTests() || App::runningInConsole()) {
return;
}
// Detect AJAX request and use error 500
if (Request::ajax()) {
return Response::make($proposedException->getMessage(), $httpCode);
}
// Clear the output buffer
while (ob_get_level()) {
ob_end_clean();
}
// Friendly error pages are used
if (!Config::get('app.debug', false)) {
return $this->handleCustomError();
}
// If the exception is already our brand, use it.
if ($proposedException instanceof BaseException) {
$exception = $proposedException;
}
// If there is an active mask prepared, use that.
elseif (static::$activeMask !== null) {
$exception = static::$activeMask;
$exception->setMask($proposedException);
}
// Otherwise we should mask it with our own default scent.
else {
$exception = new ApplicationException($proposedException->getMessage(), 0);
$exception->setMask($proposedException);
}
// Ensure System view path is registered
View::addNamespace('system', base_path().'/modules/system/views');
return View::make('system::exception', ['exception' => $exception]);
}
/**
* Prepares a mask exception to be used when any exception fires.
* @param Exception $exception The mask exception.
* @return void
*/
public static function applyMask(\Exception $exception)
{
if (static::$activeMask !== null) {
array_push(static::$maskLayers, static::$activeMask);
}
static::$activeMask = $exception;
}
/**
* Destroys the prepared mask by applyMask()
* @return void
*/
public static function removeMask()
{
if (count(static::$maskLayers) > 0) {
static::$activeMask = array_pop(static::$maskLayers);
}
else {
static::$activeMask = null;
}
}
/**
* Looks up an error page using the CMS route "/error". If the route does not
* exist, this function will use the error view found in the Cms module.
@ -114,6 +22,9 @@ class ErrorHandler
*/
public function handleCustomError()
{
if (Config::get('app.debug', false))
return null;
$theme = Theme::getActiveTheme();
// Use the default view if no "/error" URL is found.
@ -126,4 +37,16 @@ class ErrorHandler
$controller = new Controller($theme);
return $controller->run('/error');
}
/**
* Displays the detailed system exception page.
* @return View Object containing the error page.
*/
public function handleDetailedError($exception)
{
// Ensure System view path is registered
View::addNamespace('system', base_path().'/modules/system/views');
return View::make('system::exception', ['exception' => $exception]);
}
}

View File

@ -1,389 +0,0 @@
<?php namespace System\Classes;
use URL;
use File;
use Config;
use Exception;
use System\Classes\ApplicationException;
/**
* The base exception class.
* This class represents a base interface and set of properties
* for system and application exceptions.
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class ExceptionBase extends Exception
{
/**
* @var Exception If this exception is acting as a mask, this property stores the face exception.
*/
protected $mask;
/**
* @var string Hint Message to help the user with troubleshooting the error (optional).
*/
public $hint;
/**
* @var array File content relating to the exception, each value of the array is a file line number.
*/
protected $fileContent = [];
/**
* @var string Class name of the called Exception.
*/
protected $className;
/**
* @var string Error type derived from the error code. Will be 'Undefined' if no code is used.
*/
protected $errorType;
/**
* @var stdObject Cached code information for highlighting code.
*/
protected $highlight;
/**
* CMS base exception class constructor. Inherits the native PHP Exception.
* All CMS related classes should inherit this class, it creates a set of unified properties
* and an interface for displaying the CMS exception page.
* @param string $message Error message.
* @param int $code Error code.
* @param Exception $previous Previous exception.
* @return void
*/
public function __construct($message = "", $code = 0, Exception $previous = null)
{
if ($this->className === null) {
$this->className = get_called_class();
}
if ($this->errorType === null) {
$this->errorType = 'Undefined';
}
parent::__construct($message, $code, $previous);
}
/**
* Returns a more descriptive error message if application
* debug mode is turned on.
* @param Exception $exception
* @return string
*/
public static function getDetailedMessage($exception)
{
/*
* Application Exceptions never display a detailed error
*/
if (!($exception instanceof ApplicationException) && Config::get('app.debug', false)) {
return sprintf('"%s" on line %s of %s',
$exception->getMessage(),
$exception->getLine(),
$exception->getFile()
);
}
else {
return $exception->getMessage();
}
}
/**
* Returns the class name of the called Exception.
* @return string
*/
public function getClassName()
{
return $this->className;
}
/**
* Returns the error type derived from the error code used.
* @return string
*/
public function getErrorType()
{
return $this->errorType;
}
/**
* Masks an exception with the called class. This should catch fatal and php errors.
* It should always be followed by the unmask() method to remove the mask.
* @param string $message Error message.
* @param int $code Error code.
* @return void
*/
public static function mask($message = null, $code = 0)
{
$calledClass = get_called_class();
$exception = new $calledClass($message, $code);
ErrorHandler::applyMask($exception);
}
/**
* Removes the active mask from the called class.
* @return void
*/
public static function unmask()
{
ErrorHandler::removeMask();
}
/**
* If this exception acts as a mask, sets the face for the foreign exception.
* @param Exception $exception Face for the mask, the underlying exception.
* @return void
*/
public function setMask(Exception $exception)
{
$this->mask = $exception;
$this->applyMask($exception);
}
/**
* This method is used when applying the mask exception to the face exception.
* It can be used as an override for child classes who may use different masking logic.
* @param Exception $exception Face exception being masked.
* @return void
*/
public function applyMask(Exception $exception)
{
$this->file = $exception->getFile();
$this->message = $exception->getMessage();
$this->line = $exception->getLine();
$this->className = get_class($exception);
}
/**
* If this exception is acting as a mask, return the face exception. Otherwise return
* this exception as the true one.
* @return Exception The underlying exception, or this exception if no mask is applied.
*/
public function getTrueException()
{
if ($this->mask !== null) {
return $this->mask;
}
return $this;
}
/**
* Generates information used for highlighting the area of code in context of the exception line number.
* The highlighted block of code will be six (6) lines before and after the problem line number.
* @return array Highlight information as an array, the following keys are supplied:
* startLine - The starting line number, 6 lines before the error line.
* endLine - The ending line number, 6 lines after the error line.
* errorLine - The focused error line number.
* lines - An array of all the lines to be highlighted, each value is a line of code.
*/
public function getHighlight()
{
if ($this->highlight !== null) {
return $this->highlight;
}
if (!$this->fileContent && File::exists($this->file) && is_readable($this->file)) {
$this->fileContent = @file($this->file);
}
$errorLine = $this->line - 1;
$startLine = $errorLine - 6;
if ($startLine < 0) {
$startLine = 0;
}
$endLine = $startLine + 12;
$lineNum = count($this->fileContent);
if ($endLine > $lineNum-1) {
$endLine = $lineNum-1;
}
$areaLines = array_slice($this->fileContent, $startLine, $endLine - $startLine + 1);
$result = [
'startLine' => $startLine,
'endLine' => $endLine,
'errorLine' => $errorLine,
'lines' => []
];
foreach ($areaLines as $index => $line) {
$result['lines'][$startLine + $index] = $line;
}
return $this->highlight = (object)$result;
}
/**
* Returns an array of line numbers used for highlighting the problem area of code.
* This will be six (6) lines before and after the error line number.
* @return array Array of code lines.
*/
public function getHighlightLines()
{
$lines = $this->getHighlight()->lines;
foreach ($lines as $index => $line) {
$lines[$index] = strlen(trim($line)) ? htmlentities($line) : '&nbsp;'.PHP_EOL;
}
return $lines;
}
/**
* Returns the call stack as an array of values containing a stack information object.
* @return Array with stack information, each value will be an object with these values:
* id - The stack ID number.
* code - The class and function name being called.
* args - The arguments passed to the code function above.
* file - Reference to the file containing the called code.
* line - Reference to the line number of the file.
*/
public function getCallStack()
{
$result = [];
$traceInfo = $this->filterCallStack($this->getTrueException()->getTrace());
$lastIndex = count($traceInfo) - 1;
foreach ($traceInfo as $index => $event) {
$functionName = (isset($event['class']) && strlen($event['class']))
? $event['class'].$event['type'].$event['function']
: $event['function'];
$file = isset($event['file']) ? URL::to(str_replace(public_path(), '', $event['file'])) : null;
$line = isset($event['line']) ? $event['line'] : null;
$args = null;
if (isset($event['args']) && count($event['args'])) {
$args = $this->formatStackArguments($event['args'], false);
}
$result[] = (object)[
'id' => $lastIndex - $index + 1,
'code' => $functionName,
'args' => $args ? htmlentities($args) : '',
'file' => $file,
'line' => $line
];
}
return $result;
}
/**
* Removes the final steps of a call stack, which add no value for the user.
* The following exceptions and any trace information afterwards will be filtered:
* - Illuminate\Exception\Handler
*
* @param array $traceInfo The trace information from getTrace() or debug_backtrace().
* @return array The filtered array containing the trace information.
*/
protected function filterCallStack($traceInfo)
{
/*
* Determine if filter should be used at all.
*/
$useFilter = false;
foreach ($traceInfo as $event) {
if (
isset($event['class']) &&
$event['class'] == 'Illuminate\Exception\Handler' &&
$event['function'] == 'handleError'
) {
$useFilter = true;
}
}
if (!$useFilter) {
return $traceInfo;
}
$filterResult = [];
$pruneResult = true;
foreach ($traceInfo as $index => $event) {
/*
* Prune the tail end of the trace from the framework exception handler.
*/
if (
isset($event['class']) &&
$event['class'] == 'Illuminate\Exception\Handler' &&
$event['function'] == 'handleError'
) {
$pruneResult = false;
continue;
}
if ($pruneResult) {
continue;
}
$filterResult[$index] = $event;
}
return $filterResult;
}
/**
* Prepares a function or method argument list for display in HTML or text format
* @param array arguments A list of the function or method arguments
* @return string
*/
protected function formatStackArguments($arguments)
{
$argsArray = array();
foreach ($arguments as $argument) {
$arg = null;
if (is_array($argument)) {
$items = array();
foreach ($argument as $index => $obj) {
if (is_array($obj)) {
$value = 'array('.count($obj).')';
}
elseif (is_object($obj)) {
$value = 'object('.get_class($obj).')';
}
elseif (is_integer($obj)) {
$value = $obj;
}
elseif ($obj === null) {
$value = "null";
}
else {
$value = "'".$obj."'";
}
$items[] = $index . ' => ' . $value;
}
if (count($items)) {
$arg = 'array(' . count($argument) . ') [' . implode(', ', $items) . ']';
}
else {
$arg = 'array(0)';
}
}
elseif (is_object($argument)) {
$arg = 'object('.get_class($argument).')';
}
elseif ($argument === null) {
$arg = "null";
}
elseif (is_integer($argument)) {
$arg = $argument;
}
else {
$arg = "'".$argument."'";
}
$argsArray[] = $arg;
}
return implode(', ', $argsArray);
}
}

View File

@ -4,7 +4,7 @@ use Str;
use Twig_TokenParser;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\PluginManager;
/**

View File

@ -1,7 +1,7 @@
<?php namespace System\Classes;
use Lang;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Database\ModelBehavior as ModelBehaviorBase;
/**

View File

@ -1,26 +0,0 @@
<?php namespace System\Classes;
use App;
use Log;
/**
* This class represents a critical system exception.
* System exceptions are logged in the error log.
*
* @package october\system
* @author Alexey Bobkov, Samuel Georges
*/
class SystemException extends ExceptionBase
{
public function __construct($message = "", $code = 0, \Exception $previous = null)
{
parent::__construct($message, $code, $previous);
/*
* Log the exception
*/
if (!App::runningUnitTests()) {
Log::error($this);
}
}
}

View File

@ -11,7 +11,7 @@ use Carbon\Carbon;
use System\Models\Parameters;
use System\Models\PluginVersion;
use System\Console\CacheClear;
use System\Classes\ApplicationException;
use ApplicationException;
use October\Rain\Filesystem\Zip;
use Exception;

View File

@ -2,9 +2,9 @@
use Str;
use File;
use Yaml;
use DB as Db;
use Carbon\Carbon;
use October\Rain\Support\Yaml;
use October\Rain\Database\Updater;
/**

View File

@ -8,7 +8,7 @@ use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\SettingsManager;
use System\Models\EventLog;
use Exception;

View File

@ -8,7 +8,7 @@ use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\SettingsManager;
use Exception;

View File

@ -11,7 +11,7 @@ use BackendMenu;
use BackendAuth;
use Backend\Classes\Controller;
use System\Models\MailTemplate;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\SettingsManager;
use Exception;

View File

@ -8,7 +8,7 @@ use Backend;
use Redirect;
use BackendMenu;
use Backend\Classes\Controller;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\SettingsManager;
use System\Models\RequestLog;
use Exception;

View File

@ -7,7 +7,7 @@ use Redirect;
use BackendMenu;
use System\Classes\SettingsManager;
use Backend\Classes\Controller;
use System\Classes\ApplicationException;
use ApplicationException;
use Exception;
/**

View File

@ -15,7 +15,7 @@ use System\Console\CacheClear;
use System\Classes\UpdateManager;
use System\Classes\PluginManager;
use System\Classes\SettingsManager;
use System\Classes\ApplicationException;
use ApplicationException;
use Exception;
/**

View File

@ -1,7 +1,7 @@
<?php namespace System\Models;
use Model;
use System\Classes\ApplicationException;
use ApplicationException;
/**
* Mail layout

View File

@ -36,9 +36,10 @@ return [
'October\Rain\Html\HtmlServiceProvider',
'October\Rain\Network\NetworkServiceProvider',
'October\Rain\Translation\TranslationServiceProvider',
'October\Rain\Support\Scaffold\ScaffoldServiceProvider',
'October\Rain\Support\FlashServiceProvider',
'October\Rain\Scaffold\ScaffoldServiceProvider',
'October\Rain\Flash\FlashServiceProvider',
'October\Rain\Mail\MailServiceProvider',
'October\Rain\Parse\ParseServiceProvider',
/*
* Vendor providers

View File

@ -5,7 +5,7 @@ use File;
use Request;
use System\Models\Parameters;
use System\Models\PluginVersion;
use System\Classes\SystemException;
use SystemException;
/**
* Asset Maker Trait

View File

@ -3,8 +3,8 @@
use File;
use Lang;
use Event;
use October\Rain\Support\Yaml;
use System\Classes\SystemException;
use Yaml;
use SystemException;
use Backend\Classes\Controller;
use stdClass;

View File

@ -3,7 +3,7 @@
use File;
use Lang;
use Block;
use System\Classes\SystemException;
use SystemException;
/**
* View Maker Trait

View File

@ -5,7 +5,7 @@ use Twig_Extension;
use Twig_TokenParser;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use System\Classes\ApplicationException;
use ApplicationException;
use System\Classes\MarkupManager;
/**

View File

@ -7,7 +7,7 @@ use Cms\Classes\Layout;
use Cms\Classes\Controller;
use Cms\Classes\CmsException;
use Cms\Classes\CodeParser;
use System\Classes\SystemException;
use SystemException;
class CmsExceptionTest extends TestCase
{

View File

@ -140,7 +140,7 @@ class CmsObjectTest extends TestCase
}
/**
* @expectedException \System\Classes\ApplicationException
* @expectedException \October\Rain\Exception\ApplicationException
* @expectedExceptionMessage The property 'something' cannot be set
*/
public function testFillNotFillable()
@ -156,7 +156,7 @@ class CmsObjectTest extends TestCase
}
/**
* @expectedException \October\Rain\Support\ValidationException
* @expectedException \October\Rain\Exception\ValidationException
* @expectedExceptionMessage Invalid file name
*/
public function testFillInvalidFileNameSymbol()
@ -171,7 +171,7 @@ class CmsObjectTest extends TestCase
}
/**
* @expectedException \October\Rain\Support\ValidationException
* @expectedException \October\Rain\Exception\ValidationException
* @expectedExceptionMessage Invalid file name
*/
public function testFillInvalidFileNamePath()
@ -187,7 +187,7 @@ class CmsObjectTest extends TestCase
/**
* @expectedException \October\Rain\Support\ValidationException
* @expectedException \October\Rain\Exception\ValidationException
* @expectedExceptionMessage Invalid file name
*/
public function testFillInvalidFileSlash()
@ -202,7 +202,7 @@ class CmsObjectTest extends TestCase
}
/**
* @expectedException \October\Rain\Support\ValidationException
* @expectedException \October\Rain\Exception\ValidationException
* @expectedExceptionMessage The File Name field is required
*/
public function testFillEmptyFileName()
@ -268,7 +268,7 @@ class CmsObjectTest extends TestCase
/**
* @depends testRename
* @expectedException \System\Classes\ApplicationException
* @expectedException \October\Rain\Exception\ApplicationException
* @expectedExceptionMessage already exists
*/
public function testRenameToExistingFile()

View File

@ -310,12 +310,12 @@ setting = "test"
==
use October\Rain\Support\Str; // This will be removed (-1 line)
use October\Rain\Support\FlashBag; // This will be removed (-1 line)
use October\Rain\Flash\FlashBag; // This will be removed (-1 line)
function onStart() { // Line 7
use October\Rain\Support\Str; // And placed here
use October\Rain\Support\FlashBag; // And placed here
use October\Rain\Flash\FlashBag; // And placed here
}
==

View File

@ -60,7 +60,7 @@ class ThemeTest extends TestCase
}
/**
* @expectedException \System\Classes\SystemException
* @expectedException \October\Rain\Exception\SystemException
* @expectedExceptionMessage The active theme is not set.
*/
public function testNoActiveTheme()