1
0
mirror of https://github.com/flarum/core.git synced 2025-10-12 15:34:26 +02:00

Distinguish between attributes/relationships in ValidationException

This exception could be a candidate for inclusion in tobscure/json-api...
This commit is contained in:
Toby Zerner
2016-06-05 09:25:26 +09:30
parent 0b3cc0c18f
commit f5988bae23
3 changed files with 38 additions and 15 deletions

View File

@@ -14,17 +14,26 @@ use Exception;
class ValidationException extends Exception
{
protected $messages;
protected $attributes;
protected $relationships;
public function __construct(array $messages)
public function __construct(array $attributes, array $relationships = [])
{
$this->messages = $messages;
$this->attributes = $attributes;
$this->relationships = $relationships;
$messages = [implode("\n", $attributes), implode("\n", $relationships)];
parent::__construct(implode("\n", $messages));
}
public function getMessages()
public function getAttributes()
{
return $this->messages;
return $this->attributes;
}
public function getRelationships()
{
return $this->relationships;
}
}