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


PHP drush_set_error函数代码示例

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


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

示例1: execCommands

 /**
  * Invoke the desired commands.
  *
  * @param array $commands
  *   The commands to invoke.
  *
  * @return bool
  *   FALSE if a command fails.
  */
 private function execCommands(array $commands)
 {
     // Pass the drushrc file through to drush_invoke_process.
     $default_options = [];
     if ($config = drush_get_option('config-file')) {
         $default_options['config'] = $config;
     }
     foreach ($commands as $command => &$info) {
         $info = (array) $info;
         // Set some default values for each command.
         $info += ['alias' => '@self', 'arguments' => [], 'options' => []];
         $info['options'] += $default_options;
         // Tell the user we are invoking the command.
         drush_print($this->formatHeading("✗") . ' ' . $this->formatCommand($command, $info));
         // Invoke the command.
         if (!drush_invoke_process($info['alias'], $command, $info['arguments'], $info['options'])) {
             return drush_set_error('COMMAND_FAILED', dt("Failed to execute drush command @command.", ['@command' => $command]));
         }
         drush_print();
     }
 }
开发者ID:keyboardcowboy,项目名称:drush-denver,代码行数:30,代码来源:Denver.class.php

示例2: run

 /**
  * {@inheritdoc}
  */
 public function run($name, $time_limit = 0)
 {
     $worker = $this->workerManager->createInstance($name);
     $end = time() + $time_limit;
     $queue = $this->getQueue($name);
     $count = 0;
     while ((!$time_limit || time() < $end) && ($item = $queue->claimItem())) {
         try {
             drush_log(dt('Processing item @id from @name queue.', array('@name' => $name, 'id' => $item->item_id)), 'info');
             $worker->processItem($item->data);
             $queue->deleteItem($item);
             $count++;
         } catch (SuspendQueueException $e) {
             // If the worker indicates there is a problem with the whole queue,
             // release the item and skip to the next queue.
             $queue->releaseItem($item);
             drush_set_error('DRUSH_SUSPEND_QUEUE_EXCEPTION', $e->getMessage());
         } catch (\Exception $e) {
             // In case of any other kind of exception, log it and leave the item
             // in the queue to be processed again later.
             drush_set_error('DRUSH_QUEUE_EXCEPTION', $e->getMessage());
         }
     }
     return $count;
 }
开发者ID:nrackleff,项目名称:capstone,代码行数:28,代码来源:Queue8.php

示例3: __construct

 /**
  * Constructor; loads and executes checks based on the name of this report.
  */
 public function __construct()
 {
     global $conf;
     $base_class_name = 'SiteAuditCheck' . $this->getReportName();
     $percent_override = NULL;
     $checks_to_skip = array();
     if (drush_get_option('skip')) {
         $checks_to_skip = explode(',', drush_get_option('skip'));
     }
     $checks_to_perform = $this->getCheckNames();
     foreach ($checks_to_perform as $key => $check_name) {
         if (in_array($this->getReportName() . $check_name, $checks_to_skip)) {
             unset($checks_to_perform[$key]);
         }
     }
     if (empty($checks_to_perform)) {
         // No message for audit_all.
         $command = drush_parse_command();
         if ($command['command'] == 'audit_all') {
             return FALSE;
         }
         return drush_set_error('SITE_AUDIT_NO_CHECKS', dt('No checks are available!'));
     }
     foreach ($checks_to_perform as $check_name) {
         $class_name = $base_class_name . $check_name;
         $check = new $class_name($this->registry, isset($conf['site_audit']['opt_out'][$this->getReportName() . $check_name]));
         // Calculate score.
         if ($check->getScore() != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO) {
             // Mark if there's a major failure.
             if ($check->getScore() == SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_FAIL) {
                 $this->hasFail = TRUE;
             }
             // Total.
             $this->scoreTotal += $check->getScore();
             // Maximum.
             $this->scoreMax += SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS;
         }
         // Allow Report percentage to be overridden.
         if ($check->getPercentOverride()) {
             $percent_override = $check->getPercentOverride();
         }
         // Combine registry.
         $this->registry = array_merge($this->registry, $check->getRegistry());
         // Store all checks.
         $this->checks[$class_name] = $check;
         // Abort the loop if the check says to bail.
         if ($check->shouldAbort()) {
             break;
         }
     }
     if ($percent_override) {
         $this->percent = $percent_override;
     } else {
         if ($this->scoreMax != 0) {
             $this->percent = round($this->scoreTotal / $this->scoreMax * 100);
         } else {
             $this->percent = SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_INFO;
         }
     }
 }
