You are here

public function FeaturesManager::isFeatureModule in Features 8.3

Same name and namespace in other branches
  1. 8.4 src/FeaturesManager.php \Drupal\features\FeaturesManager::isFeatureModule()

Determines if the module is a Features package, optionally testing by bundle.

Parameters

\Drupal\Core\Extension\Extension $module: An extension object.

\Drupal\features\FeaturesBundleInterface $bundle: (optional) Bundle to filter by.

Return value

bool TRUE if the given module is a Features package of the given bundle (if any).

Overrides FeaturesManagerInterface::isFeatureModule

File

src/FeaturesManager.php, line 410

Class

FeaturesManager
The FeaturesManager provides helper functions for building packages.

Namespace

Drupal\features

Code

public function isFeatureModule(Extension $module, FeaturesBundleInterface $bundle = NULL) {
  if ($features_info = $this
    ->getFeaturesInfo($module)) {

    // If no bundle was requested, it's enough that this is a feature.
    if (is_null($bundle)) {
      return TRUE;
    }
    elseif ($bundle
      ->isDefault()) {
      return !isset($features_info['bundle']);
    }
    else {
      return isset($features_info['bundle']) && $features_info['bundle'] == $bundle
        ->getMachineName();
    }
  }
  return FALSE;
}