Allow custom attributes in type definitions for user-land metadata

This commit is contained in:
vladar 2015-10-17 17:35:56 +06:00
parent 2d54f654c2
commit 5f2b2376e0

View File

@ -80,7 +80,10 @@ class Config
// Make sure there are no unexpected keys in map // Make sure there are no unexpected keys in map
$unexpectedKeys = array_keys(array_diff_key($map, $definitions)); $unexpectedKeys = array_keys(array_diff_key($map, $definitions));
Utils::invariant(empty($unexpectedKeys), 'Error in "'.$typeName.'" type definition: Unexpected keys "%s" ' . $suffix, implode(', ', $unexpectedKeys)); if (!empty($unexpectedKeys)) {
trigger_error(sprintf('"%s" type definition: Unexpected keys "%s" ' . $suffix, $typeName, implode(', ', $unexpectedKeys)));
$map = array_intersect_key($map, $definitions);
}
// Make sure that all required keys are present in map // Make sure that all required keys are present in map
$requiredKeys = array_filter($definitions, function($def) {return (self::_getFlags($def) & self::REQUIRED) > 0;}); $requiredKeys = array_filter($definitions, function($def) {return (self::_getFlags($def) & self::REQUIRED) > 0;});