function CreateForEachBundle::apply

Overrides ConfigActionPluginInterface::apply

File

core/lib/Drupal/Core/Config/Action/Plugin/ConfigAction/CreateForEachBundle.php, line 86

Class

CreateForEachBundle
Creates config entities for each bundle of a particular entity type.

Namespace

Drupal\Core\Config\Action\Plugin\ConfigAction

Code

public function apply(string $configName, mixed $value) : void {
    assert(is_array($value));
    $bundle = $this->configManager
        ->loadConfigEntityByName($configName);
    assert(is_object($bundle));
    $value = static::replacePlaceholders($value, [
        static::BUNDLE_PLACEHOLDER => $bundle->id(),
        static::LABEL_PLACEHOLDER => $bundle->label(),
    ]);
    foreach ($value as $name => $values) {
        // Invoke the actual create action via the config action manager, so that
        // the created entity will be validated.
        $this->configActionManager
            ->applyAction('entity_create:' . $this->createAction, $name, $values);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.