You are here

private function EntityProcessorBase::createBundle in Content Synchronizer 8

Same name and namespace in other branches
  1. 8.2 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createBundle()
  2. 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createBundle()

Create missing Bundle

Parameters

$bundle_type:

$bundle_name:

1 call to EntityProcessorBase::createBundle()
EntityProcessorBase::checkBundle in src/Processors/Entity/EntityProcessorBase.php
Check if entity's bundle exist, create-it

File

src/Processors/Entity/EntityProcessorBase.php, line 280

Class

EntityProcessorBase
The entity processor base.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

private function createBundle($bundle_type, $bundle_name) {
  $storage = \Drupal::entityTypeManager()
    ->getStorage($bundle_type);
  $data = [];
  switch ($bundle_type) {
    case "taxonomy_vocabulary":
      $data = [
        'vid' => $bundle_name,
        'name' => $bundle_name,
        'weight' => 0,
      ];
      break;
    case "media_type":
      $data = [
        'id' => $bundle_name,
        'label' => $bundle_name,
        'status' => 1,
      ];
      break;
    case "paragraphs_type":
      $data = [
        'id' => $bundle_name,
        'label' => $bundle_name,
      ];
      break;
    case "node_type":
      $data = [
        'type' => $bundle_name,
        'name' => $bundle_name,
      ];
      break;
  }
  $bundle = $storage
    ->create($data);
  $bundle
    ->save();
}