| 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\Condition\Exceptions; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Romm\Formz\Exceptions\FormzException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Romm\Formz\Form\Definition\Field\Field; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Romm\Formz\Form\Definition\Field\Validation\Validator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | class InvalidConditionException extends FormzException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     const INVALID_FIELD_CONDITION_CONFIGURATION = 'Invalid configuration for the condition "%s", used on the field "%s" of the form "%s"; error message is « %s » (code: %s).'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     const INVALID_VALIDATION_CONDITION_CONFIGURATION = 'Invalid configuration for the condition "%s", used on the validation "%s" of the field "%s" of the form "%s"; error message is « %s » (code: %s).'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     const FIELD_DOES_NOT_EXIST = 'The field "%s" does not exist.'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     const VALIDATION_DOES_NOT_EXIST_FOR_FIELD = 'The validation "%s" does not exist for the field "%s".'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      * @code 1488653398 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |      * @param string     $conditionName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |      * @param Field      $field | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |      * @param string     $formClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |      * @param \Exception $exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     final public static function invalidFieldConditionConfiguration($conditionName, Field $field, $formClassName, \Exception $exception) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             self::INVALID_FIELD_CONDITION_CONFIGURATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |                 $conditionName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |                 $field->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |                 $formClassName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                 $exception->getMessage(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                 $exception->getCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      * @code 1488653713 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * @param string     $conditionName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * @param Validator  $validation | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * @param string     $formClassName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @param \Exception $exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     final public static function invalidValidationConditionConfiguration($conditionName, Validator $validation, $formClassName, \Exception $exception) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |             self::INVALID_VALIDATION_CONDITION_CONFIGURATION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                 $conditionName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                 $validation->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                 $validation->getParentField()->getName(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                 $formClassName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 $exception->getMessage(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 $exception->getCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |             ] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |      * @code 1488192037 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     final public static function conditionFieldHasErrorFieldNotFound($fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             [$fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |      * @code 1488192055 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |      * @param string $validationName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     final public static function conditionFieldHasErrorValidationNotFound($validationName, $fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |             self::VALIDATION_DOES_NOT_EXIST_FOR_FIELD, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             [$validationName, $fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |      * @code 1488192031 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     final public static function conditionFieldHasValueFieldNotFound($fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             [$fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |      * @code 1488191994 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     final public static function conditionFieldIsEmptyFieldNotFound($fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |             [$fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |      * @code 1518016343128 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     final public static function conditionFieldIsFilledFieldNotFound($fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             [$fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * @code 1488183577 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     final public static function conditionFieldIsValidFieldNotFound($fieldName) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         /** @var self $exception */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |             [$fieldName] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         return $exception; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |      * @code 1519909297 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |      * @param string $fieldName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |      * @return InvalidConditionException | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 193 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 194 |  |  |     final public static function conditionFieldCountValuesFieldNotFound($fieldName) | 
            
                                                        
            
                                    
            
            
                | 195 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 196 |  |  |         /** @var self $exception */ | 
            
                                                        
            
                                    
            
            
                | 197 |  |  |         $exception = self::getNewExceptionInstance( | 
            
                                                        
            
                                    
            
            
                | 198 |  |  |             self::FIELD_DOES_NOT_EXIST, | 
            
                                                        
            
                                    
            
            
                | 199 |  |  |             [$fieldName] | 
            
                                                        
            
                                    
            
            
                | 200 |  |  |         ); | 
            
                                                        
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 202 |  |  |         return $exception; | 
            
                                                        
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 204 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 205 |  |  |  |