private function EntityProcessorBase::createBundle in Content Synchronizer 3.x
Same name and namespace in other branches
- 8.2 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createBundle()
- 8 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createBundle()
Create missing Bundle.
Parameters
string $bundle_type: The bundle.
string $bundle_name: The 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 320
Class
- EntityProcessorBase
- The entity processor base.
Namespace
Drupal\content_synchronizer\Processors\EntityCode
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;
}
if ($data) {
$bundle = $storage
->create($data);
$bundle
->save();
}
}