/** * Get potential data directory paths. * * If a `dataDir` option was explicitly set, returns an array containing * just that directory. * * Otherwise, it returns `~/.psysh` and all XDG Base Directory data directories: * * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html * * @return string[] */ public static function getDataDirs() { $xdg = new Xdg(); return self::getDirNames($xdg->getDataDirs()); }
/** * Get potential data directory paths. * * If a `dataDir` option was explicitly set, returns an array containing * just that directory. * * Otherwise, it returns `~/.psysh` and all XDG Base Directory data directories: * * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html * * @return string[] */ protected function getDataDirs() { if (isset($this->dataDir)) { return array($this->dataDir); } $xdg = new Xdg(); $dirs = array_map(function ($dir) { return $dir . '/psysh'; }, $xdg->getDataDirs()); if ($home = $this->getPsyHome()) { array_unshift($dirs, $home); } return $dirs; }
/** * Get potential data directory paths. * * If a `dataDir` option was explicitly set, returns an array containing * just that directory. * * Otherwise, it returns `~/.psysh` and all XDG Base Directory data directories: * * http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html * * @return string[] */ protected function getDataDirs() { if (isset($this->dataDir)) { return array($this->dataDir); } $xdg = new Xdg(); $dirs = array_map(function ($dir) { return $dir . '/psysh'; }, $xdg->getDataDirs()); array_unshift($dirs, $this->getHomeDir() . '/.psysh'); return $dirs; }