Handles interactions pages
Provides a uniform endpoint to retrieve comments/likes

stream/comments/<entity_guid>/[<comment_guid>]
stream/likes/<entity_guid>
stream/edit/<entity_guid>

@param array $segments URL segments
@return boolean
498078
public static function handleStream($segments) {

		$page = array_shift($segments);
		$guid = array_shift($segments);

		switch ($page) {

			case 'comments' :

				$comment_guid = array_shift($segments);
				set_input('entity_guid', $guid);
				set_input('comment_guid', $comment_guid);
				echo elgg_view_resource('interactions/comments', [
					'guid' => $guid,
					'comment_guid' => $comment_guid
				]);
				return true;

			case 'likes' :
				set_input('guid', $guid);
				echo elgg_view_resource('interactions/likes', [
					'guid' => $guid,
				]);
				return true;

			case 'edit' :
				set_input('guid', $guid);
				echo elgg_view_resource('interactions/edit', [
					'guid' => $guid,
				]);
				return true;

			case 'view' :
				set_input('guid', $guid);
				echo elgg_view_resource('interactions/view', [
					'guid' => $guid,
				]);
				return true;
		}

		return false;
	}
295112
private function getDynamicRouteIds(array $segments): array
    {
        $matched = [];
        $index = 0;

        do {
            $matched[] =
                $this->provider->getRoutesBySegmentValue($index, $segments[$index]) +
                $this->provider->getRoutesBySegmentValue($index, RouteDefinition::DYNAMIC_SEGMENT);
            $index++;
        } while (isset($segments[$index]));

        $matched[] = $this->provider->getRoutesBySegmentCount(\count($segments));

        return array_values(array_intersect_key(... $matched));
    }
55643
protected function _validateRequest($segments){

		if(count($segments) == 0){
			$segments = [
				$this->getConfig('default_controller'),
				$this->getConfig('default_method')
			];
		}
		
		$controller_path = $this->app_path.$this->getConfig('controller_folder').DS;

		// Does the requested controller exist in the root folder?
		if (file_exists($controller_path.ucfirst($segments[0]).$this->getConfig('class_surfix').'.php')){
			return $segments;
		}

		// Is the controller in a sub-folder?
		if (is_dir($controller_path.$segments[0])){
			// Set the directory and remove it from the segment array
			$this->set_directory($segments[0]);

			$segments = array_slice($segments, 1);

			if (count($segments) > 0){
				// Does the requested controller exist in the sub-folder?
				if ( ! file_exists($controller_path.$this->directory.$segments[0].$this->getConfig('class_surfix').'.php')){
					if ( ! $this->getConfig('404_override')){
						$x = explode('/', $this->getConfig('404_override'));
						$this->set_directory('');
						$this->setClass($x[0]);
						$this->method = isset($x[1]) ? $x[1] : 'index';

						return $x;
					}
					else{
						show_404($this->fetch_directory().$segments[0]);
					}
				}
			}
			else
			{
				// Is the method being specified in the route?
				if (strpos($this->class, '/') !== FALSE)
				{
					$x = explode('/', $this->default_controller);

					$this->setClass($x[0]);
					$this->method = $x[1];
				}

				// Does the default controller exist in the sub-folder?
				if ( ! file_exists($controller_path.$this->directory.$this->class.'.php'))
				{
					$this->directory = '';
					return [];
				}

			}

			return $segments;
		}
	}
1158591
private function processService(array &$segments): array
    {
        // init
        $processed = [];

        foreach ($segments as &$seg) {
            $jsonsegment = $this->processSegment($seg, $this->xmlSvc, null);
            $processed[$jsonsegment['key']] = $jsonsegment['value'];
        }

        return $processed;
    }
819332
public function parse(&$segments)
    {
        $path = implode('/', $segments);

        if (empty($segments)) {
            $segments[] = 'email';
        }

        if (preg_match('#(connections|token)(/\w+)?#', $path)) {
            return array(
                'view' => array_shift($segments),
                'service' => pick('facebook', array_pop($segments)),
            );
        }

        return parent::parse($segments);
    }
