final class GenerateAutoloadReferenceFile (View source)

internal  
 

Generates an 'autoload.php' that includes the autoloader created by Composer.

Methods

static ScaffoldResult
generateAutoload(IOInterface $io, string $package_name, string $web_root, string $vendor)

Generates the autoload file at the specified location.

static bool
autoloadFileCommitted(IOInterface $io, string $package_name, string $web_root)

Determines whether or not the autoload file has been committed.

autoloadPath(string $package_name, string $web_root)

Generates a scaffold file path object for the autoload file.

static string
autoLoadContents(string $relative_autoload_path)

Builds the contents of the autoload file.

Details

static ScaffoldResult generateAutoload(IOInterface $io, string $package_name, string $web_root, string $vendor)

Generates the autoload file at the specified location.

This only writes a bit of PHP that includes the autoload file that Composer generated. Drupal does this so that it can guarantee that there will always be an autoload.php file in a well-known location.

Parameters

IOInterface $io

IOInterface to write to.

string $package_name

The name of the package defining the autoload file (the root package).

string $web_root

The path to the web root.

string $vendor

The path to the vendor directory.

Return Value

ScaffoldResult

The result of the autoload file generation.

static bool autoloadFileCommitted(IOInterface $io, string $package_name, string $web_root)

Determines whether or not the autoload file has been committed.

Parameters

IOInterface $io

IOInterface to write to.

string $package_name

The name of the package defining the autoload file (the root package).

string $web_root

The path to the web root.

Return Value

bool

True if autoload.php file exists and has been committed to the repository

static protected ScaffoldFilePath autoloadPath(string $package_name, string $web_root)

Generates a scaffold file path object for the autoload file.

Parameters

string $package_name

The name of the package defining the autoload file (the root package).

string $web_root

The path to the web root.

Return Value

ScaffoldFilePath

Object wrapping the relative and absolute path to the destination file.

static protected string autoLoadContents(string $relative_autoload_path)

Builds the contents of the autoload file.

Parameters

string $relative_autoload_path

The relative path to the autoloader in vendor.

Return Value

string

Return the contents for the autoload.php.