Updated exceptions to new nodes core format. Small tweaks here and there.

This commit is contained in:
Morten Rugaard 2016-01-07 10:38:43 +01:00
parent b3ff18b345
commit b51b111786
7 changed files with 41 additions and 39 deletions

View File

@ -19,7 +19,7 @@
} }
], ],
"require": { "require": {
"php": ">=5.5.9", "laravel/framework": "5.1.*",
"nodes/core": "^0.1" "nodes/core": "^0.1"
}, },
"autoload": { "autoload": {

View File

@ -17,13 +17,13 @@ class CounterCacheException extends NodesException
* *
* @access public * @access public
* @param string $message * @param string $message
* @param integer $statusCode * @param integer $code
* @param string|null $statusMessage
* @param array $headers * @param array $headers
* @param boolean $report * @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);
} }
} }

View File

@ -15,13 +15,13 @@ class NoCounterCachesFound extends CounterCacheException
* *
* @access public * @access public
* @param string $message * @param string $message
* @param integer $statusCode * @param integer $code
* @param string|null $statusMessage
* @param array $headers * @param array $headers
* @param boolean $report * @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);
} }
} }

View File

@ -15,13 +15,13 @@ class NoEntitiesFoundException extends CounterCacheException
* *
* @access public * @access public
* @param string $message * @param string $message
* @param integer $statusCode * @param integer $code
* @param string|null $statusMessage
* @param array $headers * @param array $headers
* @param boolean $report * @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);
} }
} }

View File

@ -15,13 +15,13 @@ class NotCounterCacheableException extends CounterCacheException
* *
* @access public * @access public
* @param string $message * @param string $message
* @param integer $statusCode * @param integer $code
* @param string|null $statusMessage
* @param array $headers * @param array $headers
* @param boolean $report * @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);
} }
} }

View File

@ -15,13 +15,13 @@ class RelationNotFoundException extends CounterCacheException
* *
* @access public * @access public
* @param string $message * @param string $message
* @param integer $statusCode * @param integer $code
* @param string|null $statusMessage
* @param array $headers * @param array $headers
* @param boolean $report * @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);
} }
} }

View File

@ -19,8 +19,10 @@ trait CounterCacheRestored
*/ */
public static function bootCounterCacheRestored() public static function bootCounterCacheRestored()
{ {
static::restored(function($model) { if (method_exists(__CLASS__, 'restored')) {
static::restored(function ($model) {
app('Nodes\CounterCache\CounterCache')->count($model); app('Nodes\CounterCache\CounterCache')->count($model);
}); });
} }
}
} }