Finds services for the given $urls.

@param array $urls An array with all the available urls
@return array An Array with loaded services
320005
protected function findServices(array $urls = array())
    {
        $return = array();
        $this->extractCustomParams($this->config['custom_params']);
        foreach (array_unique($urls) as $u) {

            try {
                $host = $this->getHost($u);
                if (isset($this->services[$host])) {
                    $provider = new \ReflectionClass($this->services[$host]);
                    $return[$u] = $provider->newInstance($u, $this->config, $this->oembed);

                    if (isset($this->customParams[$host])) {
                        $return[$u]->appendParams($this->customParams[$host]);
                    }
                }
            } catch (\Exception $e) {
                //echo $e->getMessage() . PHP_EOL;
            }
        }

        return $return;
    }
1016219
public function collectDataServices(array $services) {
    $todo_services = [];
    foreach ($services as $priority => $allservices) {
      /*
       * @var integer $key
       * @var OpenyDataServiceInterface $service
       */
      foreach ($allservices as $key => $service) {
        foreach ($service->addDataServices($todo_services) as $method) {
          $this->services[$method][$priority] = $service;
          krsort($this->services[$method]);
        }
      }
    }
  }
1185357
protected function normalizeStaticRoutes(array $routes)
    {
        foreach (\array_keys($routes) as $key) {
            // If any of the keys are  an HTTP method then we are running on a newer version of
            // Lumen and FastRoute which means we can leave the routes as they are.
            if ($this->stringIsHttpMethod($key)) {
                return $routes;
            }
        }

        $normalized = [];

        // To normalize the routes we'll take the inner array which contains the routes method as the
        // key and make that the parent element on the array. We'll then add all routes for a
        // particular HTTP method as children of it by keying them to their URI.
        foreach ($routes as $uri => $value) {
            foreach ($value as $method => $route) {
                $normalized[$method][$uri] = $route;
            }
        }

        return $normalized;
    }
680473
public static function getRoutesFromSettings(array $settings): array{
        $routes = [];
        foreach ($settings['routing'] as $method => $urls) {
            if (!isset($routes[$method])) {
                $routes[$method] = [];
            }
            foreach ($urls as $url) {
                array_push($routes[$method], (array)$url);
            }
        }
        return $routes;
    }
612442
public function batchSearch(array $queries) {
        $requests = [];

        foreach ($queries as $query) {
            $requests[] = [
                'method' => 'idoit.search',
                'params' => [
                    'q' => $query
                ]
            ];
        }

        return $this->api->batchRequest($requests);
    }
906829
public function findFiltered(array $filters)
    {
        /* @var Unit[] $units */
        if (!isset($filters['domain']) || is_null($filters['domain']) || empty($filters['domain'])) {
            $units = $this->findAll();
        } else {
            $units = $this->findByDomain($filters['domain']);
        }

        foreach ($units as $k => $u) {
            $filterEmpty = isset($filters['empty']) && $filters['empty'];
            $filterKey = isset($filters['key']) && strlen(trim($filters['key'])) > 0 ? trim($filters['key']) : null;
            $filterValue = isset($filters['value']) && strlen(trim($filters['value'])) > 0 ? trim($filters['value']) : null;
            if (empty($filters['locale'])) {
                $filters['locale'] = $this->getLocaleList();
            }

            if ($filterKey && strpos($u->getKey(), $filterKey) === false) {
                unset($units[$k]);
                continue;
            }

            $nonEmptyCount = 0;
            $valueCount = 0;
            foreach ($u->getTranslations() as $t) {
                // Remove translations not required
                if (!in_array($t->getLocale(), $filters['locale'])) {
                    unset($u[$t->getLocale()]);
                    continue;
                }

                // Count empty or match values
                $value = $t->getValue();
                if ($value !== null && strlen($value) > 0) {
                    ++$nonEmptyCount;
                }
                if ($filterValue && strpos($value, $filterValue) !== false) {
                    ++$valueCount;
                }
            }

            // For empty filtering, remove unit with non empty translations
            if ($filterEmpty && $nonEmptyCount >= count($filters['locale'])) {
                unset($units[$k]);
                continue;
            }

            // For value filtering, remove unit when there is no match
            if ($filterValue && $valueCount == 0) {
                unset($units[$k]);
                continue;
            }
        }

        return $units;
    }
