function ProjectInfo::getProjectName

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Utility/ProjectInfo.php \Drupal\Core\Utility\ProjectInfo::getProjectName()
  2. 10 core/lib/Drupal/Core/Utility/ProjectInfo.php \Drupal\Core\Utility\ProjectInfo::getProjectName()
  3. 11.x core/lib/Drupal/Core/Utility/ProjectInfo.php \Drupal\Core\Utility\ProjectInfo::getProjectName()

Determines what project a given file object belongs to.

Parameters

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

Return value

string The canonical project short name.

1 call to ProjectInfo::getProjectName()
ProjectInfo::processInfoList in core/lib/Drupal/Core/Utility/ProjectInfo.php
Populates an array of project data.

File

core/lib/Drupal/Core/Utility/ProjectInfo.php, line 151

Class

ProjectInfo
Performs operations on drupal.org project data.

Namespace

Drupal\Core\Utility

Code

public function getProjectName(Extension $file) {
    $project_name = '';
    if (isset($file->info['project'])) {
        $project_name = $file->info['project'];
    }
    elseif (strpos($file->getPath(), 'core/modules') === 0) {
        $project_name = 'drupal';
    }
    return $project_name;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.