Module::setSegments

@param array|string $segments

@return static
554908
public function setSegments($segments)
    {
        $this->segments = is_array($segments) ? implode('/', $segments) : $segments;

        return $this;
    }
822784
public function setSections(array $sections)
    {
        foreach ($sections as $key => $config) {
            // Watch out for old config data that's not updated yet
            if (!isset($config['sectionUid'])) {
                continue;
            }

            // Ignore sections that don't allow guest submissions
            if ($config['allowGuestSubmissions']) {
                $this->_sections[$config['sectionUid']] = new SectionSettings($config);
            } else {
                unset($this->_sections[$config['sectionUid']]);
            }
        }
    }
1315067
private function dimensions(array $segments)
    {
        $translatedDimensions = $this->dimensions;

        $this->array_substitute($translatedDimensions, $segments);

        return implode('.', $translatedDimensions);
    }
1137930
public function setSegment($segment)
    {
        if (array_key_exists($segment, $this->segments)) {
            return $this->segments[$segment];
        }
        // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*?)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm";
        $reg = "#\[!--\sBEGIN\s$segment\s--\](.*?)\[!--\sEND\s$segment\s--\]#smU";
        if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) {
            throw new OdfException("'$segment' segment not found in the document");
        }
        $this->segments[$segment] = new Segment($segment, $m[1], $this);
        return $this->segments[$segment];
    }
989916
func (s *Trace) SetSegments(v []*Segment) *Trace {
	s.Segments = v
	return s
}
169935
private function addSegment(string $segment): void
    {
        preg_match_all(
            "/\{(?'name'[a-z0-9_]++)(?::(?'pattern'(?:[^{}]++|\{(?&pattern)\})++))?\}/i",
            $segment,
            $matches,
            \PREG_SET_ORDER | \PREG_OFFSET_CAPTURE | \PREG_UNMATCHED_AS_NULL
        );

        if (empty($matches)) {
            $this->segments[] = $segment;
            $this->format .= $this->formatEncode($segment) . '/';
            return;
        }

        $pattern = $this->formatPattern($segment, $matches);
        $this->patterns[\count($this->segments)] = sprintf('/%s/', $pattern);
        $this->segments[] = self::DYNAMIC_SEGMENT;
    }
1020427
public static function prependSegment($uri, $segment)
    {
        $uri = self::filterUri($uri);

        return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->prepend($segment));
    }
1082425
public function parse(&$segments)
    {
        $query = array();
        $path = implode('/', $segments);
        if ($path == 'new') {
            array_pop($segments);
            $query = array_merge(parent::parse($segments), array('new' => true));
        } else {
            return parent::parse($segments);
        }

        return $query;
    }
628839
private function setBounds(&$segments) {
        for ($i = 0, $count = count($segments); $i < $count; ++$i) {
            if ($segments[$i]->optional && $i - 1 >= 0) {
                $optional = true;

                for ($j = $i + 1; $j < $count; ++$j) {
                    if (!$segments[$j]->optional) {
                        $optional = false;
                        break;
                    }
                }

                if ($optional) {
                    $segments[$i - 1]->preEnd = true;
                }
                else {
                    for (--$j, $jc = $i - 1; $j >= $jc; --$j) {
                        $segments[$j]->optional = false;
                    }
                }
            }

            if ($i + 1 == $count) {
                $segments[$i]->end = true;
            }
        }
    }
711839
protected function buildUrl(array $segments = [])
    {
        //Get the base URL and add a ?
        $url = $this->apiBase.'?';

        if (isset($this->apiEnding)) {
            $segments = array_merge($segments, $this->apiEnding);
        }

        foreach ($segments as $key => $value) {
            $url = $url."$key=$value&";
        }

        //Remove the final &
        $url = substr($url, 0, -1);

        return $url;
    }
