Skip to content

Instantly share code, notes, and snippets.

@e2thex
Created July 11, 2012 15:28
Show Gist options
  • Select an option

  • Save e2thex/3091134 to your computer and use it in GitHub Desktop.

Select an option

Save e2thex/3091134 to your computer and use it in GitHub Desktop.
PluginFactory::checkPluginMeta
/**
* Recursive function to search the meta data
*
* @param $plugin_info
* @param $property
* this can be a string or a array of tree keys
* @param $value
*
* @return bool
*/
protected function checkPluginMeta($plugin_info, $property, $value) {
$tree = array();
if (is_array($property)) {
$tree = $property;
$property = array_shift($tree);
}
foreach ($plugin_info as $plugin_info_key => $plugin_info_value) {
if ($plugin_info_key == $property) {
if($tree) {
return $this->checkPluginMeta($plugin_info[$plugin_info_key], $tree, $value);
}
else if ($plugin_info_value == $value) {
return TRUE;
}
}
}
return FALSE;
}
@jec006
Copy link
Copy Markdown

jec006 commented Jul 11, 2012


$test = array(
  'instance settings' => array(
    'whatever' => FALSE,
    'condition' => 'something',
  ),
  'sub' => array(
    'condition' => 'basic'
  ),
  'condition' => 'wrong',
);

//returns true
checkPluginMeta($test, 'condition', 'basic');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment