// Save in the definition whether this is a module or a theme. This is
// important because when creating the plugin instance (the Component
// object) we'll need to negotiate based on the active theme.
$definitions =
array_map([$this, 'alterDefinition'
],
$definitions);
// Validate the definition after alterations.
assert( Inspector::
assertAll( fn(array
$definition) =>
$this->
isValidDefinition($definition),
$definitions ) );
parent::
alterDefinitions($definitions);
// Finally, validate replacements.
$replacing_definitions =
array_filter( $definitions,
static fn(array
$definition) => ($definition['replaces'
] ?? NULL
) && ($definitions[$definition['replaces'
]] ?? NULL
) );
$validation_errors =
array_reduce($replacing_definitions,
function Darray
$errors, array
$new_definition) use ($definitions) { $original_definition =
$definitions[$new_definition['replaces'
]];
$original_schemas =
$original_definition['props'
] ?? NULL;
$new_schemas =
$new_definition['props'
] ?? NULL;
if (!
$original_schemas || !
$new_schemas) {