开发者ID:OPIN-CA,项目名称:checkpoint,代码行数:63,代码来源:Abstract.php

示例4: __construct

 /**
  * Class constructor.
  *
  * @param CommandBase $command
  *   The current instance of the command.
  */
 public function __construct(CommandBase $command)
 {
     $this->command = $command;
     // Determine if the "path" option has been set.
     $this->path = drush_get_option('path');
     if ($this->path && !file_exists($this->path)) {
         return drush_set_error('DRUSH_LWG_INVALID_PATH', dt("The specified project path does not exist:\n!path", array('!path' => $this->path)));
     } else {
         if (!$this->path) {
             $this->path = drush_cwd();
         }
     }
     // Ensure the path is writable.
     if (!is_writable($this->path)) {
         return drush_set_error('DRUSH_LWG_PATH_NOT_WRITABLE', dt("The specified project path is not writable:\n!path", array('!path' => $this->path)));
     }
     foreach (drush_scan_directory($this->path, '/\\.info(\\.yml)?/') as $file) {
         if ($this->info = drush_drupal_parse_info_file($file->filename)) {
             $this->name = $file->name;
             break;
         }
     }
     if (!$this->getInfo('name')) {
         return drush_set_error('DRUSH_LWG_NOT_PROJECT', dt('Project info not found. Please navigate to a valid project directory or specify one with the --path option.'));
     }
     // Indicate that this is a valid project.
     $this->valid = TRUE;
 }
开发者ID:markcarver,项目名称:drush-lwg,代码行数:34,代码来源:Project.php

示例5: 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

示例6: runserver_parse_uri

/**
 * Parse a URI or partial URI (including just a port, host IP or path).
 *
 * @param string $uri
 *   String that can contain partial URI.
 *
 * @return array
 *   URI array as returned by parse_url.
 */
function runserver_parse_uri($uri)
{
    if (empty($uri)) {
        return array();
    }
    if ($uri[0] == ':') {
        // ':port/path' shorthand, insert a placeholder hostname to allow parsing.
        $uri = 'placeholder-hostname' . $uri;
    }
    // FILTER_VALIDATE_IP expects '[' and ']' to be removed from IPv6 addresses.
    // We check for colon from the right, since IPv6 addresses contain colons.
    $to_path = trim(substr($uri, 0, strpos($uri, '/')), '[]');
    $to_port = trim(substr($uri, 0, strrpos($uri, ':')), '[]');
    if (filter_var(trim($uri, '[]'), FILTER_VALIDATE_IP) || filter_var($to_path, FILTER_VALIDATE_IP) || filter_var($to_port, FILTER_VALIDATE_IP)) {
        // 'IP', 'IP/path' or 'IP:port' shorthand, insert a schema to allow parsing.
        $uri = 'http://' . $uri;
    }
    $uri = parse_url($uri);
    if (empty($uri)) {
        return drush_set_error('RUNSERVER_INVALID_ADDRPORT', dt('Invalid argument - should be in the "host:port/path" format, numeric (port only) or non-numeric (path only).'));
    }
    if (count($uri) == 1 && isset($uri['path'])) {
        if (is_numeric($uri['path'])) {
            // Port only shorthand.
            $uri['port'] = $uri['path'];
            unset($uri['path']);
        }
    }
    if (isset($uri['host']) && $uri['host'] == 'placeholder-hostname') {
        unset($uri['host']);
    }
    return $uri;
}
开发者ID:tnchuntic,项目名称:govCMS,代码行数:42,代码来源:router.php

示例7: validateDrushParams

 public function validateDrushParams($args)
 {
     $values = array('num' => array_shift($args), 'kill' => drush_get_option('kill'), 'title_length' => 12);
     if ($this->isNumber($values['num']) == FALSE) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of vocabularies: !num.', array('!num' => $values['num'])));
     }
     return $values;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:8,代码来源:VocabularyDevelGenerate.php

示例8: getInstance

 /**
  * Downloads release info xml from update service.
  *
  * @param array $request
  *   A request array.
  * @param int $cache_duration
  *   Cache lifetime.
  *
  * @return \Drush\UpdateService\Project
  */
 public static function getInstance(array $request, $cache_duration = ReleaseInfo::CACHE_LIFETIME)
 {
     $url = self::buildFetchUrl($request);
     drush_log(dt('Downloading release history from !url', array('!url' => $url)));
     $path = drush_download_file($url, drush_tempnam($request['name']), $cache_duration);
     $xml = simplexml_load_file($path);
     if (!$xml) {
         $error = dt('Failed to get available update data from !url', array('!url' => $url));
         return drush_set_error('DRUSH_RELEASE_INFO_ERROR', $error);
     }
     return new Project($xml);
 }
