Пример #1
0
 public function build()
 {
     $finder = new Finder();
     $finder->in($this->path)->files()->name('*.xml')->sortByName();
     // Iterate over config files, and add a portal object for each config to the collection
     $collection = new WebspaceCollection();
     // reset arrays
     $this->webspaces = [];
     $this->portals = [];
     $this->portalInformations = [];
     foreach ($finder as $file) {
         // add file resource for cache invalidation
         $collection->addResource(new FileResource($file->getRealPath()));
         /** @var Webspace $webspace */
         $webspace = $this->loader->load($file->getRealPath());
         $this->webspaces[] = $webspace;
         $this->buildPortals($webspace);
     }
     $environments = array_keys($this->portalInformations);
     foreach ($environments as $environment) {
         // sort all portal informations by length
         uksort($this->portalInformations[$environment], function ($a, $b) {
             return strlen($a) < strlen($b);
         });
     }
     $collection->setWebspaces($this->webspaces);
     $collection->setPortals($this->portals);
     $collection->setPortalInformations($this->portalInformations);
     return $collection;
 }
Пример #2
0
 /**
  * Creates a new class with the data from the given collection.
  *
  * @param array $options
  *
  * @return string
  */
 public function dump($options = [])
 {
     return $this->render('WebspaceCollectionClass.php.twig', ['cache_class' => $options['cache_class'], 'base_class' => $options['base_class'], 'collection' => $this->webspaceCollection->toArray()]);
 }
Пример #3
0
 public function build()
 {
     $finder = new Finder();
     $finder->in($this->path)->files()->name('*.xml')->sortByName();
     // Iterate over config files, and add a portal object for each config to the collection
     $collection = new WebspaceCollection();
     // reset arrays
     $this->webspaces = [];
     $this->portals = [];
     $this->portalInformations = [];
     foreach ($finder as $file) {
         /* @var SplFileInfo $file */
         try {
             // add file resource for cache invalidation
             $collection->addResource(new FileResource($file->getRealPath()));
             /** @var Webspace $webspace */
             $webspace = $this->loader->load($file->getRealPath());
             $this->webspaces[] = $webspace;
             $this->buildPortals($webspace);
         } catch (\InvalidArgumentException $iae) {
             $this->logger->warning('Error in file "' . $file->getRealPath() . '" (' . $iae->getMessage() . '). The file has been skipped');
         } catch (InvalidUrlDefinitionException $iude) {
             $this->logger->warning('Error: "' . $iude->getMessage() . '" in "' . $file->getRealPath() . '". File was skipped');
         }
     }
     if (0 === count($this->webspaces)) {
         throw new NoValidWebspaceException($this->path);
     }
     $environments = array_keys($this->portalInformations);
     foreach ($environments as $environment) {
         // sort all portal informations by length
         uksort($this->portalInformations[$environment], function ($a, $b) {
             return strlen($a) < strlen($b);
         });
     }
     $collection->setWebspaces($this->webspaces);
     $collection->setPortals($this->portals);
     $collection->setPortalInformations($this->portalInformations);
     return $collection;
 }
Пример #4
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Unknown portal environment "unknown"
  */
 public function testGetPortalInformationsUnknown()
 {
     $this->webspaceCollection->getPortalInformations('unknown');
 }