Jarves\Jarves::getBundleDir PHP Method

getBundleDir() public method

public getBundleDir ( string $bundleName ) : string | null
$bundleName string full className or bundleName or short bundleName
return string | null with leading / relative to root folder
    public function getBundleDir($bundleName)
    {
        $bundle = $this->getBundle($bundleName);
        $path = null;
        if ($bundle) {
            $path = $bundle->getPath();
        } else {
            if (class_exists($bundleName)) {
                $reflection = new \ReflectionClass($bundleName);
                $path = dirname($reflection->getFileName());
            }
        }
        $current = realpath($this->rootDir . '/..');
        if ($path) {
            $path = Tools::getRelativePath($path, $current);
            if ('/' !== substr($path, -1)) {
                $path .= '/';
            }
            return $path;
        }
        return null;
    }

Usage Example

Example #1
0
 /**
  * @param string $bundle
  * @param string $lang
  * @return array
  */
 protected function getLanguage($bundle, $lang)
 {
     Manager::prepareName($bundle);
     $utils = $this->translator->getUtils();
     $file = $this->jarves->getBundleDir($bundle) . "Resources/translations/{$lang}.po";
     $res = $utils->parsePo($file);
     $pluralForm = $utils->getPluralForm($lang);
     preg_match('/^nplurals=([0-9]+);/', $pluralForm, $match);
     $res['pluralCount'] = intval($match[1]);
     $res['pluralForm'] = $pluralForm;
     return $res;
 }
All Usage Examples Of Jarves\Jarves::getBundleDir