Sulu\Component\Webspace\Manager\WebspaceCollection::addResource PHP Method

addResource() public method

Adds a new FileResource, which is required to determine if the cache is fresh.
public addResource ( Symfony\Component\Config\Resource\FileResource $resource )
$resource Symfony\Component\Config\Resource\FileResource
    public function addResource(FileResource $resource)
    {
        $this->resources[] = $resource;
    }

Usage Example

示例#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;
 }
All Usage Examples Of Sulu\Component\Webspace\Manager\WebspaceCollection::addResource