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": {
"php": ">=5.5.9",
"laravel/framework": "5.1.*",
"nodes/core": "^0.1"
},
"autoload": {

View File

@ -16,14 +16,14 @@ class CounterCacheException extends NodesException
* @author Morten Rugaard <moru@nodes.dk>
*
* @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);
}
}

View File

@ -14,14 +14,14 @@ class NoCounterCachesFound extends CounterCacheException
* @author Morten Rugaard <moru@nodes.dk>
*
* @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);
}
}

View File

@ -14,14 +14,14 @@ class NoEntitiesFoundException extends CounterCacheException
* @author Morten Rugaard <moru@nodes.dk>
*
* @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);
}
}

View File

@ -14,14 +14,14 @@ class NotCounterCacheableException extends CounterCacheException
* @author Morten Rugaard <moru@nodes.dk>
*
* @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);
}
}

View File

@ -14,14 +14,14 @@ class RelationNotFoundException extends CounterCacheException
* @author Morten Rugaard <moru@nodes.dk>
*
* @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);
}
}

View File

@ -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);
});
}
}
}