1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ubiquity\contents\validation\traits; |
4
|
|
|
|
5
|
|
|
use Ubiquity\cache\CacheManager; |
6
|
|
|
use Ubiquity\controllers\Startup; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* |
10
|
|
|
* @author jcheron <[email protected]> |
11
|
|
|
* @property array $validatorTypes |
12
|
|
|
*/ |
13
|
|
|
trait ValidatorsManagerInitTrait { |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Parses models and save validators in cache |
17
|
|
|
* to use in dev only |
18
|
|
|
* |
19
|
|
|
* @param array $config |
20
|
|
|
* @param array $databaseOffset |
21
|
|
|
*/ |
22
|
|
|
public static function initModelsValidators(&$config, $databaseOffset = 'default') { |
23
|
|
|
$models = CacheManager::getModels ( $config, true, $databaseOffset ); |
24
|
|
|
foreach ( $models as $model ) { |
25
|
|
|
self::initClassValidators ( $model ); |
26
|
|
|
} |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* |
31
|
|
|
* Parses a class and save validators in cache |
32
|
|
|
* to use in dev only |
33
|
|
|
* |
34
|
|
|
* @param string $class |
35
|
|
|
*/ |
36
|
|
|
public static function initClassValidators($class) { |
37
|
|
|
$parser = new ValidationModelParser (); |
|
|
|
|
38
|
|
|
$parser->parse ( $class ); |
39
|
|
|
$validators = $parser->getValidators (); |
40
|
|
|
if (\count ( $validators ) > 0) { |
41
|
|
|
self::store ( $class, $validators ); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Parses a class and save validators in cache |
47
|
|
|
* |
48
|
|
|
* @param string $class |
49
|
|
|
*/ |
50
|
|
|
public static function addClassValidators($class) { |
51
|
|
|
$config = Startup::getConfig (); |
52
|
|
|
CacheManager::start ( $config ); |
53
|
|
|
self::initClassValidators ( $class ); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Registers a validator type for using with @validator annotation |
58
|
|
|
* |
59
|
|
|
* @param string $type |
60
|
|
|
* @param string $validatorClass |
61
|
|
|
*/ |
62
|
|
|
public static function registerType($type, $validatorClass) { |
63
|
|
|
self::$validatorTypes [$type] = $validatorClass; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths