You are here

public function Flow::getEntityTypeConfig in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Flow.php \Drupal\cms_content_sync\Entity\Flow::getEntityTypeConfig()

Get the config for the given entity type or all entity types.

Parameters

$entity_type:

$entity_bundle:

bool $used_only: Return only the configs where a handler is set

Return value

array

9 calls to Flow::getEntityTypeConfig()
Flow::canPullEntity in src/Entity/Flow.php
Ask this Flow whether or not it can push the provided entity.
Flow::canPushEntityType in src/Entity/Flow.php
Ask this Flow whether or not it can push the given entity type and optionally bundle.
Flow::getEntityTypesToPull in src/Entity/Flow.php
Return all entity type configs with pull enabled.
Flow::getPoolsToPushTo in src/Entity/Flow.php
Get a list of all pools that are used for pushing this entity, either automatically or manually selected.
Flow::getPushedEntityTypes in src/Entity/Flow.php
Return all entity type configs with push enabled.

... See full list

File

src/Entity/Flow.php, line 875

Class

Flow
Defines the "Content Sync - Flow" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public function getEntityTypeConfig($entity_type = null, $entity_bundle = null, $used_only = false) {
  $entity_types = $this->sync_entities;
  $result = [];
  foreach ($entity_types as $id => &$type) {

    // Ignore field definitions.
    if (1 != substr_count($id, '-')) {
      continue;
    }
    if ($used_only && self::HANDLER_IGNORE == $type['handler']) {
      continue;
    }
    preg_match('/^(.+)-(.+)$/', $id, $matches);
    $entity_type_name = $matches[1];
    $bundle_name = $matches[2];
    if ($entity_type && $entity_type_name != $entity_type) {
      continue;
    }
    if ($entity_bundle && $bundle_name != $entity_bundle) {
      continue;
    }

    // If this is called before being saved, we want to have version etc.
    // available still.
    if (empty($type['version'])) {
      $type['version'] = Flow::getEntityTypeVersion($entity_type_name, $bundle_name);
      $type['entity_type_name'] = $entity_type_name;
      $type['bundle_name'] = $bundle_name;
    }
    if ($entity_type && $entity_bundle) {
      return $type;
    }
    $result[$id] = $type;
  }
  return $result;
}