DrupalCommands
extends AbstractCommands
in package
Drupal commands to setup and install a Drupal 8 site.
Table of Contents
Properties
- $blockEnd : string
- Comment ending the Toolkit settings block.
- $blockStart : string
- Comment starting the Toolkit settings block.
Methods
- drupalCheckPermissions() : int
- Command to check the forbidden permissions.
- drupalDisableCache() : mixed
- Disable aggregation and clear cache.
- drupalDrushSetup() : mixed
- Write Drush configuration file at "${drupal.root}/drush/drush.yml".
- drupalPermissionsSetup() : mixed
- Setup Drupal permissions.
- drupalSettingsSetup() : CollectionBuilder
- Setup Drupal settings.php file in compliance with Toolkit conventions.
- drupalSiteInstall() : mixed
- Install target site.
- drupalSiteInstallValidate() : mixed
- Validate command drupal:site-install.
- drupalSitePostInstall() : mixed
- Run Drupal post-install commands.
- drupalSitePreInstall() : mixed
- Run Drupal pre-install commands.
- drupalUpgradeStatus() : int
- Check project compatibility for Drupal 9/10 upgrade.
- getConfigurationFile() : mixed
- Path to YAML configuration file containing command defaults.
- getJson() : array<string|int, mixed>
- Returns the JSON parsed content.
- getWorkingDir() : string
- Returns the current working directory.
- isWebsiteInstalled() : bool
- Check if the website is installed.
- getBin() : string
- Validate and return the path to given bin.
- getBinPath() : string
- Return the path to given bin.
- getConfigValue() : mixed
- {@inheritdoc}
- getNodeBin() : string
- Validate and return the path to given bin from node packages.
- getNodeBinPath() : string
- Return the path to given bin from node packages.
- getSettingsBlockRegex() : string
- Remove settings block from given content.
- getToolkitSettingsBlock() : string
- Helper function to update settings.php file.
- isJunit() : bool
- Check whether Junit option is being used, or env var is set.
- isSimulating() : bool
- Check if current command is being executed with option simulate.
- processPrePostInstallCommands() : mixed
- Process pre and post install string-only commands by replacing given tokens.
- taskExecute() : mixed
- Execute a command.
- taskProcess() : mixed
- Process the file.
- taskReplaceBlock() : mixed
- Replace block in a file.
Properties
$blockEnd
Comment ending the Toolkit settings block.
protected
string
$blockEnd
= '// End Toolkit settings block.'
$blockStart
Comment starting the Toolkit settings block.
protected
string
$blockStart
= '// Start Toolkit settings block.'
Methods
drupalCheckPermissions()
Command to check the forbidden permissions.
public
drupalCheckPermissions(ConsoleIO $io[, array<string|int, mixed> $options = ['endpoint' => InputOption::VALUE_REQUIRED, 'blocker' => InputOption::VALUE_NONE] ]) : int
Parameters
- $io : ConsoleIO
- $options : array<string|int, mixed> = ['endpoint' => InputOption::VALUE_REQUIRED, 'blocker' => InputOption::VALUE_NONE]
-
Command options.
Tags
Return values
intdrupalDisableCache()
Disable aggregation and clear cache.
public
drupalDisableCache() : mixed
Tags
drupalDrushSetup()
Write Drush configuration file at "${drupal.root}/drush/drush.yml".
public
drupalDrushSetup([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'config-dir' => InputOption::VALUE_REQUIRED] ]) : mixed
Configuration file contents can be customized by editing "drupal.drush" values in your local runner.yml.dist/runner.yml, as shown below:
drupal: drush: options: ignored-directories: "${drupal.root}" uri: "${drupal.base_url}"
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'config-dir' => InputOption::VALUE_REQUIRED]
-
Command options.
Tags
drupalPermissionsSetup()
Setup Drupal permissions.
public
drupalPermissionsSetup([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED] ]) : mixed
This command will set the necessary permissions on the default folder.
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED]
-
Command options.
Tags
drupalSettingsSetup()
Setup Drupal settings.php file in compliance with Toolkit conventions.
public
drupalSettingsSetup([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, 'force' => false, 'skip-permissions-setup' => false] ]) : CollectionBuilder
This command will:
- Copy "default.settings.php" to "settings.php", which will be overridden if existing
- Add database and config directory settings using environment variables
- Append to "settings.php" an include operation for a "settings.override.php" file
You can specify additional settings.php portions in your local runner.yml.dist/runner.yml as shown below:
drupal: additional_settings: | $config['cas.settings']['server']['hostname'] = getenv('CAS_HOSTNAME'), $config['cas.settings']['server']['port'] = getenv('CAS_PORT');
You can specify additional service parameters in your local runner.yml.dist/runner.yml as shown below:
drupal: service_parameters: session.storage.options: cookie_domain: '.europa.eu'
The settings override file name cannot be changed, changing the "drupal.site.settings_override_file" property will have no effect.
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, 'force' => false, 'skip-permissions-setup' => false]
-
Command options.
Tags
Return values
CollectionBuilder —Collection builder.
drupalSiteInstall()
Install target site.
public
drupalSiteInstall([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED, 'base-url' => InputOption::VALUE_REQUIRED, 'site-name' => InputOption::VALUE_REQUIRED, 'site-mail' => InputOption::VALUE_REQUIRED, 'site-profile' => InputOption::VALUE_REQUIRED, 'site-update' => InputOption::VALUE_REQUIRED, 'site-locale' => InputOption::VALUE_REQUIRED, 'account-name' => InputOption::VALUE_REQUIRED, 'account-password' => InputOption::VALUE_REQUIRED, 'account-mail' => InputOption::VALUE_REQUIRED, 'database-type' => InputOption::VALUE_REQUIRED, 'database-scheme' => InputOption::VALUE_REQUIRED, 'database-user' => InputOption::VALUE_REQUIRED, 'database-password' => InputOption::VALUE_REQUIRED, 'database-host' => InputOption::VALUE_REQUIRED, 'database-port' => InputOption::VALUE_REQUIRED, 'database-name' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, 'config-dir' => InputOption::VALUE_REQUIRED, 'existing-config' => false, 'skip-permissions-setup' => false] ]) : mixed
This command will install a target Drupal site using configuration values provided in local runner.yml.dist/runner.yml files.
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED, 'base-url' => InputOption::VALUE_REQUIRED, 'site-name' => InputOption::VALUE_REQUIRED, 'site-mail' => InputOption::VALUE_REQUIRED, 'site-profile' => InputOption::VALUE_REQUIRED, 'site-update' => InputOption::VALUE_REQUIRED, 'site-locale' => InputOption::VALUE_REQUIRED, 'account-name' => InputOption::VALUE_REQUIRED, 'account-password' => InputOption::VALUE_REQUIRED, 'account-mail' => InputOption::VALUE_REQUIRED, 'database-type' => InputOption::VALUE_REQUIRED, 'database-scheme' => InputOption::VALUE_REQUIRED, 'database-user' => InputOption::VALUE_REQUIRED, 'database-password' => InputOption::VALUE_REQUIRED, 'database-host' => InputOption::VALUE_REQUIRED, 'database-port' => InputOption::VALUE_REQUIRED, 'database-name' => InputOption::VALUE_REQUIRED, 'sites-subdir' => InputOption::VALUE_REQUIRED, 'config-dir' => InputOption::VALUE_REQUIRED, 'existing-config' => false, 'skip-permissions-setup' => false]
-
Command options.
Tags
drupalSiteInstallValidate()
Validate command drupal:site-install.
public
drupalSiteInstallValidate(CommandData $commandData) : mixed
Parameters
- $commandData : CommandData
-
The command data object.
Tags
drupalSitePostInstall()
Run Drupal post-install commands.
public
drupalSitePostInstall([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED] ]) : mixed
Commands have to be listed under the "drupal.post_install" property in your local runner.yml.dist/runner.yml files, as shown below:
drupal: ... post_install: - "./vendor/bin/drush en views -y" - { task: "process", source: "behat.yml.dist", destination: "behat.yml" }
Post-install commands are automatically executed after installing the site when running "drupal:site-install".
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED]
Tags
drupalSitePreInstall()
Run Drupal pre-install commands.
public
drupalSitePreInstall([array<string|int, mixed> $options = ['root' => InputOption::VALUE_REQUIRED] ]) : mixed
Commands have to be listed under the "drupal.pre_install" property in your local runner.yml.dist/runner.yml files, as shown below:
drupal: ... pre_install: - { task: "symlink", from: "../libraries", to: "${drupal.root}/libraries" } - { task: "process", source: "behat.yml.dist", destination: "behat.yml" }
Pre-install commands are automatically executed before installing the site when running "drupal:site-install".
Parameters
- $options : array<string|int, mixed> = ['root' => InputOption::VALUE_REQUIRED]
Tags
drupalUpgradeStatus()
Check project compatibility for Drupal 9/10 upgrade.
public
drupalUpgradeStatus() : int
Tags
Return values
intgetConfigurationFile()
Path to YAML configuration file containing command defaults.
public
getConfigurationFile() : mixed
getJson()
Returns the JSON parsed content.
public
getJson(string $filename[, mixed $throwException = true ]) : array<string|int, mixed>
Parameters
- $filename : string
- $throwException : mixed = true
Return values
array<string|int, mixed>getWorkingDir()
Returns the current working directory.
public
getWorkingDir() : string
Return values
string —The current working directory.
isWebsiteInstalled()
Check if the website is installed.
public
isWebsiteInstalled() : bool
Return values
boolgetBin()
Validate and return the path to given bin.
protected
getBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getBinPath()
Return the path to given bin.
protected
getBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
getConfigValue()
{@inheritdoc}
protected
getConfigValue(mixed $key[, mixed $default = null ]) : mixed
Parameters
- $key : mixed
- $default : mixed = null
getNodeBin()
Validate and return the path to given bin from node packages.
protected
getNodeBin(string $name) : string
Parameters
- $name : string
-
The bin to look for.
Tags
Return values
string —The bin path.
getNodeBinPath()
Return the path to given bin from node packages.
protected
getNodeBinPath(string $name) : string
Parameters
- $name : string
Return values
string —The path to given binary.
getSettingsBlockRegex()
Remove settings block from given content.
protected
getSettingsBlockRegex() : string
Return values
string —Content without setting block.
getToolkitSettingsBlock()
Helper function to update settings.php file.
protected
getToolkitSettingsBlock() : string
Return values
string —Database configuration to be attached to Drupal settings.php.
isJunit()
Check whether Junit option is being used, or env var is set.
protected
isJunit() : bool
Return values
boolisSimulating()
Check if current command is being executed with option simulate.
protected
isSimulating() : bool
Return values
bool —True if using --simulate, false otherwise.
processPrePostInstallCommands()
Process pre and post install string-only commands by replacing given tokens.
protected
processPrePostInstallCommands(array<string|int, mixed> &$commands, array<string|int, mixed> $tokens) : mixed
Parameters
- $commands : array<string|int, mixed>
-
List of commands.
- $tokens : array<string|int, mixed>
-
Replacement key-value tokens.
taskExecute()
Execute a command.
protected
taskExecute(array<string|int, mixed> $tasks) : mixed
Parameters
- $tasks : array<string|int, mixed>
-
An array with tasks to execute.
taskProcess()
Process the file.
protected
taskProcess(string $source[, string $destination = '' ]) : mixed
Parameters
- $source : string
-
The source file to process.
- $destination : string = ''
-
The destination file.
taskReplaceBlock()
Replace block in a file.
protected
taskReplaceBlock([string $filename = '' ]) : mixed
Parameters
- $filename : string = ''
-
The file to process.