Completed
Push — master ( 94ddbb...e5219e )
by Jean-Christophe
04:25
created

ValidatorsManagerInitTrait::initModelsValidators()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 8
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Ubiquity\contents\validation;
4
5
use Ubiquity\cache\CacheManager;
6
7
/**
8
 * @author jcheron <[email protected]>
9
 * @property array $validatorTypes
10
 */
11
trait ValidatorsManagerInitTrait {
12
	/**
13
	 * Parses models and save validators in cache
14
	 * to use in dev only
15
	 * @param array $config
16
	 */
17 1
	public static function initModelsValidators(&$config){
18 1
		$models=CacheManager::getModels($config,true);
19 1
		foreach ($models as $model){
20 1
			$parser=new ValidationModelParser();
21 1
			$parser->parse($model);
22 1
			$validators=$parser->getValidators();
23 1
			if(sizeof($validators)>0){
24 1
				self::store($model, $parser->__toString());
25
			}
26
		}
27 1
	}
28
	
29
	/**
30
	 * Registers a validator type for using with @validator annotation
31
	 * @param string $type
32
	 * @param string $validatorClass
33
	 */
34
	public static function registerType($type,$validatorClass){
35
		self::$validatorTypes[$type]=$validatorClass;
36
	}
37
}
38
39