-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathArrayContains.phptpl
More file actions
50 lines (41 loc) · 1.58 KB
/
ArrayContains.phptpl
File metadata and controls
50 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
is_array($value) && (function (&$items){% if countMatches %} use (&$countMatches){% endif %} {
if (empty($items)) {
return true;
}
{% if generatorConfiguration.collectErrors() %}
$originalErrorRegistry = $this->errorRegistry;
{% endif %}
foreach ($items as &$value) {
try {
{% if generatorConfiguration.collectErrors() %}
$this->errorRegistry = new {{ viewHelper.getSimpleClassName(generatorConfiguration.getErrorRegistryClass()) }}();
{% endif %}
{{ viewHelper.resolvePropertyDecorator(property) }}
{% foreach property.getOrderedValidators() as validator %}
{{ viewHelper.renderValidator(validator, schema) }}
{% endforeach %}
{% if generatorConfiguration.collectErrors() %}
if ($this->errorRegistry->getErrors()) {
continue;
}
$this->errorRegistry = $originalErrorRegistry;
{% endif %}
{% if countMatches %}
$countMatches++;
{% else %}
// one matched item is enough to pass the contains check
return false;
{% endif %}
} catch (\Exception $e) {
continue;
}
}
{% if generatorConfiguration.collectErrors() %}
$this->errorRegistry = $originalErrorRegistry;
{% endif %}
return {% if countMatches %}
{% if allowNoMatch %}false{% else %}$countMatches === 0{% endif %}
{% else %}
true
{% endif %};
})($value)