getDefinitionClass example

      if (isset($values[$key]) && $values[$key] instanceof Translation) {
        $values[$key] = (string) $values[$key]->get();
      }
      else {
        $values[$key] = NULL;
      }
    }
    if (isset($values['class']) && !in_array('Drupal\Core\Plugin\Context\ContextDefinitionInterface', class_implements($values['class']))) {
      throw new \Exception('ContextDefinition class must implement \Drupal\Core\Plugin\Context\ContextDefinitionInterface.');
    }

    $class = $this->getDefinitionClass($values);
    $this->definition = new $class($values['value']$values['label']$values['required']$values['multiple']$values['description']$values['default_value']);

    if (isset($values['constraints'])) {
      foreach ($values['constraints'] as $constraint_name => $options) {
        $this->definition->addConstraint($constraint_name$options);
      }
    }
  }

  /** * Determines the context definition class to use. * * If the annotation specifies a specific context definition class, we use * that. Otherwise, we use \Drupal\Core\Plugin\Context\EntityContextDefinition * if the data type starts with 'entity:', since it contains specialized logic * specific to entities. Otherwise, we fall back to the generic * \Drupal\Core\Plugin\Context\ContextDefinition class. * * @param array $values * The annotation values. * * @return string * The fully-qualified name of the context definition class. */
$definition->addExtension($extension);
        }

        return $definition;
    }

    protected function removeExtension(string ...$extensionsClasses): void
    {
        foreach ($extensionsClasses as $extensionsClass) {
            /** @var EntityExtension $extension */
            $extension = new $extensionsClass();
            if ($this->getContainer()->has($extension->getDefinitionClass())) {
                /** @var EntityDefinition $definition */
                $definition = $this->getContainer()->get($extension->getDefinitionClass());

                $definition->removeExtension($extension);

                $salesChannelDefinitionId = 'sales_channel_definition.' . $extension->getDefinitionClass();

                if ($this->getContainer()->has($salesChannelDefinitionId)) {
                    /** @var EntityDefinition $definition */
                    $definition = $this->getContainer()->get('sales_channel_definition.' . $extension->getDefinitionClass());

                    
$configLoader->load($confDir . '/{packages}/prod/*' . Kernel::CONFIG_EXTS, 'glob');
        }
    }

    private function registerEntityExtensions(
        DefinitionInstanceRegistry $definitionRegistry,
        SalesChannelDefinitionInstanceRegistry $salesChannelRegistry,
        ExtensionRegistry $registry
    ): void {
        foreach ($registry->getExtensions() as $extension) {
            /** @var string $class */
            $class = $extension->getDefinitionClass();

            $definition = $definitionRegistry->get($class);

            $definition->addExtension($extension);

            $salesChannelDefinition = $salesChannelRegistry->get($class);

            // same definition? do not added extension             if ($salesChannelDefinition !== $definition) {
                $salesChannelDefinition->addExtension($extension);
            }
        }
Home | Imprint | This part of the site doesn't use cookies.