public function validateDefinition(array
$definition, bool
$enforce_schemas): bool
{ // First ensure there are no name collisions between props and slots.
$prop_names =
array_keys($definition['props'
]['properties'
] ??
[]);
$slot_names =
array_keys($definition['slots'
] ??
[]);
$collisions =
array_intersect($prop_names,
$slot_names);
if ($collisions) { $message =
sprintf( 'The component "%s" declared [%s] both as a prop and as a slot. Make sure to use different names.',
$definition['id'
],
implode(', ',
$collisions) );
throw new InvalidComponentException($message);
} // If the validator isn't set, then the validation library is not installed.
if (!
$this->validator
) { return TRUE;
} // Detect the props with a type class, and validate that the class exists.
$schema =
$definition['props'
] ?? NULL;
if (!
$schema) { if ($enforce_schemas) { throw new InvalidComponentException(sprintf('The component "%s" does not provide schema information. Schema definitions are mandatory for components declared in modules. For components declared in themes, schema definitions are only mandatory if the "enforce_prop_schemas" key is set to "true" in the theme info file.',
$definition['id'
]));
}