|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* TechDivision\Import\Callbacks\IndexedArrayValidatorCallback |
|
5
|
|
|
* |
|
6
|
|
|
* NOTICE OF LICENSE |
|
7
|
|
|
* |
|
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
|
9
|
|
|
* that is available through the world-wide-web at this URL: |
|
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
|
11
|
|
|
* |
|
12
|
|
|
* PHP version 5 |
|
13
|
|
|
* |
|
14
|
|
|
* @author Tim Wagner <[email protected]> |
|
15
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
17
|
|
|
* @link https://github.com/techdivision/import |
|
18
|
|
|
* @link http://www.techdivision.com |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Callbacks; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Array validator callback implementation that expects an indexed array with |
|
25
|
|
|
* validations, whereas the key is the attribute name. |
|
26
|
|
|
* |
|
27
|
|
|
* @author Tim Wagner <[email protected]> |
|
28
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
|
29
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
|
30
|
|
|
* @link https://github.com/techdivision/import |
|
31
|
|
|
* @link http://www.techdivision.com |
|
32
|
|
|
*/ |
|
33
|
|
|
class IndexedArrayValidatorCallback extends ArrayValidatorCallback |
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Returns the validations for the attribute with the passed code. |
|
38
|
|
|
* |
|
39
|
|
|
* @param string|null $attributeCode The code of the attribute to return the validations for |
|
40
|
|
|
* |
|
41
|
|
|
* @return array The allowed values for the attribute with the passed code |
|
42
|
|
|
*/ |
|
43
|
|
|
protected function getValidations($attributeCode = null) |
|
44
|
|
|
{ |
|
45
|
|
|
|
|
46
|
|
|
// query whether or not if allowed values have been specified |
|
47
|
|
|
if (isset($this->validations[$attributeCode])) { |
|
48
|
|
|
return $this->validations[$attributeCode]; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
// return an empty array, if NOT |
|
52
|
|
|
return array(); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|