You are here

public function Flag::getApplicableBundles in Flag 8.4

Get the bundles this flag may be applied to.

For the verbatim value of the flag's types property, use getBundles().

Return value

array An array containing the bundles this flag may be applied to.

Overrides FlagInterface::getApplicableBundles

File

src/Entity/Flag.php, line 228

Class

Flag
Provides the Flag configuration entity.

Namespace

Drupal\flag\Entity

Code

public function getApplicableBundles() {
  $bundles = $this
    ->getBundles();
  if (empty($bundles)) {

    // If the setting is empty, return all bundle names for the flag's entity
    // type.

    /** @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info_service */
    $bundle_info_service = \Drupal::service('entity_type.bundle.info');
    $bundle_info = $bundle_info_service
      ->getBundleInfo($this->entity_type);
    $bundles = array_keys($bundle_info);
  }
  return $bundles;
}