Sulu\Component\Webspace\Webspace::getSegments PHP Method

getSegments() public method

Returns the segments of this webspace.
public getSegments ( ) : Segment[]
return Segment[]
    public function getSegments()
    {
        return $this->segments;
    }

Usage Example

Example #1
0
 /**
  * Validate webspace default segment.
  *
  * @throws Exception\WebspaceDefaultSegmentNotFoundException
  * @throws Exception\InvalidWebspaceDefaultSegmentException
  */
 protected function validateWebspaceDefaultSegment()
 {
     // check if there are duplicate defaults in the webspaces segments
     $segments = $this->webspace->getSegments();
     if ($segments) {
         $webspaceDefaultSegmentFound = false;
         foreach ($segments as $webspaceSegment) {
             if ($webspaceSegment->isDefault()) {
                 // throw an exception, if a new default segment is found, although there already is one
                 if ($webspaceDefaultSegmentFound) {
                     throw new InvalidWebspaceDefaultSegmentException($this->webspace);
                 }
                 $webspaceDefaultSegmentFound = true;
             }
         }
         if (!$webspaceDefaultSegmentFound) {
             throw new WebspaceDefaultSegmentNotFoundException($this->webspace);
         }
     }
 }