You are here

protected function RulesAbstractPlugin::getFileName in Rules 7.2

1 call to RulesAbstractPlugin::getFileName()
RulesAbstractPlugin::rebuildCache in includes/rules.core.inc
Add in the data provided by the info hooks to the cache.

File

includes/rules.core.inc, line 1868
Rules base classes and interfaces needed for any rule evaluation.

Class

RulesAbstractPlugin
Defines a common base class for so-called "Abstract Plugins" like actions.

Code

protected function getFileName($function, $includes) {
  static $filenames;
  if (!isset($filenames) || !array_key_exists($function, $filenames)) {
    $filenames[$function] = NULL;
    $reflector = new ReflectionFunction($function);

    // On windows the path contains backslashes instead of slashes, fix that.
    $file = str_replace('\\', '/', $reflector
      ->getFileName());
    foreach ($includes as $include) {
      $pos = strpos($file, $include . '.inc');

      // Test whether the file ends with the given filename.inc.
      if ($pos !== FALSE && strlen($file) - $pos == strlen($include) + 4) {
        $filenames[$function] = $include;
        return $include;
      }
    }
  }
  return $filenames[$function];
}