Created
May 6, 2014 18:50
-
-
Save lucasconstantino/757c3c1e86b4d040cc92 to your computer and use it in GitHub Desktop.
A generic hook_ctools_plugin_directory implementation.
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_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