You are here

public function ProjectCollector::loadProject in Upgrade Status 8.2

Same name and namespace in other branches
  1. 8.3 src/ProjectCollector.php \Drupal\upgrade_status\ProjectCollector::loadProject()
  2. 8 src/ProjectCollector.php \Drupal\upgrade_status\ProjectCollector::loadProject()

Returns a single extension based on type and machine name.

Parameters

string $type: One of 'module' or 'theme' or 'profile' to signify the type of the extension.

string $project_machine_name: Machine name for the extension.

Return value

\Drupal\Core\Extension\Extension A project if exists.

Throws

\InvalidArgumentException If the type was not one of the allowed ones.

\Drupal\Core\Extension\Exception\UnknownExtensionException If there was no extension with the given name.

File

src/ProjectCollector.php, line 203

Class

ProjectCollector
Collects projects collated for the purposes of upgrade status.

Namespace

Drupal\upgrade_status

Code

public function loadProject(string $type, string $project_machine_name) {
  if (!in_array($type, $this->allowedTypes)) {
    throw new InvalidArgumentException(sprintf('"%s" is not a valid type. Valid types are module, profile and theme.', $type));
  }
  if ($type === 'module') {
    return $this->moduleExtensionList
      ->get($project_machine_name);
  }
  if ($type === 'profile') {
    return $this->profileExtensionList
      ->get($project_machine_name);
  }
  return $this->themeExtensionList
    ->get($project_machine_name);
}