isJarvesBundle() public method

public isJarvesBundle ( string $bundleName ) : boolean
$bundleName string
return boolean
Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 public function importObjectRoutes()
 {
     foreach ($this->jarves->getBundles() as $bundleName => $bundle) {
         if ($this->jarves->isJarvesBundle($bundleName)) {
             if (!($config = $this->jarves->getConfig($bundleName))) {
                 continue;
             }
             if ($objects = $config->getObjects()) {
                 foreach ($objects as $object) {
                     if ($object->isExcludeFromREST()) {
                         continue;
                     }
                     $objectName = $config->getName() . '/' . lcfirst($object->getId());
                     $pattern = '%jarves_admin_prefix%/object/' . $objectName;
                     $this->setupRoutes($config, $object->getFinalApiController(), $pattern, $object->getKey(), $object);
                     //maybe in v1.1
                     //$this->setupRelationRoutes($pattern, $object);
                 }
             }
         }
     }
 }