getBundleName() public method

Jarves\JarvesBundle => JarvesBundle
public getBundleName ( string $bundleClass ) : string
$bundleClass string
return string
コード例 #1
0
ファイル: ManagerController.php プロジェクト: jarves/jarves
 /**
  * @param Finder $finder
  * @return array
  */
 protected function getBundles(Finder $finder)
 {
     $bundles = array();
     /** @var \Symfony\Component\Finder\SplFileInfo $file */
     foreach ($finder as $file) {
         $file = $file->getRealPath();
         $content = file_get_contents($file);
         preg_match('/^\\s*\\t*class ([a-z0-9_]+)/mi', $content, $className);
         if (isset($className[1]) && $className[1]) {
             preg_match('/\\s*\\t*namespace\\s*\\t*([a-zA-Z0-9_\\\\]+)/i', $content, $namespace);
             $class = (count($namespace) > 1 ? $namespace[1] . '\\' : '') . $className[1];
             if ('Bundle' === $className[1] || false !== strpos($class, '\\Test\\') || false !== strpos($class, '\\Tests\\')) {
                 continue;
             }
             $bundles[] = $class;
         }
     }
     $bundles = array_unique($bundles);
     $res = [];
     foreach ($bundles as $bundleClass) {
         if (!class_exists($bundleClass)) {
             continue;
         }
         $name = basename(str_replace('\\', '//', $bundleClass));
         $reflection = new \ReflectionClass($bundleClass);
         $interfaces = $reflection->getInterfaceNames();
         if (in_array('Symfony\\Component\\HttpKernel\\Bundle\\BundleInterface', $interfaces)) {
             $composer = $this->utils->getComposerArray($bundleClass) ?: [];
             $composer['_path'] = $this->jarves->getBundleDir($bundleClass);
             if (isset($composer['name'])) {
                 $composer['_installed'] = $this->getInstalledInfoAction($composer['name']);
             } else {
                 $composer['_installed'] = [];
             }
             $composer['_bundleName'] = $this->jarves->getBundleName($bundleClass);
             $composer['activated'] = $this->jarves->isActiveBundle($name);
             $composer['jarvesBundle'] = $this->jarves->isJarvesBundle($name);
             $res[$bundleClass] = $composer;
         }
     }
     return $res;
 }