Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Drush Command for posting solr schema #131

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions modules/pantheon/pantheon_apachesolr/pantheon_apachesolr.drush.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* @file
* Drush commands for Pantheon Apachesolr.
*/

/**
* Implements hook_drush_command().
*/
function pantheon_apachesolr_drush_command() {
$items = array();

$items['pantheon-apachesolr-schema-post'] = array(
'description' => 'Posts a schema file to the Solr server',
'examples' => array(
'drush pantheon-apachesolr-schema-post sites/all/modules/contrib/apachesolr/solr-conf/solr-3.x/schema.xml' => dt('Posts the solr-3.x schema'),
),
'arguments' => array(
'file' => dt('The path to the schema file, relative to the Drupal root'),
),
);

return $items;
}

/**
* Post a schema file.
*/
function drush_pantheon_apachesolr_schema_post($file) {

$vars = array('!file' => $file);
if (filesize($file) < 1) {
drush_log(dt("The file !file is empty or does not exist", $vars), 'error');
}
else {
$success = pantheon_apachesolr_post_schema_exec($file);
if ($success) {
drush_log(dt("The file !file posted successfully", $vars), 'ok');
}
else {
drush_log(dt("The file !file failed to post successfully", $vars), 'error');
}
}
}