Phergie_Plugin_Abstract::findDataFile PHP Method

findDataFile() public method

Locates a given data file used by this plugin and returns the path to it. This is currently used mainly for compatibility with PEAR packaging.
public findDataFile ( string $filename ) : string | null
$filename string Name of the file
return string | null File path or NULL if the file cannot be found
    public function findDataFile($filename)
    {
        $class = get_class($this);
        $r = new ReflectionClass($class);
        $path = dirname($r->getFilename()) . '/' . $this->getName() . '/' . $filename;
        if (file_exists($path)) {
            return $path;
        }
        if (class_exists('PEAR_Config')) {
            $config = new PEAR_Config();
            $dataDir = $config->get('data_dir');
            $path = rtrim($dataDir, '\\/') . '/' . $class . '/' . str_replace('_', '/', $class) . '/' . $filename;
            if (file_exists($path)) {
                return $path;
            }
        }
        return null;
    }