258887
public function parse(&$segments)
    {
        $query = array();

        if (!count($segments)) {
            $query['view'] = 'packages';
        } else {
            $query = parent::parse($segments);
        }

        return $query;
    }
690810
protected function addDynamic($segment, $connector, $parameters, $index)
    {
        // Once we have parsed out the columns and formatted the boolean operators we
        // are ready to add it to this query as a where clause just like any other
        // clause on the query. Then we'll increment the parameter index values.
        $bool = strtolower($connector);
        $segment = mb_strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1'.'_', $segment));
        $this->where($segment, '=', $parameters[$index], $bool);
    }
330406
public static function getDoneFlags(array $plugins, Segment $segment)
    {
        $doneFlags = array();
        $doneAllPlugins = self::getDoneFlagArchiveContainsAllPlugins($segment);
        $doneFlags[$doneAllPlugins] = $doneAllPlugins;

        $plugins = array_unique($plugins);
        foreach ($plugins as $plugin) {
            $doneOnePlugin = self::getDoneFlagArchiveContainsOnePlugin($segment, $plugin);
            $doneFlags[$plugin] = $doneOnePlugin;
        }
        return $doneFlags;
    }
201496
public static function appendSegment($uri, string $segment)
    {
        $uri = self::filterUri($uri);

        return self::normalizePath($uri, (new HierarchicalPath($uri->getPath()))->append($segment));
    }
349437
protected function wrapSegments($segments)
    {
        return collect($segments)->map(function ($segment, $key) use ($segments) {
            return $key == 0 && count($segments) > 1
                            ? $this->wrapTable($segment)
                            : $this->wrapValue($segment);
        })->implode('.');
    }
151141
public function process_url_actions() {
        if (!$this->page->user_is_editing()) {
            return false;
        }
        return $this->process_url_add() || $this->process_url_delete() ||
            $this->process_url_show_hide() || $this->process_url_edit() ||
            $this->process_url_move();
    }
360817
public function usePageSectionsFromPageIds(array $pageIds = []): QueryBuilder
    {
        $filters = [];

        /** @var $processor PageUidToHierarchy */
        $processor = GeneralUtility::makeInstance(PageUidToHierarchy::class);
        $hierarchies = $processor->process($pageIds);

        foreach ($hierarchies as $hierarchy) {
            $lastLevel = array_pop($hierarchy);
            $filters[] = 'rootline:"' . $lastLevel . '"';
        }

        $pageSectionsFilterString = implode(' OR ', $filters);
        return $this->useFilter($pageSectionsFilterString, 'pageSections');
    }
1247940
def add_contact(self, segment_id, contact_id):
        

        response = self._client.session.post(
            '{url}/{segment_id}/contact/add/{contact_id}'.format(
                url=self.endpoint_url,
                segment_id=segment_id,
                contact_id=contact_id
            )
        )
        return self.process_response(response)
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;
    }
857355
public function getKnownSegmentsToArchiveForSite(&$segments, $idSite)
    {
        $model = new Model();
        $segmentToAutoArchive = $model->getSegmentsToAutoArchive($idSite);

        foreach ($segmentToAutoArchive as $segmentInfo) {
            $segments[] = $segmentInfo['definition'];
        }

        $segments = array_unique($segments);
    }
52824
private function addForeignConstraint($segments)
    {
        $string = sprintf(
            "%s:foreign:references('id'):on('%s')",
            $segments['name'],
            $this->getTableNameFromForeignKey($segments['name'])
        );

        $this->addField($this->parseSegments($string));
    }
1038520
private function checkId(Segment $segment, $id)
    {
        $user = $this->usersRepository->find($id);
        if (!$user) {
            return false;
        }
        return $segment->isIn('id', $id);
    }