You are here

protected function SettingsForm::addNewConfigEntities in Content Planner 8

Check which config entity needs to be deleted.

Parameters

array $selected_content_types:

\Drupal\content_calendar\Entity\ContentTypeConfig[] $config_entities:

1 call to SettingsForm::addNewConfigEntities()
SettingsForm::submitForm in modules/content_calendar/src/Form/SettingsForm.php
Form submission handler.

File

modules/content_calendar/src/Form/SettingsForm.php, line 295

Class

SettingsForm
Defines a form that configures forms module settings.

Namespace

Drupal\content_calendar\Form

Code

protected function addNewConfigEntities(array $selected_content_types, array &$config_entities) {

  // Get entity keys.
  $entity_keys = array_keys($config_entities);
  foreach ($selected_content_types as $selected_content_type) {
    if (!in_array($selected_content_type, $entity_keys)) {
      if ($node_type = NodeType::load($selected_content_type)) {
        $this->contentTypeConfigService
          ->createEntity($selected_content_type, $node_type
          ->label());
        $this
          ->messenger()
          ->addMessage(t('Content Type @name has been added and can be configured below.', [
          '@name' => $node_type
            ->label(),
        ]));
      }
    }
  }
}