You are here

function entityqueue_smartqueue_entity_bundle_field_info in Entityqueue 8

Implements hook_entity_bundle_field_info().

File

modules/entityqueue_smartqueue/entityqueue_smartqueue.module, line 54
Provides automated subqueues for each entity of a given entity type.

Code

function entityqueue_smartqueue_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {

  /** @var \Drupal\entityqueue\EntityQueueInterface $queue */
  if ($entity_type
    ->id() === 'entity_subqueue' && ($queue = EntityQueue::load($bundle)) && $queue
    ->getHandler() === 'smartqueue') {
    $field_storage_definitions = \Drupal::service('entity_field.manager')
      ->getActiveFieldStorageDefinitions('entity_subqueue');
    $field_definitions['attached_entity'] = FieldDefinition::createFromFieldStorageDefinition($field_storage_definitions['attached_entity']);
    $field_definitions['attached_entity']
      ->setTargetBundle($bundle);
    $field_definitions['attached_entity']
      ->setSetting('target_type', $queue
      ->getHandlerConfiguration()['entity_type']);
    return $field_definitions;
  }
}