1362547
protected function addSegment(Segment $segment)
    {
        if (!$segment->getSegment() && $this->segmentName) {
            $segment->setSegment($this->segmentName);
        }

        if (!$segment->getType()) {
            $metricTypes = array(self::TYPE_NUMBER, self::TYPE_FLOAT, self::TYPE_MONEY, self::TYPE_DURATION_S, self::TYPE_DURATION_MS);
            if (in_array($this->getType(), $metricTypes, $strict = true)) {
                $segment->setType(Segment::TYPE_METRIC);
            } else {
                $segment->setType(Segment::TYPE_DIMENSION);
            }
        }

        if (!$segment->getCategoryId() && $this->category) {
            $segment->setCategory($this->category);
        }

        if (!$segment->getName() && $this->nameSingular) {
            $segment->setName($this->nameSingular);
        }

        $sqlSegment = $segment->getSqlSegment();

        if (empty($sqlSegment) && !$segment->getUnionOfSegments()) {
            if (!empty($this->sqlSegment)) {
                $segment->setSqlSegment($this->sqlSegment);
            } elseif ($this->dbTableName && $this->columnName) {
                $segment->setSqlSegment($this->dbTableName . '.' . $this->columnName);
            } else {
                throw new Exception('Segment cannot be added because no sql segment is set');
            }
        }

        if (!$this->suggestedValuesCallback) {
            // we can generate effecient value callback for enums automatically
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $this->suggestedValuesCallback = function ($idSite, $maxValuesToReturn) use ($enum) {
                    $values = array_values($enum);
                    return array_slice($values, 0, $maxValuesToReturn);
                };
            }
        }

        if (!$this->acceptValues) {
            // we can generate accept values for enums automatically
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $enumValues = array_values($enum);
                $enumValues = array_slice($enumValues, 0, 20);
                $this->acceptValues = 'Eg. ' . implode(', ', $enumValues);
            };
        }

        if ($this->acceptValues && !$segment->getAcceptValues()) {
            $segment->setAcceptedValues($this->acceptValues);
        }

        if (!$this->sqlFilterValue && !$segment->getSqlFilter() && !$segment->getSqlFilterValue()) {
            // no sql filter configured, we try to configure automatically for enums
            $enum = $this->getEnumColumnValues();
            if (!empty($enum)) {
                $this->sqlFilterValue = function ($value, $sqlSegmentName) use ($enum) {
                    if (isset($enum[$value])) {
                        return $value;
                    }

                    $id = array_search($value, $enum);

                    if ($id === false) {
                        $id = array_search(strtolower(trim(urldecode($value))), $enum);

                        if ($id === false) {
                            throw new \Exception("Invalid '$sqlSegmentName' segment value $value");
                        }
                    }

                    return $id;
                };
            };
        }

        if ($this->suggestedValuesCallback && !$segment->getSuggestedValuesCallback()) {
            $segment->setSuggestedValuesCallback($this->suggestedValuesCallback);
        }

        if ($this->sqlFilterValue && !$segment->getSqlFilterValue()) {
            $segment->setSqlFilterValue($this->sqlFilterValue);
        }

        if ($this->sqlFilter && !$segment->getSqlFilter()) {
            $segment->setSqlFilter($this->sqlFilter);
        }

        if (!$this->allowAnonymous) {
            $segment->setRequiresAtLeastViewAccess(true);
        }

        $this->segments[] = $segment;
    }
780337
public static function root($segments = null): string
    {
        $path = __DIR__;
        for ($c1 = 0; $c1 < 4; $c1++) {
            $path = dirname($path);
        }
        $path = str_replace('\\', '/', $path);
        $path = self::addSegmentsToPath($path, $segments);
        return $path;
    }
312534
protected function splitSegment($segment)
    {
        $parts = preg_split('/\+(?<!\?\+)/', $segment);

        foreach ($parts as &$part) {
            $part = str_replace('?+', '+', $part);
        }

        return $parts;
    }
67997
protected function buildSegments(array $segments)
    {
        $pattern  = "";
        $patterns = [];
        $wildcardTokens = array_keys($this->wildcards);
        $wildcardRegex  = $this->wildcards;

        foreach ($segments as $n => $segment) {
            if ($segment === "" && $n !== 0) {
                throw new BadRouteException(BadRouteException::EMPTY_OPTIONAL_PARTS);
            }

            $patterns[] = $pattern .= str_replace($wildcardTokens, $wildcardRegex, $segment);
        }

        return $patterns;
    }
695904
public function parse(&$segments)
    {
        $vars = array();

        if (empty($segments)) {
            $vars['view'] = $this->getIdentifier()->package;
        } elseif (count($segments) == 1) {
            $identifier = array_pop($segments);

            if (is_numeric($identifier)) {
                $vars['id'] = (int) $identifier;
            } else {
                $vars['alias'] = $identifier;
            }

            $vars['view'] = AnInflector::singularize($this->getIdentifier()->package);
        }

        return $vars;
    }
5146
public function addSegment($segment, $other = null){
		if(!$segment instanceof Segment){
			$segment = new Segment($segment);
		}
		if($this->getIndexOf($segment->getName())) throw new \Exception('Section with this name already exists');
		if($other){
			if(($index = $this->getIndexOf($other))===false) throw new \Exception('Segment not found');
			array_splice($this->segments, $index, 0, [$segment]);
		}else{
			$this->segments[] = $segment;
		}
		return $segment;
	}
340680
public function delocalizeSegments(array &$segments)
    {
        if (count($segments) > 0) {
            $locale = $segments[0];
            if ($this->localeHelper->isValidLocale($locale)) {
                array_shift($segments);
            }
        }
    }