class Handler (View source)

internal  
 

Core class of the plugin.

Contains the primary logic which determines the files to be fetched and processed.

Constants

PRE_DRUPAL_SCAFFOLD_CMD

Composer hook called before scaffolding begins.

POST_DRUPAL_SCAFFOLD_CMD

Composer hook called after scaffolding completes.

Properties

protected Composer $composer

The Composer service.

protected IOInterface $io

Composer's I/O service.

protected ManageOptions $manageOptions

The scaffold options in the top-level composer.json's 'extra' section.

protected AllowedPackages $manageAllowedPackages

The manager that keeps track of which packages are allowed to scaffold.

protected PostPackageEventListenerInterface[] $postPackageListeners

The list of listeners that are notified after a package event.

Methods

__construct(Composer $composer, IOInterface $io)

Handler constructor.

requireWasCalled()

Registers post-package events if the 'require' command was called.

onPostPackageEvent(PackageEvent $event)

Posts package command event.

createScaffoldOperations(PackageInterface $package, array $package_file_mappings)

Creates scaffold operation objects for all items in the file mappings.

scaffold()

Copies all scaffold files from source to destination.

string
getVendorPath()

Gets the path to the 'vendor' directory.

OperationInterface[][]
getFileMappingsFromPackages(array $allowed_packages)

Gets a consolidated list of file mappings from all allowed packages.

getPackageFileMappings(PackageInterface $package)

Gets the array of file mappings provided by a given package.

string
rootPackageName()

Gets the root package name.

Details

__construct(Composer $composer, IOInterface $io)

Handler constructor.

Parameters

Composer $composer

The Composer service.

IOInterface $io

The Composer I/O service.

requireWasCalled()

Registers post-package events if the 'require' command was called.

onPostPackageEvent(PackageEvent $event)

Posts package command event.

We want to detect packages 'require'd that have scaffold files, but are not yet allowed in the top-level composer.json file.

Parameters

PackageEvent $event

Composer package event sent on install/update/remove.

protected OperationInterface[] createScaffoldOperations(PackageInterface $package, array $package_file_mappings)

Creates scaffold operation objects for all items in the file mappings.

Parameters

PackageInterface $package

The package that relative paths will be relative from.

array $package_file_mappings

The package file mappings array keyed by destination path and the values are operation metadata arrays.

Return Value

OperationInterface[]

A list of scaffolding operation objects

scaffold()

Copies all scaffold files from source to destination.

protected string getVendorPath()

Gets the path to the 'vendor' directory.

Return Value

string

The file path of the vendor directory.

protected OperationInterface[][] getFileMappingsFromPackages(array $allowed_packages)

Gets a consolidated list of file mappings from all allowed packages.

Parameters

array $allowed_packages

A multidimensional array of file mappings, as returned by self::getAllowedPackages().

Return Value

OperationInterface[][]

An array of destination paths => scaffold operation objects.

protected OperationInterface[] getPackageFileMappings(PackageInterface $package)

Gets the array of file mappings provided by a given package.

Parameters

PackageInterface $package

The Composer package from which to get the file mappings.

Return Value

OperationInterface[]

An array of destination paths => scaffold operation objects.

protected string rootPackageName()

Gets the root package name.

Return Value

string

The package name of the root project