public function ScheduledTransitionsUtility::getBundles in Scheduled Transitions 2.x
Same name and namespace in other branches
- 8 src/ScheduledTransitionsUtility.php \Drupal\scheduled_transitions\ScheduledTransitionsUtility::getBundles()
Get list of entity type/bundles scheduled transitions are enabled on.
Return value
array Arrays of bundles keyed by entity type.
Overrides ScheduledTransitionsUtilityInterface::getBundles
File
- src/
ScheduledTransitionsUtility.php, line 146
Class
- ScheduledTransitionsUtility
- Utilities for Scheduled Transitions module.
Namespace
Drupal\scheduled_transitionsCode
public function getBundles() : array {
$enabledBundlesCache = $this->cache
->get(static::CID_SCHEDULED_TRANSITIONS_BUNDLES);
if ($enabledBundlesCache !== FALSE) {
return $enabledBundlesCache->data ?? [];
}
$enabledBundles = $this->configFactory
->get('scheduled_transitions.settings')
->get('bundles');
$enabledBundles = array_map(function (array $bundleConfig) {
return sprintf('%s:%s', $bundleConfig['entity_type'], $bundleConfig['bundle']);
}, is_array($enabledBundles) ? $enabledBundles : []);
$applicableBundles = $this
->getApplicableBundles();
foreach ($applicableBundles as $entityTypeId => &$bundles) {
$bundles = array_filter($bundles, function (string $bundle) use ($entityTypeId, $enabledBundles) {
return in_array($entityTypeId . ':' . $bundle, $enabledBundles);
});
}
$applicableBundles = array_filter($applicableBundles);
$this->cache
->set(static::CID_SCHEDULED_TRANSITIONS_BUNDLES, $applicableBundles, Cache::PERMANENT, [
SettingsForm::SETTINGS_TAG,
]);
return $applicableBundles;
}