Last active
April 26, 2016 15:12
-
-
Save timodwhit/e60341fdf46a9ab688dad5836a555645 to your computer and use it in GitHub Desktop.
Generate and Enable Feature
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implements hook_form_alter(). | |
*/ | |
function MODULE_NAME_form_features_export_form_alter(&$form, &$form_state, $form_id) { | |
$rebuild = array_search('features_form_rebuild', $form['advanced']['generate']['#submit']); | |
unset($form['advanced']['generate']['#submit'][$rebuild]); | |
$form['advanced']['generate']['#submit'][] = 'ccp_install_features_export_enable_module'; | |
$form['advanced']['generate']['#submit'][] = 'features_form_rebuild'; | |
} | |
/** | |
* Custom Function to install the module on generation. | |
*/ | |
function MODULE_NAME_features_export_enable_module($form, &$form_state) { | |
if (!empty($form_state['input']['module_name'])){ | |
// Flush all caches, so Drupal knows the files exists. | |
drupal_flush_all_caches(); | |
// Grab module name enable. | |
$status = module_enable(array($form_state['input']['module_name'])); | |
if ($status) { | |
drupal_set_message(t("Feature: @name enabled", array('@name' => $form_state['input']['name']))); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment