You are here

class CommandHelper in Varbase Core 8.8

Same name and namespace in other branches
  1. 8.6 src/Utility/CommandHelper.php \Drupal\varbase_core\Utility\CommandHelper
  2. 8.7 src/Utility/CommandHelper.php \Drupal\varbase_core\Utility\CommandHelper
  3. 9.0.x src/Utility/CommandHelper.php \Drupal\varbase_core\Utility\CommandHelper

Command Helper.

Hierarchy

  • class \Drupal\varbase_core\Utility\CommandHelper implements \Psr\Log\LoggerAwareInterface uses \Psr\Log\LoggerAwareTrait

Expanded class hierarchy of CommandHelper

2 files declare their use of CommandHelper
VarbaseUpdateHelperCommands.php in modules/varbase_update_helper/src/Commands/VarbaseUpdateHelperCommands.php
varbase_update_helper.drush.inc in modules/varbase_update_helper/varbase_update_helper.drush.inc
Contains drush command for Varbase update helpers.

File

src/Utility/CommandHelper.php, line 11

Namespace

Drupal\varbase_core\Utility
View source
class CommandHelper implements LoggerAwareInterface {
  use LoggerAwareTrait;

  /**
   * Constructs an Command Helper object.
   */
  public function __construct() {
  }

  /**
   * Applying an (optional) update hook (function) from module install file.
   *
   * @param string $module
   *   Drupal module name.
   * @param string $update_hook
   *   Name of update_hook to apply.
   * @param bool $force
   *   Force the update.
   */
  public function varbaseApplyUpdate($module = '', $update_hook = '', $force = FALSE) {
    if (!$update_hook || !$module) {
      $this->logger
        ->info(dt('Please provide a module name and an update hook. Example: drush varbase-up <module> <update_hook>'));
      return;
    }
    module_load_install($module);
    if (function_exists($update_hook)) {
      call_user_func($update_hook, $force);
    }
    else {
      $this->logger
        ->error(dt("Couldn't find an update hook: !update_hook. Please verify the update hook name.", [
        "!update_hook" => $update_hook,
      ]));
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommandHelper::varbaseApplyUpdate public function Applying an (optional) update hook (function) from module install file.
CommandHelper::__construct public function Constructs an Command Helper object.