Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save arnested/2044786 to your computer and use it in GitHub Desktop.

Select an option

Save arnested/2044786 to your computer and use it in GitHub Desktop.
drupal_alter in page_manager_load_task_handlers()
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;
}
<?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