getConfigs() public method

Returns all configurations for all registered bundles.
public getConfigs ( ) : Configs | Bundle[]
return Jarves\Configuration\Configs | Jarves\Configuration\Bundle[]
Ejemplo n.º 1
0
 public function addMainResources($options = array())
 {
     $response = $this->pageStack->getPageResponse();
     $request = $this->pageStack->getRequest();
     $options['noJs'] = isset($options['noJs']) ? $options['noJs'] : false;
     $prefix = substr($this->jarves->getAdminPrefix(), 1);
     $response->addJs('
     window._path = window._baseUrl = ' . json_encode($request->getBasePath() . '/') . '
     window._pathAdmin = ' . json_encode($request->getBaseUrl() . '/' . $prefix . '/'), 3001);
     if ($this->jarves->isDebugMode()) {
         foreach ($this->jarves->getConfigs() as $bundleConfig) {
             foreach ($bundleConfig->getAdminAssetsInfo() as $assetInfo) {
                 if ($options['noJs'] && $assetInfo->isJavaScript()) {
                     continue;
                 }
                 $response->addAsset($assetInfo);
             }
         }
     } else {
         $response->addCssFile($prefix . '/admin/backend/css');
         if (!$options['noJs']) {
             $response->addJsFile($prefix . '/admin/backend/script', 3000);
         }
         foreach ($this->jarves->getConfigs() as $bundleConfig) {
             foreach ($bundleConfig->getAdminAssetsInfo() as $assetInfo) {
                 if ($options['noJs'] && $assetInfo->isJavaScript()) {
                     continue;
                 }
                 if ($assetInfo->getPath()) {
                     // load javascript files, that are not accessible (means those point to a controller)
                     // because those can't be compressed
                     $path = $this->jarves->resolveWebPath($assetInfo->getPath());
                     if (!file_exists($path)) {
                         $response->addAsset($assetInfo);
                         continue;
                     }
                 }
                 if ($assetInfo->getContent()) {
                     // load inline assets because we can't compress those
                     $response->addAsset($assetInfo);
                     continue;
                 }
                 if (!$assetInfo->isCompressionAllowed()) {
                     $response->addAsset($assetInfo);
                 }
             }
         }
     }
     $response->setDocType('JarvesBundle:Admin:index.html.twig');
     $response->addHeader('<meta name="viewport" content="initial-scale=1.0" >');
     $response->addHeader('<meta name="apple-mobile-web-app-capable" content="yes">');
     $response->setResourceCompression(false);
 }
Ejemplo n.º 2
0
 /**
  * @ApiDoc(
  *  section="Bundle Editor",
  *  description="Builds all model files and updates their model schema"
  * )
  *
  * @Rest\RequestParam(name="objectKey", requirements=".*", strict=true, description="The object key like jarves/node")
  *
  * @Rest\Post("/admin/system/bundle/editor/model/build")
  *
  * @return boolean
  * @throws ModelBuildException
  */
 public function setModelFromObjectsAction($objectKey)
 {
     /** @var Builder $modelBuilder */
     $modelBuilder = $this->get('jarves.model.builder');
     /** @var Propel $builder */
     $builder = $modelBuilder->getBuilder('propel');
     $object = $this->jarves->getConfigs()->getObject($objectKey);
     if (!$object) {
         throw new \RuntimeException('Object not found ' . $objectKey);
     }
     $buffer = new BufferedOutput();
     $builder->build([$object], $buffer, true);
     return $buffer->fetch();
 }
Ejemplo n.º 3
0
 /**
  * @ApiDoc(
  *  section="Backend",
  *  description="Returns all available menu/entryPoint items for the main navigation bar in the administration"
  * )
  *
  * @Rest\View()
  * @Rest\Get("/admin/backend/menus")
  *
  * @return array
  */
 public function getMenusAction()
 {
     $entryPoints = array();
     foreach ($this->jarves->getConfigs() as $bundleName => $bundleConfig) {
         foreach ($bundleConfig->getAllEntryPoints() as $subEntryPoint) {
             $path = $subEntryPoint->getFullPath();
             if (substr_count($path, '/') <= 3) {
                 if ($subEntryPoint->isLink()) {
                     if ($this->acl->check(ACLRequest::create('jarves/entryPoint', ['path' => '/' . $path]))) {
                         $entryPoints[$path] = array('label' => $subEntryPoint->getLabel(), 'icon' => $subEntryPoint->getIcon(), 'fullPath' => $path, 'path' => $subEntryPoint->getPath(), 'type' => $subEntryPoint->getType(), 'system' => $subEntryPoint->getSystem(), 'templateUrl' => $subEntryPoint->getTemplateUrl(), 'level' => substr_count($path, '/'));
                     }
                 }
             }
         }
     }
     return $entryPoints;
 }
Ejemplo n.º 4
0
 /**
  * @return string
  */
 public function getDocType()
 {
     if ($page = $this->pageStack->getCurrentPage()) {
         $themeId = $page->getTheme() ?: $this->pageStack->getCurrentDomain()->getTheme();
         if ($theme = $this->jarves->getConfigs()->getTheme($themeId)) {
             $layoutKey = $this->getLayout($page);
             if ($layout = $theme->getLayoutByKey($layoutKey)) {
                 if ($layout->getDoctype()) {
                     return $layout->getDoctype();
                 }
             }
             if ($theme->getDoctype()) {
                 return $theme->getDoctype();
             }
         }
     }
     return $this->docType;
 }
Ejemplo n.º 5
0
 protected function registerContentTypes(Jarves $jarves, ContainerInterface $container)
 {
     /** @var ContentRender $jarvesContentRender */
     $jarvesContentRender = $container->get('jarves.content.render');
     foreach ($jarves->getConfigs() as $bundleConfig) {
         if ($bundleConfig->getContentTypes()) {
             foreach ($bundleConfig->getContentTypes() as $contentType) {
                 if ('stopper' === $contentType->getId()) {
                     continue;
                 }
                 if (!$contentType->getService()) {
                     throw new \RuntimeException(sprintf('For content type %s:%s is no service defined', $bundleConfig->getName(), $contentType->getId()));
                 }
                 if (!$container->has($contentType->getService())) {
                     throw new \RuntimeException(sprintf('Service `%s` for content type %s:%s does not exist', $contentType->getService(), $bundleConfig->getName(), $contentType->getId()));
                 }
                 $instance = $container->get($contentType->getService());
                 if ($instance instanceof ContentTypes\AbstractType) {
                     $jarvesContentRender->addType($contentType->getId(), $container->get($contentType->getService()));
                 } else {
                     throw new \RuntimeException(sprintf('Content type %s:%s with service %s has wrong parent class', $bundleConfig->getName(), $contentType->getId(), $contentType->getService()));
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * prepares $fields. Replace array items which are only a key (with no array definition) with
  * the array definition of the proper field from the object fields.
  *
  * @param array $fields
  */
 public function prepareFieldDefinition(array &$fields)
 {
     for ($i = 0; $i < count($fields); $i++) {
         $key = array_keys($fields)[$i];
         $field = $fields[$key];
         if (is_numeric($key) && !$field instanceof Field) {
             if (!$this->objectDefinition->getField($field)) {
                 throw new \InvalidArgumentException(sprintf('Field %s not found', $field));
             }
             $newItem = clone $this->objectDefinition->getField($field);
             if ($newItem) {
                 $newItem = $newItem->toArray();
             } else {
                 continue;
             }
             if (!isset($newItem['label'])) {
                 $newItem['label'] = $field;
             }
             $fields = array_merge(array_slice($fields, 0, $i), array($field => $newItem), array_slice($fields, $i + 1));
             $i = -1;
         }
     }
     foreach ($fields as $key => &$field) {
         if ($field instanceof Field) {
             continue;
         }
         if (!is_array($field)) {
             continue;
         }
         $fieldName = $key;
         $objectDefinition = $this->objectDefinition;
         if (strpos($key, '.')) {
             list($objectName, $fieldName) = explode('.', $key);
             if (!$objectDefinition->getField($objectName)) {
                 throw new \RuntimeException("Relation `{$objectName}` (`{$key}`) in object {$objectDefinition->getKey()} not found.");
             }
             $foreignObjectName = $objectDefinition->getField($objectName)->getObject();
             $objectDefinition = $this->jarves->getConfigs()->getObject($foreignObjectName);
             if (!$objectDefinition) {
                 throw new \RuntimeException("Object {$foreignObjectName} not found, used in field {$this->objectDefinition->getKey()} {$key}");
             }
         }
         if ($oField = $objectDefinition->getField($fieldName)) {
             $field = array_merge($oField->toArray(), $field);
         }
         if (isset($field['children'])) {
             $this->prepareFieldDefinition($field['children']);
         }
     }
 }