905674
public function collectCronServices(array $services) {
    /** @var OpenyCronServiceInterface $service */
    foreach ($services as $periodicity => $service) {
      $this->cronServices[$periodicity] = $service;
    }
  }
1317098
private function getTrackerHosts($urls)
    {
        $hosts = array();
        foreach ($urls as $url) {
            $url = parse_url($url);
            if (isset($url['host'])) {
                $hosts[] = $url['host'];
            }
        }
        return $hosts;
    }
1042878
public function crawl( $url ) {

		$this->parse($url);

		while( $url = array_shift($this->sitemaps) ) {

			$this->parse($url);
		}

		return $this->urls;
	}
909048
protected function setUrls (array $urls)
	{
		foreach ($urls as $key => $value) $this->urls[$key] = $value;
	}
537717
public function findAll(array $locations = [])
    {
        if (empty($locations)) {
            $locations = $this->lookupPaths;
        }

        $finder = new Finder;
        $finder->directories()->depth(0)->sortByName()->in($locations);

        return iterator_to_array($finder, true);
    }
638918
public function setReturnUrls(array $returnUrls)
    {
        foreach ($returnUrls as $key => $returnUrl) {
            $this->returnUrls[$key] = $this->parseUrl($returnUrl);
        }
    }
767492
public function getAlternateLinks($urls)
    {
        // determine default and current values
        $webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
        $currentPortal = $this->requestAnalyzer->getPortal();

        $defaultLocale = null;
        if (null !== $currentPortal && null !== ($defaultLocale = $currentPortal->getXDefaultLocalization())) {
            $defaultLocale = $defaultLocale->getLocale();
        }

        $result = [];
        foreach ($urls as $locale => $url) {
            // url = '/' means that there is no translation for this page
            // the only exception is the homepage where the requested resource-locator is '/'
            if ('/' !== $url || '/' === $this->requestAnalyzer->getResourceLocator()) {
                if ($locale === $defaultLocale) {
                    $result[] = $this->getAlternate($url, $webspaceKey, $locale, true);
                }
                $result[] = $this->getAlternate($url, $webspaceKey, $locale);
            }
        }

        return implode(PHP_EOL, $result);
    }
1256419
public function list(array $filters = [])
    {
        $data = [
            'filters' => json_encode($filters),
        ];

        $url = $this->url.'?'.http_build_query($data);

        return $this->curl->get($url);
    }
