data_export_import.drush.inc in Data export import 6
Same filename and directory in other branches
This file defines the Data Export Import module drush commands.
To find out how to use the command run `drush help dei-export` to see the command options.
File
includes/data_export_import.drush.incView source
<?php
/**
* @file
* This file defines the Data Export Import module drush commands.
*
* To find out how to use the command run `drush help dei-export`
* to see the command options.
*/
/**
* Implements hook_drush_command().
*
* This function specifies which commands the drush module has made
* available.
*
* @return array
* An associative array describing your command(s).
*/
function data_export_import_drush_command() {
$items = array();
// The 'data_export_import-export' command.
$items['data_export_import-export'] = array(
'description' => "Exports Data Export Import dataset profiles.",
'arguments' => array(
'profile' => 'The type of dataset profile.',
),
'options' => array(
'content-types' => 'List of comma separated content types to supply to the nodes export command.',
),
'examples' => array(
'drush data_export_import-export terms' => 'Export taxonomy terms to a file.',
),
'aliases' => array(
'dei-ex',
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
);
// The 'data_export_import-import' command.
$items['data_export_import-import'] = array(
'description' => "Imports Data Export Import dataset files.",
'arguments' => array(
'file' => 'The name of the file being imported.',
),
'options' => array(
'options' => 'List of comma separated options to supply to the command.',
),
'examples' => array(
'drush data_export_import-import terms file=20120223_170526_taxonomy_terms.dataset' => 'Import a dataset from a file.',
),
'aliases' => array(
'dei-im',
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_LOGIN,
);
return $items;
}
/**
* Implements hook_drush_help().
*
* This function is called when a drush user calls 'drush help'. This
* hook is optional. If a command does not implement this hook, the
* command's description is used instead.
*
* This hook is also used to look up help metadata, such as help
* category title and summary.
*
* @section string
* A string with the help section (prepend with 'drush:')
*
* @return string
* A string with the help text for your command.
*/
function data_export_import_drush_help($section) {
switch ($section) {
case 'drush:data_export_import-export':
return dt("This command will export a dataset profile to a data file.");
case 'drush:data_export_import-import':
return dt("This command will import a dataset file.");
case 'meta:data_export_import:title':
// The 'title' meta item is used to name a group of
// commands in `drush help`. If a title is not defined,
// the default is "All commands in ___", with the
// specific name of the commandfile (e.g. sandwich).
// Command files with less than four commands will
// be placed in the "Other commands" section, _unless_
// they define a title. It is therefore preferable
// to not define a title unless the file defines a lot
// of commands.
return dt("Data Export Import commands");
case 'meta:data_export_import:summary':
// The 'summary' meta item is displayed in `drush help --filter`,
// and is used to give a general idea what the commands in this
// command file do, and what they have in common.
return dt("Drush commands to carry out functions of the Data Export Import module.");
}
}
/**
* A drush command callback. This is where the action takes place.
*
* This function will handle exporting data profiles to data files -
* it can be extended by the addition of further profiles.
*
* @profile string
* Which dataset profile to export.
*
* @return bool
* Set as TRUE if the function ran OK.
*/
function drush_data_export_import_export($profile) {
// @todo These options should be pulled in from the profile files.
switch ($profile) {
case 'terms':
$msg = data_export_import_export_taxonomy_terms();
break;
case 'users':
$msg = data_export_import_export_users_to_file();
break;
case 'nodes':
// Get the list of content types which should be exported.
$list_of_content_types = drush_get_option('content-types');
$array_of_content_types = explode(',', $list_of_content_types);
$msg = data_export_import_all_content_types_export_to_file_using_drush($array_of_content_types);
break;
default:
$msg = "No valid argument was supplied.";
}
drush_print($msg);
return TRUE;
}
/**
* A drush command callback. This is where the action takes place.
*
* This function will handle the importing of dataset files.
*
* @dataset_file string
* The dataset file which will be imported.
*
* @return bool
* Set as TRUE if the function ran OK.
*/
function drush_data_export_import_import($dataset_file) {
switch ($dataset_file) {
case 'terms':
$filename = drush_get_option('file');
data_export_import_import_taxonomy_terms($filename);
break;
case 'users':
$filename = drush_get_option('file');
data_export_import_import_users($filename);
break;
case 'nodes':
$filename = drush_get_option('file');
data_export_import_import_all_content_types_using_drush($filename);
break;
default:
$msg = "No valid argument was supplied to the dei-import command.";
drush_print($msg);
}
return TRUE;
}
Functions
Name![]() |
Description |
---|---|
data_export_import_drush_command | Implements hook_drush_command(). |
data_export_import_drush_help | Implements hook_drush_help(). |
drush_data_export_import_export | A drush command callback. This is where the action takes place. |
drush_data_export_import_import | A drush command callback. This is where the action takes place. |