Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lucasconstantino/757c3c1e86b4d040cc92 to your computer and use it in GitHub Desktop.
Save lucasconstantino/757c3c1e86b4d040cc92 to your computer and use it in GitHub Desktop.
A generic hook_ctools_plugin_directory implementation.
<?php
/**
* Implements hook_ctools_plugin_directory().
*/
function hook_ctools_plugin_directory($owner, $plugin_type) {
$plugin_map = array(
// Set the directory map as the key to the following 'owner' => 'plugin_type' combinations.
"plugins/$plugin_type" => array(
// Set owner => plugin_type so if they match, the directory above will be used.
'panels' => 'styles',
// Set to an array to allow more then one specific plugin types for this owner.
'ctools' => array('content_types', 'cache'),
// Set value to the variable so any value is accepted for this owner.
'page_manager' => $plugin_type,
// MORE...
// 'stylizer' => $plugin_type,
// 'panelizer' => $plugin_type,
),
// Set other plugin paths, if needed. They might even contain the same owners as above,
// if they are defined with a differente plugin type.
);
foreach ($plugin_map as $map => $plugins) {
if (!is_array($plugins[$owner])) {
$plugins[$owner] = array($plugins[$owner]);
}
if (isset($plugins[$owner]) && in_array($plugin_type, $plugins[$owner])) {
return $map;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment