You are here

private function EntityProcessorBase::checkBundle 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::checkBundle()
  2. 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::checkBundle()

Check if entity's bundle exist, create-it

Parameters

\Drupal\Core\Entity\Entity $entity:

bool $force_create:

1 call to EntityProcessorBase::checkBundle()
EntityProcessorBase::import in src/Processors/Entity/EntityProcessorBase.php
Create or update entity with data :.

File

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

Class

EntityProcessorBase
The entity processor base.

Namespace

Drupal\content_synchronizer\Processors\Entity

Code

private function checkBundle(\Drupal\Core\Entity\Entity $entity, $force_create = FALSE) {
  $bundle_type = $entity
    ->getEntityType()
    ->getBundleEntityType();
  if ($bundle_type == '') {
    return;
  }
  $bundle_name = $entity
    ->bundle();
  $bundle = \Drupal::entityTypeManager()
    ->getStorage($bundle_type)
    ->load($bundle_name);
  if ($bundle == NULL && $force_create === TRUE) {
    $this
      ->createBundle($bundle_type, $bundle_name);
  }
}