From b51b111786d0c482230d61118eb972f8a405b772 Mon Sep 17 00:00:00 2001 From: Morten Rugaard Date: Thu, 7 Jan 2016 10:38:43 +0100 Subject: [PATCH] Updated exceptions to new nodes core format. Small tweaks here and there. --- composer.json | 2 +- src/Exceptions/CounterCacheException.php | 14 +++++++------- src/Exceptions/NoCounterCachesFoundException.php | 14 +++++++------- src/Exceptions/NoEntitiesFoundException.php | 14 +++++++------- src/Exceptions/NotCounterCacheableException.php | 14 +++++++------- src/Exceptions/RelationNotFoundException.php | 14 +++++++------- src/Traits/CounterCacheRestored.php | 8 +++++--- 7 files changed, 41 insertions(+), 39 deletions(-) diff --git a/composer.json b/composer.json index 333c4f8..b6c0d18 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } ], "require": { - "php": ">=5.5.9", + "laravel/framework": "5.1.*", "nodes/core": "^0.1" }, "autoload": { diff --git a/src/Exceptions/CounterCacheException.php b/src/Exceptions/CounterCacheException.php index 91d85fa..003b965 100644 --- a/src/Exceptions/CounterCacheException.php +++ b/src/Exceptions/CounterCacheException.php @@ -16,14 +16,14 @@ class CounterCacheException extends NodesException * @author Morten Rugaard * * @access public - * @param string $message - * @param integer $statusCode - * @param string|null $statusMessage - * @param array $headers - * @param boolean $report + * @param string $message + * @param integer $code + * @param array $headers + * @param boolean $report + * @param string $severity */ - public function __construct($message = 'Counter cache failed', $statusCode = 500, $statusMessage = 'Counter cache failed', array $headers = [], $report = true) + public function __construct($message = 'Counter cache failed', $code = 500, array $headers = [], $report = true, $severity = 'error') { - parent::__construct($message, $statusCode, $statusMessage, $headers, $report); + parent::__construct($message, $code, $headers, $report, $severity); } } \ No newline at end of file diff --git a/src/Exceptions/NoCounterCachesFoundException.php b/src/Exceptions/NoCounterCachesFoundException.php index ea2d728..00fd608 100644 --- a/src/Exceptions/NoCounterCachesFoundException.php +++ b/src/Exceptions/NoCounterCachesFoundException.php @@ -14,14 +14,14 @@ class NoCounterCachesFound extends CounterCacheException * @author Morten Rugaard * * @access public - * @param string $message - * @param integer $statusCode - * @param string|null $statusMessage - * @param array $headers - * @param boolean $report + * @param string $message + * @param integer $code + * @param array $headers + * @param boolean $report + * @param string $severity */ - public function __construct($message = 'No counter caches found on model', $statusCode = 500, $statusMessage = 'Counter cache failed', array $headers = [], $report = true) + public function __construct($message = 'No counter caches found on model', $code = 500, array $headers = [], $report = true, $severity = 'error') { - parent::__construct($message, $statusCode, $statusMessage, $headers, $report); + parent::__construct($message, $code, $headers, $report, $severity); } } \ No newline at end of file diff --git a/src/Exceptions/NoEntitiesFoundException.php b/src/Exceptions/NoEntitiesFoundException.php index f59638f..4f1bb04 100644 --- a/src/Exceptions/NoEntitiesFoundException.php +++ b/src/Exceptions/NoEntitiesFoundException.php @@ -14,14 +14,14 @@ class NoEntitiesFoundException extends CounterCacheException * @author Morten Rugaard * * @access public - * @param string $message - * @param integer $statusCode - * @param string|null $statusMessage - * @param array $headers - * @param boolean $report + * @param string $message + * @param integer $code + * @param array $headers + * @param boolean $report + * @param string $severity */ - public function __construct($message = 'No entities found', $statusCode = 500, $statusMessage = 'Counter cache failed', array $headers = [], $report = true) + public function __construct($message = 'No entities found', $code = 500, array $headers = [], $report = true, $severity = 'error') { - parent::__construct($message, $statusCode, $statusMessage, $headers, $report); + parent::__construct($message, $code, $headers, $report, $severity); } } \ No newline at end of file diff --git a/src/Exceptions/NotCounterCacheableException.php b/src/Exceptions/NotCounterCacheableException.php index 9709c7b..6762e22 100644 --- a/src/Exceptions/NotCounterCacheableException.php +++ b/src/Exceptions/NotCounterCacheableException.php @@ -14,14 +14,14 @@ class NotCounterCacheableException extends CounterCacheException * @author Morten Rugaard * * @access public - * @param string $message - * @param integer $statusCode - * @param string|null $statusMessage - * @param array $headers - * @param boolean $report + * @param string $message + * @param integer $code + * @param array $headers + * @param boolean $report + * @param string $severity */ - public function __construct($message = 'Model does not implement CounterCacheable', $statusCode = 500, $statusMessage = 'Counter cache failed', array $headers = [], $report = true) + public function __construct($message = 'Model does not implement CounterCacheable', $code = 500, array $headers = [], $report = true, $severity = 'error') { - parent::__construct($message, $statusCode, $statusMessage, $headers, $report); + parent::__construct($message, $code, $headers, $report, $severity); } } \ No newline at end of file diff --git a/src/Exceptions/RelationNotFoundException.php b/src/Exceptions/RelationNotFoundException.php index c34f849..5d937f4 100644 --- a/src/Exceptions/RelationNotFoundException.php +++ b/src/Exceptions/RelationNotFoundException.php @@ -14,14 +14,14 @@ class RelationNotFoundException extends CounterCacheException * @author Morten Rugaard * * @access public - * @param string $message - * @param integer $statusCode - * @param string|null $statusMessage - * @param array $headers - * @param boolean $report + * @param string $message + * @param integer $code + * @param array $headers + * @param boolean $report + * @param string $severity */ - public function __construct($message = 'Relation not found on model', $statusCode = 500, $statusMessage = 'Counter cache failed', array $headers = [], $report = true) + public function __construct($message = 'Relation not found on model', $code = 500, array $headers = [], $report = true, $severity = 'error') { - parent::__construct($message, $statusCode, $statusMessage, $headers, $report); + parent::__construct($message, $code, $headers, $report, $severity); } } \ No newline at end of file diff --git a/src/Traits/CounterCacheRestored.php b/src/Traits/CounterCacheRestored.php index 6b13b42..f82f2d7 100644 --- a/src/Traits/CounterCacheRestored.php +++ b/src/Traits/CounterCacheRestored.php @@ -19,8 +19,10 @@ trait CounterCacheRestored */ public static function bootCounterCacheRestored() { - static::restored(function($model) { - app('Nodes\CounterCache\CounterCache')->count($model); - }); + if (method_exists(__CLASS__, 'restored')) { + static::restored(function ($model) { + app('Nodes\CounterCache\CounterCache')->count($model); + }); + } } } \ No newline at end of file