function MockPathLocator::setPaths

Sets the paths to return.

Parameters

string|null $project_root: The project root, or NULL to defer to the parent class.

string|null $vendor_dir: The vendor directory, or NULL to defer to the parent class.

string|null $web_root: The web root, relative to the project root, or NULL to defer to the parent class.

string|null $staging_root: The absolute path of the stage root directory, or NULL to defer to the parent class.

File

core/modules/package_manager/tests/modules/package_manager_bypass/src/MockPathLocator.php, line 85

Class

MockPathLocator
Mock path locator: allows specifying paths instead of discovering paths.

Namespace

Drupal\package_manager_bypass

Code

public function setPaths(?string $project_root, ?string $vendor_dir, ?string $web_root, ?string $staging_root) : void {
    foreach ([
        $project_root,
        $staging_root,
    ] as $path) {
        if (!empty($path) && !Path::isAbsolute($path)) {
            throw new \InvalidArgumentException('project_root and staging_root need to be absolute paths.');
        }
    }
    $this->state
        ->set(static::class . ' root', is_null($project_root) ? NULL : realpath($project_root));
    $this->state
        ->set(static::class . ' vendor', is_null($vendor_dir) ? NULL : realpath($vendor_dir));
    $this->state
        ->set(static::class . ' web', is_null($web_root) ? NULL : Path::canonicalize($web_root));
    $this->state
        ->set(static::class . ' stage', is_null($staging_root) ? NULL : realpath($staging_root));
}

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