Created
March 15, 2012 15:25
-
-
Save arnested/2044786 to your computer and use it in GitHub Desktop.
drupal_alter in page_manager_load_task_handlers()
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
| diff --git page_manager/page_manager.module page_manager/page_manager.module | |
| index 7b606af..4200315 100644 | |
| --- page_manager/page_manager.module | |
| +++ page_manager/page_manager.module | |
| @@ -530,6 +530,9 @@ function page_manager_load_task_handlers($task, $subtask_id = NULL, $default_han | |
| } | |
| } | |
| + // Let other modules alter the handlers. | |
| + drupal_alter('page_manager_load_task_handlers', $handlers, $task, $subtask_id); | |
| + | |
| return $handlers; | |
| } |
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 | |
| /** | |
| * @file | |
| * Code for the my-feature feature. | |
| */ | |
| include_once 'my_feature.features.inc'; | |
| /** | |
| * Implements hook_page_manager_load_task_handlers_alter(). | |
| * | |
| * When page manager loads task handlers for pages we remove the page handlers | |
| * that are handled by features in this module. | |
| * | |
| * Requires a patch to ctools/page_manager.module (call drupal_alter). | |
| */ | |
| function my_feature_page_manager_load_task_handlers_alter(&$handlers, $task, $subtask_id = NULL) { | |
| // If we are on an admin/structure/features* page or we are being called | |
| // through drush features we will filter out page handlers. | |
| $in_drush_features = FALSE; | |
| if (function_exists('drush_get_command')) { | |
| $command = drush_get_command(); | |
| if (isset($command['drupal dependencies']) && in_array('features', $command['drupal dependencies'])) { | |
| $in_drush_features = TRUE; | |
| } | |
| }; | |
| if (preg_match('/admin\/structure\/features/', $_GET['q']) || $in_drush_features) { | |
| // Load the page handlers handled by this feature module. | |
| $my_feature_handlers = array_keys(my_feature_default_page_manager_handlers()); | |
| if ($task['name'] == 'page') { | |
| foreach ($handlers as $handler) { | |
| if (in_array($handler->name, $my_feature_handlers)) { | |
| unset($handlers[$handler->name]); | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment