You are here

public function SchedulerManager::getEnabledTypes in Scheduler 2.x

Gets the names of the types/bundles enabled for a specific process.

If the entity type is not supported by Scheduler, or there are no enabled bundles for this process within the entity type, then an empty array is returned.

Parameters

string $entityTypeId: The entity type id, for example 'node' or 'media'.

string $process: The process to check - 'publish' or 'unpublish'.

Return value

array The entity's type/bundle names that are enabled for the required process.

2 calls to SchedulerManager::getEnabledTypes()
SchedulerManager::publish in src/SchedulerManager.php
Publish scheduled entities.
SchedulerManager::unpublish in src/SchedulerManager.php
Unpublish scheduled entities.

File

src/SchedulerManager.php, line 968

Class

SchedulerManager
Defines a scheduler manager.

Namespace

Drupal\scheduler

Code

public function getEnabledTypes($entityTypeId, $process) {
  if (!($plugin = $this
    ->getPlugin($entityTypeId))) {
    return [];
  }
  $types = $plugin
    ->getTypes();
  $types = array_filter($types, function ($bundle) use ($process) {
    return $bundle
      ->getThirdPartySetting('scheduler', $process . '_enable', $this
      ->setting('default_' . $process . '_enable'));
  });
  return array_keys($types);
}