You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Have this robo task plugin for drush be aware of the Drupal version by inspecting it and storing it. Then for certain tasks that differ depending on the version, do a SEMVER check like:
<?php/** * Enables the maintenance mode. * * @return $this */publicfunctionmaintenanceOn()
{
$this->printTaskInfo('Turn maintenance mode on');
// Implement a version lookup method.$version = $this->getDrupalCoreVersion();
if (\Composer\Semver\Semver::satisfies($version, '<8.0')) {
return$this->drush('variable-set --exact maintenance_mode 1');
}
if (\Composer\Semver\Semver::satisfies($version, '>=8.0')) {
return$this->drush('state-set --exact maintenance_mode 1');
}
}
The text was updated successfully, but these errors were encountered:
A simple but efficient way would be to simple use \Drupal::VERSION or \Drupal::CORE_COMPATIBILITY. Inside a Try catch block and defaults to drupal-7, since in Drupal 7 this Class does not exist... Put into the __construct and you are good to go.
Only question is, are you willing to go down that road, since there is actually no explicit dependency to Drupal in Drush, Robo nor this Task.
Problem / Motivation
Some common Drupal / Drush tasks have different implementations when moving to a new Major Drupal version. The best example I can give is this:
Suggested Solutions
Have this robo task plugin for drush be aware of the Drupal version by inspecting it and storing it. Then for certain tasks that differ depending on the version, do a SEMVER check like:
The text was updated successfully, but these errors were encountered: