当前位置: 首页>>代码示例>>PHP>>正文


PHP drush_get_context函数代码示例

本文整理汇总了PHP中drush_get_context函数的典型用法代码示例。如果您正苦于以下问题:PHP drush_get_context函数的具体用法?PHP drush_get_context怎么用?PHP drush_get_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drush_get_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ascii

 public function ascii($string, $color = NULL, $style = NULL, $background = NULL)
 {
     if (drush_get_context('DRUSH_NOCOLOR')) {
         return $string;
     }
     return $this->color->color($color, $style, $background) . $string . $this->color->color('reset');
 }
开发者ID:markcarver,项目名称:drush-lwg,代码行数:7,代码来源:CommandBase.php

示例2: druplicon

 /**
  * Print druplicon as post-command output.
  *
  * @hook post-command *
  * @option druplicon Shows the druplicon as glorious ASCII art.
  * @todo hidden is not yet part of annotated-command project. It is recognized by Drush's annotation_adapter.inc
  * @hidden-option druplicon
  */
 public function druplicon($result, CommandData $commandData)
 {
     // If one command does a drush_invoke to another command,
     // then this hook will be called multiple times. Only print
     // once.  (n.b. If drush_invoke_process passes along the
     // --druplicon option, then we will still get mulitple output)
     if ($this->printed) {
         return;
     }
     $this->printed = true;
     $annotationData = $commandData->annotationData();
     $commandName = $annotationData['command'];
     // For some reason, Drush help uses drush_invoke_process to call helpsingle
     if ($commandName == 'helpsingle') {
         return;
     }
     if ($commandData->input()->getOption('druplicon')) {
         $this->logger()->debug(dt('Displaying Druplicon for "!command" command.', array('!command' => $commandName)));
         $misc_dir = DRUSH_BASE_PATH . '/misc';
         if (drush_get_context('DRUSH_NOCOLOR')) {
             $content = file_get_contents($misc_dir . '/druplicon-no_color.txt');
         } else {
             $content = file_get_contents($misc_dir . '/druplicon-color.txt');
         }
         // @todo: `$commandData->output->writeln($content)` after $output hooked up to backend invoke
         drush_print($content);
     }
 }
开发者ID:jibran,项目名称:drush,代码行数:36,代码来源:DrupliconCommands.php

示例3: calculateScore

 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore() {
   $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
   $handle = opendir($drupal_root . '/sites/');
   $this->registry['multisites'] = array();
   while (FALSE !== ($entry = readdir($handle))) {
     if (!in_array($entry, array(
       '.',
       '..',
       'default',
       'all',
       'example.sites.php',
       'README.txt',
       '.svn',
     ))) {
       if (is_dir($drupal_root . '/sites/' . $entry)) {
         $this->registry['multisites'][] = $entry;
       }
     }
   }
   closedir($handle);
   if (!empty($this->registry['multisites'])) {
     if (drush_get_option('vendor') == 'pantheon') {
       return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
     }
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
   }
   return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
 }
开发者ID:karlkedrovsky,项目名称:config,代码行数:31,代码来源:Multisite.php

示例4: bootstrap_and_dispatch

 function bootstrap_and_dispatch()
 {
     $phases = _drush_bootstrap_phases(FALSE, TRUE);
     $return = '';
     $command_found = FALSE;
     _drush_bootstrap_output_prepare();
     foreach ($phases as $phase) {
         if (drush_bootstrap_to_phase($phase)) {
             $command = drush_parse_command();
             if (is_array($command)) {
                 $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                 drush_enforce_requirement_bootstrap_phase($command);
                 drush_enforce_requirement_core($command);
                 drush_enforce_requirement_drupal_dependencies($command);
                 drush_enforce_requirement_drush_dependencies($command);
                 if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                     drush_log(dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])), 'bootstrap');
                     $command_found = TRUE;
                     // Dispatch the command(s).
                     $return = drush_dispatch($command);
                     // Prevent a '1' at the end of the output.
                     if ($return === TRUE) {
                         $return = '';
                     }
                     if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
                         // @todo Create version independant wrapper around Drupal timers. Use it.
                         drush_print_timers();
                     }
                     break;
                 }
             }
         } else {
             break;
         }
     }
     if (!$command_found) {
         // If we reach this point, command doesn't fit requirements or we have not
         // found either a valid or matching command.
         // If no command was found check if it belongs to a disabled module.
         if (!$command) {
             $command = drush_command_belongs_to_disabled_module();
         }
         // Set errors related to this command.
         $args = implode(' ', drush_get_arguments());
         if (isset($command) && is_array($command)) {
             foreach ($command['bootstrap_errors'] as $key => $error) {
                 drush_set_error($key, $error);
             }
             drush_set_error('DRUSH_COMMAND_NOT_EXECUTABLE', dt("The drush command '!args' could not be executed.", array('!args' => $args)));
         } elseif (!empty($args)) {
             drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt("The drush command '!args' could not be found.  Run `drush cache-clear drush` to clear the commandfile cache if you have installed new extensions.", array('!args' => $args)));
         }
         // Set errors that occurred in the bootstrap phases.
         $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
         foreach ($errors as $code => $message) {
             drush_set_error($code, $message);
         }
     }
     return $return;
 }
开发者ID:catch56,项目名称:drush,代码行数:60,代码来源:DrupalBoot.php

示例5: calculateScore

 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore() {
   $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
   $handle = opendir($drupal_root . '/sites/');
   $this->registry['superfluous'] = array();
   while (FALSE !== ($entry = readdir($handle))) {
     if (!in_array($entry, array(
       '.',
       '..',
       'default',
       'all',
       'example.sites.php',
       'README.txt',
     ))) {
       if (is_file($drupal_root . '/sites/' . $entry)) {
         // Support multi-site directory aliasing for non-Pantheon sites.
         if ($entry != 'sites.php' || drush_get_option('vendor') == 'pantheon') {
           $this->registry['superfluous'][] = $entry;
         }
       }
     }
   }
   closedir($handle);
   if (!empty($this->registry['superfluous'])) {
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
   }
   return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
 }
开发者ID:karlkedrovsky,项目名称:config,代码行数:30,代码来源:SitesSuperfluous.php

示例6: bootstrap_and_dispatch

 function bootstrap_and_dispatch()
 {
     $phases = $this->bootstrap_init_phases();
     $return = '';
     $command_found = FALSE;
     _drush_bootstrap_output_prepare();
     foreach ($phases as $phase) {
         if (drush_bootstrap_to_phase($phase)) {
             $command = drush_parse_command();
             if (is_array($command)) {
                 $command += $this->command_defaults();
                 // Insure that we have bootstrapped to a high enough
                 // phase for the command prior to enforcing requirements.
                 $bootstrap_result = drush_bootstrap_to_phase($command['bootstrap']);
                 $this->enforce_requirement($command);
                 if ($bootstrap_result && empty($command['bootstrap_errors'])) {
                     $this->logger->log(LogLevel::BOOTSTRAP, dt("Found command: !command (commandfile=!commandfile)", array('!command' => $command['command'], '!commandfile' => $command['commandfile'])));
                     $command_found = TRUE;
                     // Dispatch the command(s).
                     $return = drush_dispatch($command);
                     if (drush_get_context('DRUSH_DEBUG') && !drush_get_context('DRUSH_QUIET')) {
                         // @todo Create version independant wrapper around Drupal timers. Use it.
                         drush_print_timers();
                     }
                     break;
                 }
             }
         } else {
             break;
         }
     }
     // TODO: If we could not find a legacy Drush command, try running a
     // command via the Symfony application. See also drush_main() in preflight.inc;
     // ultimately, the Symfony application should be called from there.
     if (!$command_found && isset($command)) {
         $container = \Drush::getContainer();
         $application = $container->get('application');
         $args = drush_get_arguments();
         if (count($args)) {
             $name = $args[0];
             if ($this->hasRegisteredSymfonyCommand($application, $name)) {
                 $command_found = true;
                 $input = drush_symfony_input();
                 $this->logger->log(LogLevel::BOOTSTRAP, dt("Dispatching with Symfony application as a fallback, since no native Drush command was found. (Set DRUSH_SYMFONY environment variable to skip Drush dispatch.)"));
                 $application->run($input);
             }
         }
     }
     if (!$command_found) {
         // If we reach this point, command doesn't fit requirements or we have not
         // found either a valid or matching command.
         $this->report_command_error($command);
     }
     // Prevent a '1' at the end of the output.
     if ($return === TRUE) {
         $return = '';
     }
     return $return;
 }
开发者ID:jibran,项目名称:drush,代码行数:59,代码来源:BaseBoot.php

示例7: setUp

 function setUp()
 {
     // Bootstrap to ensure the Console_Table library is present and included.
     drush_bootstrap(DRUSH_BOOTSTRAP_DRUSH);
     $this->original_columns = drush_get_context('DRUSH_COLUMNS');
     // Some table data we reuse between tests.
     $this->numbers = array(array('1', '12', '123'), array('1234', '12345', '123456'), array('1234567', '12345678', '123456789'));
     $this->words = array(array('Drush is a command line shell', 'scripting interface', 'for Drupal'), array('A veritable', 'Swiss Army knife', 'designed to make life easier for us'));
 }
开发者ID:harryboulderdash,项目名称:PlayGFC,代码行数:9,代码来源:tablesUnitTest.php

示例8: listTables

 public function listTables()
 {
     $current = drush_get_context('DRUSH_SIMULATE');
     drush_set_context('DRUSH_SIMULATE', FALSE);
     $return = $this->query('SHOW TABLES;');
     $tables = drush_shell_exec_output();
     drush_set_context('DRUSH_SIMULATE', $current);
     return $tables;
 }
开发者ID:komlenic,项目名称:drush,代码行数:9,代码来源:Sqlmysql.php

示例9: setUp

 function setUp()
 {
     // Bootstrap to ensure the auto-loaded is running so that Console_Table is found.
     drush_preflight();
     $this->original_columns = drush_get_context('DRUSH_COLUMNS');
     // Some table data we reuse between tests.
     $this->numbers = array(array('1', '12', '123'), array('1234', '12345', '123456'), array('1234567', '12345678', '123456789'));
     $this->words = array(array('Drush is a command line shell', 'scripting interface', 'for Drupal'), array('A veritable', 'Swiss Army knife', 'designed to make life easier for us'));
 }
开发者ID:bjargud,项目名称:drush,代码行数:9,代码来源:tablesUnitTest.php

示例10: setup

 /**
  * Setup before each test.
  */
 public function setup()
 {
     $this->log = array();
     // Set ourselves as the log receiver.
     deployotron_log_proxy($this);
     // Save previous value.
     $this->prevLog = drush_get_context('DRUSH_LOG_CALLBACK', NULL);
     // Hook into drush_log.
     drush_set_context('DRUSH_LOG_CALLBACK', 'deployotron_log_proxy');
 }
开发者ID:reload,项目名称:dockhub-testing,代码行数:13,代码来源:deployotronActionTest.php

示例11: drushMain

 /**
  * Calls a Drush command.
  *
  * This is an exact copy of drush_main from drush.php, but that file
  * cannot be loaded because it produces side effects.
  *
  * @see drush_main
  *
  * @return int|string
  */
 protected static function drushMain()
 {
     $return = '';
     // Start code coverage collection.
     if ($coverage_file = drush_get_option('drush-coverage', false)) {
         drush_set_context('DRUSH_CODE_COVERAGE', $coverage_file);
         xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE);
         register_shutdown_function('drush_coverage_shutdown');
     }
     /* Set up bootstrap object, so that
      * - 'early' files can bootstrap when needed.
      * - bootstrap constants are available.
      */
     $bootstrap_class = drush_get_option('bootstrap_class', 'Drush\\Boot\\DrupalBoot');
     $bootstrap = new $bootstrap_class();
     drush_set_context('DRUSH_BOOTSTRAP_OBJECT', $bootstrap);
     $bootstrap->preflight();
     // Process initial global options such as --debug.
     _drush_preflight_global_options();
     $return = '';
     drush_preflight();
     if (!drush_get_error()) {
         if ($file = drush_get_option('early', false)) {
             require_once $file;
             $function = 'drush_early_' . basename($file, '.inc');
             if (function_exists($function)) {
                 if ($return = $function()) {
                     // If the function returns FALSE, we continue and attempt to bootstrap
                     // as normal. Otherwise, we exit early with the returned output.
                     if ($return === TRUE) {
                         $return = '';
                     }
                 }
             }
         } else {
             // Do any necessary preprocessing operations on the command,
             // perhaps handling immediately.
             $command_handled = drush_preflight_command_dispatch();
             if (!$command_handled) {
                 $bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT');
                 $return = $bootstrap->bootstrap_and_dispatch();
             }
         }
     }
     drush_postflight();
     // How strict are we?  If we are very strict, turn 'ok' into 'error'
     // if there are any warnings in the log.
     if ($return == 0 && drush_get_option('strict') > 1 && drush_log_has_errors()) {
         $return = 1;
     }
     // After this point the drush_shutdown function will run,
     // exiting with the correct exit code.
     return $return;
 }
开发者ID:bangpound,项目名称:drupal-bridge,代码行数:64,代码来源:ScriptHandler.php

示例12: calculateScore

 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore()
 {
     $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
     exec('du -s -k -x ' . $drupal_root, $result);
     $this->registry['size_all_kb'] = trim($result[0]);
     if (!$this->registry['size_all_kb']) {
         $this->abort = TRUE;
         return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
     }
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
 }
开发者ID:OPIN-CA,项目名称:checkpoint,代码行数:14,代码来源:SizeAll.php

示例13: calculateScore

 /**
  * Implements \SiteAudit\Check\Abstract\calculateScore().
  */
 public function calculateScore()
 {
     $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');
     if (is_dir($drupal_root . '/sites/all')) {
         if (is_link($drupal_root . '/sites/all')) {
             return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_WARN;
         }
         return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
     }
     return SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL;
 }
开发者ID:OPIN-CA,项目名称:checkpoint,代码行数:14,代码来源:SitesAll.php

示例14: bootstrap_drupal_full

 function bootstrap_drupal_full()
 {
     if (!drush_get_context('DRUSH_QUIET', FALSE)) {
         ob_start();
     }
     drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
     if (!drush_get_context('DRUSH_QUIET', FALSE)) {
         ob_end_clean();
     }
     parent::bootstrap_drupal_full();
 }
开发者ID:bjargud,项目名称:drush,代码行数:11,代码来源:DrupalBoot7.php

示例15: bootstrap_drupal_full

 function bootstrap_drupal_full()
 {
     if (!drush_get_context('DRUSH_QUIET', FALSE)) {
         ob_start();
     }
     $this->kernel->boot();
     $this->kernel->prepareLegacyRequest($this->request);
     if (!drush_get_context('DRUSH_QUIET', FALSE)) {
         ob_end_clean();
     }
     parent::bootstrap_drupal_full();
 }
开发者ID:nuwud,项目名称:drush,代码行数:12,代码来源:DrupalBoot8.php


注:本文中的drush_get_context函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。