You are here

public function ProjectCollector::loadProject in Upgrade Status 8

Same name and namespace in other branches
  1. 8.3 src/ProjectCollector.php \Drupal\upgrade_status\ProjectCollector::loadProject()
  2. 8.2 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.

Overrides ProjectCollectorInterface::loadProject

File

src/ProjectCollector.php, line 158

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($this
      ->t('Type must be either module or theme.'));
  }
  if ($type === 'module') {
    return $this->moduleExtensionList
      ->get($project_machine_name);
  }
  if ($type === 'profile') {
    return $this->profileExtensionList
      ->get($project_machine_name);
  }
  return $this->themeHandler
    ->getTheme($project_machine_name);
}