318445
public function areLinksDead( $urls ) {
		// Create multiple curl handle
		$multicurl_resource = curl_multi_init();
		if ( $multicurl_resource === false ) {
			return null;
		}
		$deadLinks = [];
		$this->queueRequests( $urls );
		if ( $this->verbose === true ) {
			if ( count( $this->curlQueue ) > 1 ) {
				echo "Delaying one or more links!\n";
			}
		}
		foreach ( $this->curlQueue as $urls ) {
			$curl_instances = [];
			// Array of URLs we want to send in for a full check
			$fullCheckURLs = [];
			foreach ( $urls as $id => $url ) {
				if ( $this->getRequestType( $this->sanitizeURL( $url ) ) != "UNSUPPORTED" ) {
					$curl_instances[$id] = curl_init();
					if ( $curl_instances[$id] === false ) {
						return null;
					}
					// Get appropriate curl options
					curl_setopt_array(
						$curl_instances[$id],
						$this->getCurlOptions( $this->sanitizeURL( $url ), false )
					);
					// Add the instance handle
					curl_multi_add_handle( $multicurl_resource, $curl_instances[$id] );
				} elseif ( $this->verbose === true ) {
					echo "$url is not supported!\n";
				}
			}
			// Let's do the curl operations
			$active = null;
			do {
				$mrc = curl_multi_exec( $multicurl_resource, $active );
			} while ( $mrc == CURLM_CALL_MULTI_PERFORM );
			while ( $active && $mrc == CURLM_OK ) {
				if ( curl_multi_select( $multicurl_resource ) == -1 ) {
					// To prevent CPU spike
					usleep( 100 );
				}
				do {
					$mrc = curl_multi_exec( $multicurl_resource, $active );
				} while ( $mrc == CURLM_CALL_MULTI_PERFORM );
			}
			// Let's process our curl results and extract the useful information
			foreach ( $urls as $id => $url ) {
				if ( isset( $curl_instances[$id] ) ) {
					$headers = curl_getinfo( $curl_instances[$id] );
					$error = curl_errno( $curl_instances[$id] );
					$errormsg = curl_error( $curl_instances[$id] );
					$curlInfo = [
						'http_code' => $headers['http_code'],
						'effective_url' => $headers['url'],
						'curl_error' => $error,
						'curl_error_msg' => $errormsg,
						'url' => $this->sanitizeURL( $url ),
						'rawurl' => $url
					];
					// Remove each of the individual handles
					curl_multi_remove_handle( $multicurl_resource, $curl_instances[$id] );
					$curl_instances[$id] = null;
					// Deduce whether the site is dead or alive
					$deadLinks[$url] = $this->processCurlResults( $curlInfo, false );
					if ( $this->verbose === true ) {
						if ( $deadLinks[$url] === true ) {
							echo "$url is DEAD!\n";
						}
						if ( $deadLinks[$url] === false ) {
							echo "$url is ALIVE!\n";
						}
					}
					// If we got back a null, we should do a full page request
					if ( is_null( $deadLinks[$url] ) ) {
						$fullCheckURLs[] = $url;
					}
				} else {
					$deadLinks[$url] = null;
					if ( $this->verbose === true ) {
						echo "Something went wrong with $url!\n";
					}
				}
			}
			// Do full page requests for URLs that returned null
			if ( !empty( $fullCheckURLs ) ) {
				if ( $this->verbose === true ) {
					echo "Running a full check on:\n";
					foreach ( $fullCheckURLs as $url ) {
						echo "\t$url\n";
					}
				}
				$results = $this->performFullRequest( $fullCheckURLs );
				if ( $this->verbose === true ) {
					foreach ( $results as $url => $result ) {
						if ( $result === true ) {
							echo "$url is DEAD!\n";
						}
						if ( $result === false ) {
							echo "$url is ALIVE!\n";
						}
					}
				}
				// Merge back results from full requests into our deadlinks array
				$deadLinks = array_merge( $deadLinks, $results );
			}
			if ( count( $this->curlQueue ) > 1 ) {
				sleep( 1 );
			}
		}
		// Close resource
		curl_multi_close( $multicurl_resource );

		return $deadLinks;
	}
908289
public function find(Request $request, array $routes)
    {
        foreach ($routes as $route) {

            if(!$this->matchMethod($request, $route)){
                continue;
            }

            if(!$this->matchContentType($request, $route)){
                continue;
            }

            if(!$this->matchFilters($route)){
                continue;
            }

            $routeMatches = $this->matchPattern($request, $route);
            if ($routeMatches) {
                $route->setMatches($routeMatches);
                return $route;
            }
        }
        throw new RouteException(
            sprintf('No route found for uri "%s"', $request->getRequestUri()),
            $request,
            $routes
        );
    }
828905
protected function streamlineFilePaths(array $paths): array
    {
        $paths = \array_map(function ($url) {
            if (!GeneralUtility::isValidUrl($url) && ':' !== $url[0]) {
                $url = GeneralUtility::locationHeaderUrl($url);
            }

            return $url;
        }, $paths);

        $paths = \array_filter($paths, function ($path) {
            return GeneralUtility::isOnCurrentHost($path) && ':' !== $path[0];
        });

        $paths = \array_map(function ($url) {
            return '/' . \ltrim(\str_replace(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST'), '', $url), '/');
        }, $paths);

        return $paths;
    }