isValidDefinition example

/** * {@inheritdoc} */
  protected function alterDefinitions(&$definitions) {
    // 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_definitionsfunction Darray $errors, array $new_definition) use ($definitions) {
      
Home | Imprint | This part of the site doesn't use cookies.