function RulesAbstractPlugin::getFileName

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 1883

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];
}