开发者ID:hanoii,项目名称:drush,代码行数:22,代码来源:Project.php

示例9: downloadCore

 public function downloadCore()
 {
     $www_dir = $this->getProjectDir() . '/' . $this->getDocumentRoot();
     if (!is_file($www_dir . '/misc/drupal.js')) {
         $core_version = $this->getCoreVersion();
         $core = "drupal-" . $core_version . ".x";
         drush_log(dt('Downloading Drupal core...'), 'status');
         drush_set_option('backend', TRUE);
         drush_set_option('destination', $this->getProjectDir());
         drush_set_option('drupal-project-rename', $this->getDocumentRoot());
         if (drush_invoke('pm-download', array($core)) === FALSE) {
             return drush_set_error('', 'Drupal core download/extract failed.');
         }
         drush_set_option('backend', FALSE);
     } else {
         drush_log(dt('Drupal already downloaded and unpacked for this project.'));
     }
 }
开发者ID:netsensei,项目名称:Rum,代码行数:18,代码来源:RumVanilla.php

示例10: report_command_error

 function report_command_error($command)
 {
     // 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);
     }
 }
开发者ID:jibran,项目名称:drush,代码行数:18,代码来源:BaseBoot.php

示例11: run

 /**
  * {@inheritdoc}
  */
 public function run($name, $time_limit = 0)
 {
     $info = $this->getInfo($name);
     $function = $info['worker callback'];
     $end = time() + $time_limit;
     $queue = $this->getQueue($name);
     $count = 0;
     while ((!$time_limit || time() < $end) && ($item = $queue->claimItem())) {
         try {
             drush_log(dt('Processing item @id from @name queue.', array('@name' => $name, 'id' => $item->item_id)), LogLevel::INFO);
             $function($item->data);
             $queue->deleteItem($item);
             $count++;
         } catch (\Exception $e) {
             // In case of exception log it and leave the item in the queue
             // to be processed again later.
             drush_set_error('DRUSH_QUEUE_EXCEPTION', $e->getMessage());
         }
     }
     return $count;
 }
开发者ID:bjargud,项目名称:drush,代码行数:24,代码来源:Queue7.php

示例12: __construct

 /**
  * Class constructor.
  *
  * @param LWG $command
  *   The current instance of the command.
  * @param array|object $input
  *   The input parameter accepts an array.
  * @param int $flags
  *   Flags to control the behaviour of the ArrayObject object.
  * @param string $iterator_class
  *   Specify the class that will be used for iteration of the ArrayObject
  *   object. ArrayIterator is the default class used.
  */
 public function __construct(LWG $command, array $input = array(), $flags = 0, $iterator_class = "ArrayIterator")
 {
     $this->command = $command;
     $this->exchangeArray($input);
     $project = $command->getProject();
     $filename = $this->getFilename();
     $this->file = $project->getPath() . "/{$filename}";
     $this->cache = new Cache($project->getName() . ':notice');
     $cache = $this->cache->get();
     if (!file_exists($this->file)) {
         $prompt = dt("An existing !filename file was not found in @project.\nWould you like to create one?", array('!filename' => $filename, '@project' => $project->getInfo('name') ?: 'this project'));
         if (drush_confirm($prompt)) {
             if (!$this->save()) {
                 return drush_set_error('DRUSH_LWG_CREATE_FILE', dt("Unable to create the specified project file:\n!file", array('!file' => $this->file)));
             }
         } else {
             $this->file = FALSE;
             return $this;
         }
     }
     if (!is_writable($this->file)) {
         return drush_set_error('DRUSH_LWG_FILE_NOT_WRITABLE', dt("The specified project file is not writable:\n!file", array('!file' => $this->file)));
     }
     if (file_exists($this->file)) {
         $array = array();
         // Convert each entry into an Asset object.
         foreach (Yaml::parse($this->file) ?: array() as $name => $data) {
             if (is_array($data)) {
                 $array[$name] = new Asset($command, $name, $data);
             }
         }
         if (!$this->cache->exists()) {
             $this->cache->set($array);
         }
         $this->exchangeArray($array);
         $this->exists = TRUE;
     }
 }
开发者ID:markcarver,项目名称:drush-lwg,代码行数:51,代码来源:Notice.php

示例13: browse

 /**
  * Display a link to a given path or open link in a browser.
  *
  * @todo Document new @handle-remote-commands and @bootstrap annotations.
  *
  * @param string|null $path Path to open. If omitted, the site front page will be opened.
  * @option string $browser Specify a particular browser (defaults to operating system default). Use --no-browser to suppress opening a browser.
  * @todo conflicts with global option: @option integer $redirect-port The port that the web server is redirected to (e.g. when running within a Vagrant environment).
  * @usage drush browse
  *   Open default web browser (if configured or detected) to the site front page.
  * @usage drush browse node/1
  *   Open web browser to the path node/1.
  * @usage drush @example.prod
  *   Open a browser to the web site specified in a site alias.
  * @usage drush browse --browser=firefox admin
  *   Open Firefox web browser to the path 'admin'.
  * @todo not used AFAIK @bootstrap DRUSH_BOOTSTRAP_NONE
  * @todo not used @handle-remote-commands true
  * @complete \Drush\CommandFiles\core\BrowseCommands::complete
  */
 public function browse($path = '', $options = ['browser' => NULL])
 {
     // Redispatch if called against a remote-host so a browser is started on the
     // the *local* machine.
     $alias = drush_get_context('DRUSH_TARGET_SITE_ALIAS');
     if (drush_sitealias_is_remote_site($alias)) {
         $site_record = drush_sitealias_get_record($alias);
         $return = drush_invoke_process($site_record, 'browse', func_get_args(), drush_redispatch_get_options(), array('integrate' => TRUE));
         if ($return['error_status']) {
             return drush_set_error('Unable to execute browse command on remote alias.');
         } else {
             $link = $return['object'];
         }
     } else {
         if (!drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
             // Fail gracefully if unable to bootstrap Drupal. drush_bootstrap() has
             // already logged an error.
             return FALSE;
         }
         $link = drush_url($path, array('absolute' => TRUE));
     }
     drush_start_browser($link);
     return $link;
 }
开发者ID:phenaproxima,项目名称:drush,代码行数:44,代码来源:BrowseCommands.php

示例14: validateDrushParams

 public function validateDrushParams($args)
 {
     $link_types = array('node', 'front', 'external');
     $values = array('num_menus' => array_shift($args), 'num_links' => array_shift($args), 'kill' => drush_get_option('kill'), 'pipe' => drush_get_option('pipe'), 'link_types' => array_combine($link_types, $link_types));
     $max_depth = array_shift($args);
     $max_width = array_shift($args);
     $values['max_depth'] = $max_depth ? $max_depth : 3;
     $values['max_width'] = $max_width ? $max_width : 8;
     $values['existing_menus']['__new-menu__'] = TRUE;
     if ($this->isNumber($values['num_menus']) == FALSE) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of menus'));
     }
     if ($this->isNumber($values['num_links']) == FALSE) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of links'));
     }
     if ($this->isNumber($values['max_depth']) == FALSE || $values['max_depth'] > 9 || $values['max_depth'] < 1) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum link depth. Use a value between 1 and 9'));
     }
     if ($this->isNumber($values['max_width']) == FALSE || $values['max_width'] < 1) {
         return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum menu width. Use a positive numeric value.'));
     }
     return $values;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:23,代码来源:MenuDevelGenerate.php

示例15: bootstrap_backdrop_login

 /**
  * Execute the BackdropBoot::BOOTSTRAP_LOGIN phase.
  *
  * Log into the bootstrapped Backdrop site with a specific user name or ID.
  */
 function bootstrap_backdrop_login()
 {
     $uid_or_name = drush_set_context('DRUSH_USER', drush_get_option('user', 0));
     if (is_numeric($uid_or_name)) {
         $account = user_load($uid_or_name);
     }
     if (!$account) {
         $account = user_load_by_name($uid_or_name);
     }
     if ($account) {
         $GLOBALS['user'] = $account;
         // @todo: Convert Backdrop messages to drush output.
         //_drush_log_drupal_messages();
     } else {
         if (is_numeric($uid_or_name)) {
             $message = dt('Could not login with user ID !user.', array('!user' => $uid_or_name));
             if ($uid_or_name === 0) {
                 $message .= ' ' . dt('This is typically caused by importing a MySQL database dump from a faulty tool which re-numbered the anonymous user ID in the users table. See !link for help recovering from this situation.', array('!link' => 'http://drupal.org/node/1029506'));
             }
         } else {
             $message = dt('Could not login with user account `!user\'.', array('!user' => $uid_or_name));
         }
         return drush_set_error('DRUPAL_USER_LOGIN_FAILED', $message);
     }
 }
开发者ID:jenlampton,项目名称:drush,代码行数:30,代码来源:BackdropBoot.php


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