Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DrupalFinderComposerRuntime.php

class DrupalFinderComposerRuntime

Hierarchy

  • class \DrupalFinder\DrupalFinderComposerRuntime

Expanded class hierarchy of DrupalFinderComposerRuntime

1 file declares its use of DrupalFinderComposerRuntime
DrupalAutoloader.php in vendor/mglaman/phpstan-drupal/src/Drupal/DrupalAutoloader.php

File

vendor/webflo/drupal-finder/src/DrupalFinderComposerRuntime.php, line 13

Namespace

DrupalFinder
View source
class DrupalFinderComposerRuntime {
    
    /**
     * Get the Drupal root path.
     */
    public function getDrupalRoot() : ?string {
        $core = InstalledVersions::getInstallPath('drupal/core');
        return $core ? realpath(dirname($core)) : null;
    }
    
    /**
     * Get the path to the Composer root directory.
     */
    public function getComposerRoot() : ?string {
        foreach (InstalledVersions::getAllRawData() as $data) {
            if (isset($data['versions']['drupal/core'])) {
                return realpath($data['root']['install_path']);
            }
        }
        $root = InstalledVersions::getRootPackage();
        return realpath($root['install_path']);
    }
    
    /**
     * Get the vendor path.
     */
    public function getVendorDir() : ?string {
        foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
            if ($loader->findFile(\Drupal::class)) {
                return realpath($vendorDir);
            }
        }
    }

}

Members

Title Sort descending Modifiers Object type Summary
DrupalFinderComposerRuntime::getComposerRoot public function Get the path to the Composer root directory.
DrupalFinderComposerRuntime::getDrupalRoot public function Get the Drupal root path.
DrupalFinderComposerRuntime::getVendorDir public function Get the vendor path.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal