本文整理汇总了PHP中drush_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP drush_get_option函数的具体用法?PHP drush_get_option怎么用?PHP drush_get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drush_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getResultWarn
/**
* Implements \SiteAudit\Check\Abstract\getResultWarn().
*/
public function getResultWarn()
{
$ret_val = dt('The following duplicate extensions were found:');
if (drush_get_option('html')) {
$ret_val = '<p>' . $ret_val . '</p>';
$ret_val .= '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>Name</th><th>Paths</th></thead>';
$ret_val .= '<tbody>';
foreach ($this->registry['extensions_dupe'] as $name => $paths) {
$ret_val .= '<tr><td>' . $name . '</td>';
$ret_val .= '<td>' . implode('<br/>', $paths) . '</td></tr>';
}
$ret_val .= '</tbody>';
$ret_val .= '</table>';
} else {
foreach ($this->registry['extensions_dupe'] as $name => $paths) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 6);
}
$ret_val .= $name . PHP_EOL;
$extension_list = '';
foreach ($paths as $path) {
$extension_list .= str_repeat(' ', 8) . $path . PHP_EOL;
}
$ret_val .= rtrim($extension_list);
}
}
return $ret_val;
}
示例2: getHooksDirectorySetting
/**
* Get the hooks directory.
*
* On Drush, this can come from several places, in the following order of
* preference:
* - The Drush --data option. This allows use of a central store of hook data
* that needs only be downloaded once for all Drupal sites. Subdirectories
* are made for each major version.
* - The Module Builder UI's variable. This will only be set if module
* builder has been installed as a Drupal module on the current site.
*/
private function getHooksDirectorySetting()
{
// Set the module folder based on variable.
// First try the drush 'data' option.
if (drush_get_option('data')) {
$directory = drush_get_option('data');
if ($directory) {
// In pure Drush, the hooks folder contains subfolder for hooks for
// each major version of Drupal.
if (substr($directory, -1, 1) != '/') {
$directory .= '/';
}
$directory .= $this->major_version;
return $directory;
}
}
// Second, check if we're in mixed drush.
if (function_exists('variable_get')) {
// We're in a loaded Drupal, but MB might not be installed here.
$directory = variable_get('module_builder_hooks_directory', 'hooks');
return $directory;
}
// If we get here then argh. Set to the default and hope...
$directory = 'hooks';
return $directory;
}
示例3: getResultInfo
/**
* Implements \SiteAudit\Check\Abstract\getResultInfo().
*/
public function getResultInfo()
{
if (drush_get_option('html')) {
$ret_val = '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>Table Name</th><th>Collation</th></tr></thead>';
$ret_val .= '<tbody>';
foreach ($this->registry['collation_tables'] as $name => $collation) {
$ret_val .= '<tr>';
$ret_val .= '<td>' . $name . '</td>';
$ret_val .= '<td>' . $collation . '</td>';
$ret_val .= '</tr>';
}
$ret_val .= '</tbody>';
$ret_val .= '</table>';
} else {
$ret_val = 'Table Name: Collation' . PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= '---------------------';
foreach ($this->registry['collation_tables'] as $name => $collation) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= "{$name}: {$collation}";
}
}
return $ret_val;
}
示例4: drush_main
/**
* The main Drush function.
*
* - Runs "early" option code, if set (see global options).
* - Parses the command line arguments, configuration files and environment.
* - Prepares and executes a Drupal bootstrap, if possible,
* - Dispatches the given command.
*
* function_exists('drush_main') may be used by modules to detect whether
* they are being called from Drush. See http://drupal.org/node/1181308
* and http://drupal.org/node/827478
*
* @return mixed
* Whatever the given command returns.
*/
function drush_main()
{
// Load Drush core include files, and parse command line arguments.
require dirname(__FILE__) . '/includes/preflight.inc';
if (drush_preflight_prepare() === FALSE) {
return 1;
}
// 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');
}
// Load the global Drush configuration files, and global Drush commands.
// Find the selected site based on --root, --uri or cwd
// Preflight the selected site, and load any configuration and commandfiles associated with it.
// Select and return the bootstrap class.
$bootstrap = drush_preflight();
// Reset our bootstrap phase to the beginning
drush_set_context('DRUSH_BOOTSTRAP_PHASE', DRUSH_BOOTSTRAP_NONE);
$return = '';
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) {
$return = $bootstrap->bootstrap_and_dispatch();
}
}
}
// TODO: Get rid of global variable access here, and just trust
// the bootstrap object returned from drush_preflight(). This will
// require some adjustments to Drush bootstrapping.
// See: https://github.com/drush-ops/drush/pull/1303
if ($bootstrap = drush_get_bootstrap_object()) {
$bootstrap->terminate();
}
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;
}
示例5: getResultFail
/**
* Implements \SiteAudit\Check\Abstract\getResultFail().
*/
public function getResultFail()
{
if (drush_get_option('html')) {
$ret_val = '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>Table Name</th><th>Engine</th></tr></thead>';
$ret_val .= '<tbody>';
foreach ($this->registry['engine_tables'] as $name => $engine) {
$ret_val .= '<tr>';
$ret_val .= '<td>' . $name . '</td>';
$ret_val .= '<td>' . $engine . '</td>';
$ret_val .= '</tr>';
}
$ret_val .= '</tbody>';
$ret_val .= '</table>';
} else {
$ret_val = 'Table Name: Engine' . PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= '---------------------';
foreach ($this->registry['engine_tables'] as $name => $engine) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= "{$name}: {$engine}";
}
}
return $ret_val;
}
示例6: getResultWarn
/**
* Implements \SiteAudit\Check\Abstract\getResultWarn().
*/
public function getResultWarn()
{
if (!drush_get_option('detail')) {
return dt('There are @count duplicate titles in the following types: @types', array('@count' => $this->registry['nodes_duplicate_title_count'], '@types' => implode(', ', array_keys($this->registry['nodes_duplicate_titles']))));
}
$ret_val = '';
if (drush_get_option('html') == TRUE) {
$ret_val .= '<table class="table table-condensed">';
$ret_val .= "<thead><tr><th>Content Type</th><th>Title</th><th>Count</th></tr></thead>";
foreach ($this->registry['nodes_duplicate_titles'] as $content_type => $title_counts) {
foreach ($title_counts as $title => $count) {
$ret_val .= "<tr><td>{$content_type}</td><td>{$title}</td><td>{$count}</td></tr>";
}
}
$ret_val .= '</table>';
} else {
$ret_val = 'Content Type: "Title" (Count)' . PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= '-----------------------------';
foreach ($this->registry['nodes_duplicate_titles'] as $content_type => $title_counts) {
foreach ($title_counts as $title => $count) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= "{$content_type}: \"{$title}\" ({$count})";
}
}
}
return $ret_val;
}
示例7: getPatch
public static function getPatch(array $patch)
{
static $cache = array();
if (!isset($cache[$patch['url']])) {
if (!empty($patch['local'])) {
if (is_file($patch['url']) && filesize($patch['url'])) {
$cache[$patch['url']] = $patch['url'];
} else {
throw new Exception("Unable to read patch from local path {$patch['url']}.");
}
} elseif (drush_get_option('no-cache')) {
$temp_file = drush_tempnam('drush_patchfile_', NULL, '.patch');
$cache[$patch['url']] = static::downloadPatch($patch['url'], $temp_file);
} else {
$cache_file = drush_directory_cache('patchfile') . '/' . md5($patch['url']) . '.patch';
if (is_file($cache_file) && filectime($cache_file) > $_SERVER['REQUEST_TIME'] - DRUSH_CACHE_LIFETIME_DEFAULT) {
drush_log(dt('Remote patch URL @url fetched from cache file @cache.', array('@url' => $patch['url'], '@cache' => $cache_file)));
$cache[$patch['url']] = $cache_file;
} else {
$cache[$patch['url']] = static::downloadPatch($patch['url'], $cache_file);
}
}
}
return $cache[$patch['url']];
}
示例8: execute
/**
* {@inheritdoc}
*/
public function execute($name = NULL)
{
if (empty($this->assets)) {
return;
}
$options = array_keys($this->assets);
$options[] = dt('All');
$choice = 'all';
if ($this->count > 2 && !drush_get_option('all')) {
$choice = drush_choice($options, dt('Choose which asset from @name to view:', array('@name' => $this->project->getInfo('name'))));
} else {
drush_print(dt("Number of @name asset(s): @count\n", array('@name' => $this->project->getInfo('name'), '@count' => $this->count)));
}
if ($choice === FALSE) {
return;
} elseif ($choice === $this->count) {
$this->clearScreen();
$choice = 'all';
}
if ($choice !== FALSE && $choice !== 'all') {
$this->clearScreen();
$this->printAsset($options[$choice]);
$this->execute($name);
} elseif ($this->count || $choice === 'all') {
foreach ($this->notice as $key => $asset) {
$this->printAsset($key);
}
return;
}
}
示例9: getAction
/**
* Implements \SiteAudit\Check\Abstract\getAction().
*/
public function getAction() {
if ($this->score != SiteAuditCheckAbstract::AUDIT_CHECK_SCORE_PASS) {
$ret_val = dt('Consider the following options:') . PHP_EOL;
$options = array();
$options[] = dt('Disable unneeded or unnecessary extensions.');
$options[] = dt('Consolidate functionality if possible, or custom develop a solution specific to your needs.');
$options[] = dt('Avoid using modules that serve only one small purpose that is not mission critical.');
if (drush_get_option('html')) {
$ret_val .= '<ul>';
foreach ($options as $option) {
$ret_val .= '<li>' . $option . '</li>';
}
$ret_val .= '</ul>';
}
else {
foreach ($options as $option) {
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 6);
}
$ret_val .= '- ' . $option . PHP_EOL;
}
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 6);
}
}
$ret_val .= dt('A lightweight site is a fast and happy site!');
return $ret_val;
}
}
示例10: getResultInfo
/**
* Implements \SiteAudit\Check\Abstract\getResultInfo().
*/
public function getResultInfo()
{
$ret_val = dt('There are @count total fields.', array('@count' => count($this->registry['field_api_map'])));
if (drush_get_option('detail')) {
if (drush_get_option('html')) {
$ret_val .= '<p>' . $ret_val . '</p>';
$ret_val .= '<table class="table table-condensed">';
$ret_val .= '<tr><th>Name</th><th>Type</th></tr>';
foreach ($this->registry['field_api_map'] as $field_name => $field_data) {
$ret_val .= "<tr><td>{$field_name}</td><td>{$field_data['type']}</td></tr>";
}
$ret_val .= '</table>';
} else {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= 'Name: Type' . PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= '----------';
foreach ($this->registry['field_api_map'] as $field_name => $field_data) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= $field_name . ': ' . $field_data['type'];
}
}
}
return $ret_val;
}
示例11: drush_main
/**
* The main Drush function.
*
* - Runs "early" option code, if set (see global options).
* - Parses the command line arguments, configuration files and environment.
* - Prepares and executes a Drupal bootstrap, if possible,
* - Dispatches the given command.
*
* function_exists('drush_main') may be used by modules to detect whether
* they are being called from drush. See http://drupal.org/node/1181308
* and http://drupal.org/node/827478
*
* @return
* Whatever the given command returns.
*/
function drush_main()
{
$return = '';
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 = '';
}
drush_bootstrap_finish();
return $return;
}
}
}
// Process initial global options such as --debug.
_drush_bootstrap_global_options();
$return = '';
drush_bootstrap_to_phase(DRUSH_BOOTSTRAP_DRUSH);
if (!drush_get_error()) {
// Do any necessary preprocessing operations on the command,
// perhaps handling immediately.
$command_handled = drush_preflight_command_dispatch();
if (!$command_handled) {
$return = _drush_bootstrap_and_dispatch();
}
}
drush_bootstrap_finish();
// After this point the drush_shutdown function will run,
// exiting with the correct exit code.
return $return;
}
示例12: 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;
}
示例13: __construct
/**
* Protected constructor; use getInstance.
*/
protected function __construct()
{
// Ensure implementing classes have necessary properties.
if (!$this->name) {
throw new \Exception('Missing name from ' . __CLASS__);
}
if (!$this->label) {
throw new \Exception('Missing label from ' . __CLASS__);
}
if (!filter_var($this->homepage, FILTER_VALIDATE_URL)) {
throw new \Exception('Missing valid homepage from ' . __CLASS__);
}
if (!filter_var($this->endpoint, FILTER_VALIDATE_URL)) {
throw new \Exception('Missing valid endpoint from ' . __CLASS__);
}
if (drush_get_option('refresh')) {
$this->apiGetSites();
}
$sites = SiteQuery::create()->filterByProvider($this->name)->find();
if (!empty($sites)) {
foreach ($sites as $site) {
$this->sites[$site->getName()] = $site;
}
}
}
示例14: getResultInfo
/**
* Implements \SiteAudit\Check\Abstract\getResultInfo().
*/
public function getResultInfo()
{
if (!empty($this->registry['cache_bins'])) {
if (drush_get_option('html')) {
$ret_val = '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>Bin</th><th>Class</th></tr></thead>';
$ret_val .= '<tbody>';
foreach ($this->registry['cache_bins'] as $bin => $class) {
$ret_val .= "<tr><td>{$bin}</td><td>{$class}</td></tr>";
}
$ret_val .= '</tbody>';
$ret_val .= '</table>';
} else {
$ret_val = 'Bin: Class' . PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= '----------';
foreach ($this->registry['cache_bins'] as $bin => $class) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
$ret_val .= "{$bin}: {$class}";
}
}
return $ret_val;
} else {
return dt('No cache bins defined.');
}
}
示例15: __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;
}