function drush_omega_tools_omega_subtheme_validate in Omega Tools 7.3
Implements of drush_hook_COMMAND_validate().
File
- includes/
omega_tools.drush.inc, line 46
Code
function drush_omega_tools_omega_subtheme_validate($name) {
system_rebuild_theme_data();
$themes = list_themes();
$destination = drush_get_option('destination', 'all');
$machine_name = drush_get_option('machine_name', _omega_tools_transform_theme_name($name));
$base = drush_get_option('base');
$starterkit = drush_get_option('starterkit');
drush_set_option('machine_name', $machine_name);
if (!_omega_tools_theme_exists('alpha') || !_omega_tools_theme_exists('omega')) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('Where is the Omega base theme? I has not found it. :('));
}
if (!$machine_name || !preg_match('/^[a-z][a-z0-9_]*$/', $machine_name)) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('The machine name is invalid or could not be generated properly. It may only contain lowercase numbers, letters and underscores and must start with a letter. Please provide a proper machine name by using "--machine_name".'));
}
if (_omega_tools_theme_exists($machine_name)) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('A theme with that name already exists. The machine-readable name must be unique.'));
}
if (!in_array($destination, omega_tools_sites())) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('The destination is invalid.'));
}
if ($starterkit && (!_omega_tools_theme_exists($starterkit) || !_omega_tools_is_starterkit($starterkit))) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('There is no valid starterkit with the name !starterkit.', array(
'!starterkit' => $starterkit,
)));
}
if (!$base && $starterkit) {
$base = $themes[$starterkit]->info['base theme'];
drush_set_option('base', $base);
}
if ($base && !array_key_exists($base, omega_tools_base_themes())) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('There is no base theme with the name !base.', array(
'!base' => $base,
)));
}
if ($starterkit && $themes[$starterkit]->info['base theme'] != $base) {
return drush_set_error('OMEGA_TOOLS_THEME_ERROR', dt('The base theme of the selected starterkit does not match the selected base theme.'));
}
if (!$base && !$starterkit) {
drush_set_option('base', 'omega');
drush_set_option('starterkit', 'starterkit_omega_html5');
}
else {
if (!$base) {
drush_set_option('base', 'omega');
}
}
}