getBundles() public method

Returns all Symfony Bundles.
public getBundles ( ) : Symfony\Component\HttpKernel\Bundle\BundleInterface[]
return Symfony\Component\HttpKernel\Bundle\BundleInterface[]
示例#1
0
 /**
  * {@inheritDoc}
  */
 public function getBranch($pk = null, Condition $condition = null, $depth = 1, $scope = null, $options = null)
 {
     $result = null;
     if (!$pk || !$pk['path']) {
         return [['path' => '/', 'title' => 'Admin Access']];
     } else {
         if ('/' == $pk['path']) {
             foreach ($this->jarves->getBundles() as $bundle) {
                 $item = array('path' => $bundle->getName(), 'title' => $bundle->getName());
                 $this->setChildren(strtolower($bundle->getName()), $item, $depth);
                 $result[] = $item;
             }
         } else {
             self::normalizePath($pk['path']);
             $adminUtils = new \Jarves\Admin\Utils($this->jarves);
             $entryPoint = $adminUtils->getEntryPoint($pk['path']);
             if ($entryPoint && $entryPoint->getChildren()) {
                 foreach ($entryPoint->getChildren() as $entryPoint) {
                     $item = array('path' => $pk['path'] . '/' . $entryPoint->getPath(), 'type' => $entryPoint->getType(), 'title' => $entryPoint->getLabel() ? $entryPoint->getLabel() : $entryPoint->getPath());
                     $this->setChildren($pk['path'] . '/' . $entryPoint->getPath(), $item, $depth);
                     $result[] = $item;
                 }
             }
         }
     }
     return $result;
 }
示例#2
0
 /**
  * @param string $lang
  * @param bool $force
  * @return array|null|string
  *
  * @throws \Jarves\Exceptions\BundleNotFoundException
  */
 public function loadMessages($lang = 'en', $force = false)
 {
     if (!$this->isValidLanguage($lang)) {
         $lang = 'en';
     }
     if ($this->messages && isset($this->messages['__lang']) && $this->messages['__lang'] == $lang && $force == false) {
         return null;
     }
     if (!$lang) {
         return null;
     }
     $code = 'core/lang/' . $lang;
     $this->messages = $this->cacher->getFastCache($code);
     $md5 = '';
     $bundles = array();
     foreach ($this->jarves->getBundles() as $bundleName => $bundle) {
         $path = $bundle->getPath();
         if ($path) {
             $path .= "/Resources/translations/{$lang}.po";
             if (file_exists($path)) {
                 $md5 .= @filemtime($path);
                 $bundles[] = $bundleName;
             }
         }
     }
     $md5 = md5($md5);
     if (!$this->messages || count($this->messages) == 0 || !isset($this->messages['__md5']) || $this->messages['__md5'] != $md5) {
         $this->messages = array('__md5' => $md5, '__plural' => $this->getPluralForm($lang), '__lang' => $lang);
         foreach ($bundles as $key) {
             $file = $this->jarves->resolvePath("@{$key}/{$lang}.po", 'Resources/translations');
             $po = $this->getLanguage($file);
             $this->messages = array_merge($this->messages, $po['translations']);
         }
         $this->cacher->setFastCache($code, $this->messages);
     }
     include_once $this->getPluralPhpFunctionFile($lang);
     return $this->messages;
 }
示例#3
0
 /**
  * @ApiDoc(
  *  section="Bundle/Package Manager",
  *  description="Checks for updates in composer packages"
  * )
  *
  * @Rest\Get("/admin/system/bundle/manager/check-updates")
  *
  * @return array
  */
 public function check4UpdatesAction()
 {
     $res = [];
     foreach ($this->jarves->getBundles() as $bundleName => $bundle) {
         $composer = $this->utils->getComposerArray($bundleName) ?: [];
         $version = @$composer['version'];
         if ($version && $version != '' && self::versionCompareToServer($version, $version['content']) == '<') {
             $temp = array();
             $temp['newVersion'] = $version;
             $temp['bundle'] = $bundleName;
             $res[] = $temp;
         }
     }
     return $res;
 }
示例#4
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);
                 }
             }
         }
     }
 }
示例#5
0
 /**
  * {@inheritDoc}
  */
 public function getBranch($pk = null, Condition $condition = null, $depth = 1, $scope = null, $options = null)
 {
     $result = null;
     $path = $pk['path'];
     if ($depth === null) {
         $depth = 1;
     }
     if ($path) {
         $path = '@' . trim($path, '/@');
         $path = str_replace(':', '/', $path);
     }
     $c = 0;
     $offset = $options['offset'];
     $limit = $options['limit'];
     $result = array();
     if (!$path) {
         $result = array();
         $bundles = array_keys($this->jarves->getBundles());
         foreach ($bundles as $bundleName) {
             $directory = $this->jarves->resolvePath('@' . $bundleName, 'Resources/views', true);
             if (!$this->localFilesystem->has($directory)) {
                 continue;
             }
             $file = $this->localFilesystem->getFile($directory);
             if (!$file) {
                 $result[] = $directory;
                 continue;
             }
             $file = $file->toArray();
             $file['name'] = $bundleName;
             $file['path'] = $bundleName;
             if ($offset && $offset > $c) {
                 continue;
             }
             if ($limit && $limit < $c) {
                 continue;
             }
             if ($condition && $condition->hasRules() && !$this->conditionOperator->satisfy($condition, $file)) {
                 $result[] = $directory;
                 continue;
             }
             $c++;
             if ($depth > 0) {
                 $children = self::getBranch(array('path' => $bundleName), $condition, $depth - 1);
                 $file['_childrenCount'] = count($children);
                 if ($depth > 1 && $file['type'] == 'dir') {
                     $file['_children'] = $children;
                 }
             }
         }
     } else {
         if (!($bundleName = $this->jarves->getBundleFromPath($path))) {
             return [];
         }
         $directory = $this->jarves->resolvePath($path, 'Resources/views', true) . '/';
         if (!$this->localFilesystem->has($directory)) {
             return [];
         }
         $files = $this->localFilesystem->getFiles($directory);
         foreach ($files as $file) {
             $item = $file->toArray();
             if ($condition && $condition->hasRules() && !$this->conditionOperator->satisfy($condition, $item, 'jarves/file')) {
                 continue;
             }
             $c++;
             if ($offset && $offset >= $c) {
                 continue;
             }
             if ($limit && $limit < $c) {
                 continue;
             }
             $item = array('name' => $this->buildPath($path . '/' . Tools::getRelativePath($item['path'], $directory)), 'path' => $this->buildPath($path . '/' . Tools::getRelativePath($item['path'], $directory)));
             if ($file->isDir()) {
                 $children = self::getBranch(array('path' => $item['path']), $condition, $depth - 1);
                 foreach ($children as $child) {
                     //                        $child['name'] = $item['name'] . '/' . $child['name'];
                     $result[] = $child;
                 }
             }
             if ($file->isFile()) {
                 $result[] = $item;
             }
         }
     }
     return $result;
 }