1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\Exception; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This exception is thrown when the configuration given to the AdminBundle is invalid. this can be when creating the |
9
|
|
|
* application, an admin, an action or a menu. |
10
|
|
|
*/ |
11
|
|
|
class ConfigurationException extends Exception |
12
|
|
|
{ |
13
|
|
|
private array $configuration; |
14
|
|
|
|
15
|
|
|
public function __construct( |
16
|
|
|
string $resourceType = null, |
17
|
|
|
string $resourceName = '', |
18
|
|
|
\Throwable $previous = null, |
19
|
|
|
array $configuration = [] |
20
|
|
|
) { |
21
|
|
|
$typeMessage = 'An error has occurred when resolving a configuration'; |
22
|
|
|
|
23
|
|
|
if ($resourceType === 'menu') { |
24
|
|
|
$typeMessage = 'An error has occurred when resolving the configuration for the menu "%s"'; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
if ($resourceType === 'action') { |
28
|
|
|
$typeMessage = 'An error has occurred when resolving the configuration of the action "%s"'; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
if ($resourceType === 'admin') { |
32
|
|
|
$typeMessage = 'An error has occurred when resolving the configuration of the admin "%s"'; |
33
|
|
|
} |
34
|
|
|
$message = sprintf($typeMessage, $resourceName); |
35
|
|
|
$code = 0; |
36
|
|
|
|
37
|
|
|
if ($previous !== null) { |
38
|
|
|
$message .= ' : '.$previous->getMessage(); |
39
|
|
|
$code = $previous->getCode(); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
parent::__construct($message, $code, $previous); |
43
|
|
|
$this->configuration = $configuration; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function getConfiguration(): array |
47
|
|
|
{ |
48
|
|
|
return $this->configuration; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|