1
0
mirror of https://github.com/flarum/core.git synced 2025-10-08 21:46:25 +02:00
Files
php-flarum/src/Core/Exceptions/ValidationException.php
Toby Zerner cbcad27679 Improve installer validation
Very rough, but works for now. The basic premise being that we need to
collect all user data before we proceed with installation.
2015-09-14 18:13:24 +09:30

51 lines
1.0 KiB
PHP

<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\Core\Exceptions;
use Exception;
class ValidationException extends Exception implements JsonApiSerializable
{
protected $messages;
public function __construct(array $messages)
{
$this->messages = $messages;
parent::__construct(implode("\n", $messages));
}
public function getMessages()
{
return $this->messages;
}
/**
* {@inheritdoc}
*/
public function getStatusCode()
{
return 422;
}
/**
* {@inheritdoc}
*/
public function getErrors()
{
return array_map(function ($path, $detail) {
$source = ['pointer' => '/data/attributes/' . $path];
return compact('source', 'detail');
}, array_keys($this->messages), $this->messages);
}
}