1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* 2017 Romain CANON <[email protected]> |
4
|
|
|
* |
5
|
|
|
* This file is part of the TYPO3 FormZ project. |
6
|
|
|
* It is free software; you can redistribute it and/or modify it |
7
|
|
|
* under the terms of the GNU General Public License, either |
8
|
|
|
* version 3 of the License, or any later version. |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, see: |
11
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Romm\Formz\Form\Service\DataObject; |
15
|
|
|
|
16
|
|
|
use Romm\Formz\Exceptions\FormzException; |
17
|
|
|
|
18
|
|
|
class WrongFormIdentifierObjectDataException extends FormzException |
19
|
|
|
{ |
20
|
|
|
const WRONG_HASH = 'The following hash could not be decrypted: "%s".'; |
21
|
|
|
|
22
|
|
|
const WRONG_TYPE = 'The data retrieved in the hash is not an array, the type is "%s".'; |
23
|
|
|
|
24
|
|
|
const CLASS_NAME_NOT_FOUND = 'The class name property was not found in the decrypted hash.'; |
25
|
|
|
|
26
|
|
|
const UNIQUE_HASH_NOT_FOUND = 'The unique hash property was not found in the decrypted hash.'; |
27
|
|
|
|
28
|
|
|
const WRONG_CLASS_NAME = 'The class name fetched from the decrypted hash (value: "%s") does not match the class name of the form object (value: "%s").'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @code 1490946563 |
32
|
|
|
* |
33
|
|
|
* @param string $hash |
34
|
|
|
* @return self |
35
|
|
|
*/ |
36
|
|
|
final public static function wrongHash($hash) |
37
|
|
|
{ |
38
|
|
|
/** @var self $exception */ |
39
|
|
|
$exception = self::getNewExceptionInstance( |
40
|
|
|
self::WRONG_HASH, |
41
|
|
|
[$hash] |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
return $exception; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @code 1490946576 |
49
|
|
|
* |
50
|
|
|
* @param mixed $data |
51
|
|
|
* @return self |
52
|
|
|
*/ |
53
|
|
|
final public static function wrongType($data) |
54
|
|
|
{ |
55
|
|
|
/** @var self $exception */ |
56
|
|
|
$exception = self::getNewExceptionInstance( |
57
|
|
|
self::WRONG_TYPE, |
58
|
|
|
[gettype($data)] |
59
|
|
|
); |
60
|
|
|
|
61
|
|
|
return $exception; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @code 1490946908 |
66
|
|
|
* |
67
|
|
|
* @return self |
68
|
|
|
*/ |
69
|
|
|
final public static function classNameNotFound() |
70
|
|
|
{ |
71
|
|
|
/** @var self $exception */ |
72
|
|
|
$exception = self::getNewExceptionInstance(self::CLASS_NAME_NOT_FOUND); |
73
|
|
|
|
74
|
|
|
return $exception; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @code 1490946992 |
79
|
|
|
* |
80
|
|
|
* @return self |
81
|
|
|
*/ |
82
|
|
|
final public static function uniqueHashNotFound() |
83
|
|
|
{ |
84
|
|
|
/** @var self $exception */ |
85
|
|
|
$exception = self::getNewExceptionInstance(self::UNIQUE_HASH_NOT_FOUND); |
86
|
|
|
|
87
|
|
|
return $exception; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @code 1490964528 |
92
|
|
|
* |
93
|
|
|
* @param string $fetchedClassName |
94
|
|
|
* @param string $formObjectClassName |
95
|
|
|
* @return WrongFormIdentifierObjectDataException |
96
|
|
|
*/ |
97
|
|
|
final public static function wrongClassName($fetchedClassName, $formObjectClassName) |
98
|
|
|
{ |
99
|
|
|
/** @var self $exception */ |
100
|
|
|
$exception = self::getNewExceptionInstance( |
101
|
|
|
self::WRONG_CLASS_NAME, |
102
|
|
|
[$fetchedClassName, $formObjectClassName] |
103
|
|
|
); |
104
|
|
|
|
105
|
|
|
return $exception; |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|