optimizely.drush.inc in Optimizely 7.3
Drush integration of Otimizely.
The commands can take the form of:
- drush optimizely-set-id ###
File
optimizely.drush.incView source
<?php
/**
* @file
* Drush integration of Otimizely.
*
* The commands can take the form of:
* - drush optimizely-set-id ###
*/
/**
* Implements hook_drush_help().
*/
function optimizely_drush_help($section) {
switch ($section) {
case 'drush:optimizely-set-id':
return dt('Set the optimizely account ID.');
default:
return dt('@section not defined.', array(
'@section' => $section,
));
}
}
/**
* Implements hook_drush_command().
*/
function optimizely_drush_command() {
$items = array();
$items['optimizely-set-id'] = array(
'callback' => 'optimizely_set_id',
'drupal dependencies' => array(
'optimizely',
),
'description' => 'Set the Optimizely account ID.',
'arguments' => array(
'oid' => 'The ID to set.',
'pid',
),
'bootstrap' => DRUPAL_BOOTSTRAP_VARIABLES,
'aliases' => array(
'op-id',
),
);
return $items;
}
/**
* Callback function for optimizely-set-id command.
*
* @parm $oid
* An oid provided by Optimizely and entered via drush. Must be an integer.
*/
function optimizely_set_id($oid = NULL) {
module_load_include('inc', 'optimizely', 'optimizely.admin');
if (empty($oid)) {
return drush_set_error(dt('The ID of the Optimizely account is required.'));
}
if (!preg_match('/^\\d+$/', $oid)) {
return drush_set_error(dt('Invalid Optimizely ID, needs to be numeric.'));
}
_optimizely_update_oid($oid);
drush_log(dt('The Optimizely ID was set to @oid. The default project entry is now ready to be enabled. This will apply to the default Optimizely project tests site wide.', array(
'@oid' => $oid,
)), 'ok');
}
Functions
Name | Description |
---|---|
optimizely_drush_command | Implements hook_drush_command(). |
optimizely_drush_help | Implements hook_drush_help(). |
optimizely_set_id | Callback function for optimizely-set-id command. |