You are here

public function FeaturesAssigner::findBundleByName in Features 8.3

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

Returns a named bundle.

First searches by Human name, then by machine_name.

Parameters

string $name: The bundle name to search by.

Return value

\Drupal\features\FeaturesBundleInterface A features bundle object.

Overrides FeaturesAssignerInterface::findBundleByName

1 call to FeaturesAssigner::findBundleByName()
FeaturesAssigner::findBundle in src/FeaturesAssigner.php
Searches for a bundle that matches the $info.yml or $features.yml export.

File

src/FeaturesAssigner.php, line 285

Class

FeaturesAssigner
Class responsible for performing package assignment.

Namespace

Drupal\features

Code

public function findBundleByName($name, $create = FALSE) {
  $bundles = $this
    ->getBundleList();
  foreach ($bundles as $machine_name => $bundle) {
    if ($name == $bundle
      ->getName()) {
      return $bundle;
    }
  }
  $machine_name = strtolower(str_replace([
    ' ',
    '-',
  ], '_', $name));
  if (isset($bundles[$machine_name])) {
    return $bundles[$machine_name];
  }
  return NULL;
}