Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function load($resource, $type = null)
 {
     if (true === $this->isLoaded) {
         throw new \RuntimeException('Do not add the "modera_routing" loader twice');
     }
     $resources = array();
     $items = $this->resourcesProvider->getItems();
     foreach ($items as $index => $resource) {
         if (!is_array($resource)) {
             $resource = array('resource' => $resource);
         }
         $resource = array_merge(array('order' => 0, 'type' => null), $resource);
         $resource['index'] = $index;
         $resources[] = $resource;
     }
     usort($resources, function ($a, $b) {
         if ($a['order'] == $b['order']) {
             return $a['index'] < $b['index'] ? -1 : 1;
         }
         return $a['order'] < $b['order'] ? -1 : 1;
     });
     $collection = new RouteCollection();
     foreach ($resources as $item) {
         $collection->addCollection($this->rootLoader->load($item['resource'], $item['type']));
     }
     $this->isLoaded = true;
     return $collection;
 }
Beispiel #2
0
 /**
  * @param string $name
  *
  * @return DashboardInterface|null
  */
 public function getDashboardByName($name)
 {
     if (!$this->dashboards) {
         $this->dashboards = array();
         foreach ($this->dashboardsProvider->getItems() as $dashboard) {
             /* @var DashboardInterface $dashboard */
             $this->dashboards[$dashboard->getName()] = $dashboard;
         }
     }
     return isset($this->dashboards[$name]) ? $this->dashboards[$name] : null;
 }
 /**
  * @param TokenStorageInterface $tokenStorage
  * @param ContributorInterface  $clientDiDefinitionsProvider
  */
 public function __construct(TokenStorageInterface $tokenStorage, ContributorInterface $clientDiDefinitionsProvider)
 {
     $this->items = array(new CallbackConfigMerger(function (array $currentConfig) use($tokenStorage) {
         // we are not making sure that user is authenticated here because we expect that this
         // callback is invoked only when user is already authenticated (invoked from behind a firewall)
         if ($token = $tokenStorage->getToken()) {
             $roles = array();
             foreach ($token->getRoles() as $role) {
                 $roles[] = $role->getRole();
             }
             return array_merge($currentConfig, array('roles' => $roles, 'userProfile' => Authenticator::userToArray($token->getUser())));
         } else {
             return $currentConfig;
         }
     }), new CallbackConfigMerger(function (array $currentConfig) use($clientDiDefinitionsProvider) {
         return array_merge($currentConfig, array('serviceDefinitions' => $clientDiDefinitionsProvider->getItems()));
     }));
 }
Beispiel #4
0
 /**
  * @param $type
  *
  * @return string[]
  */
 public function getJavascriptAssets($type)
 {
     return $this->filterRawAssetsByType($type, $this->jsResourcesProvider->getItems());
 }