Return all of the section route rules

@param string   $format 'Craft'|'React'|'Vue'
@param int|null $siteId

@return array
426460
public function getAllSectionRouteRules(string $format = 'Craft', $siteId = null): array
    {
        $routeRules = [];
        // Get all of the sections
        $sections = Craft::$app->getSections()->getAllSections();
        foreach ($sections as $section) {
            $routes = $this->getSectionRouteRules($section->handle, $format, $siteId);
            if (!empty($routes)) {
                $routeRules[$section->handle] = $routes;
            }
        }

        return $routeRules;
    }
112429
public function getHeaders($filename, $format = self::FORMAT_GUZZLE) {

        $rawHeaders = $this->getFile($filename);

        preg_match_all('/(.+):\ (.+)/i', $rawHeaders, $matches);

        // Curl format
        if($format == self::FORMAT_CURL) return $matches[0];

        // Guzzle format
        $headers = array();

        foreach($matches[0] as $i => $matche) {
            $headers[$matches[1][$i]] = $matches[2][$i];
        }

        return $headers;
    }
44398
public function getCategoryUrls(string $category, array $criteria = [], $siteId = null): array
    {
        return RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId);
    }
959557
public function getDataBySiteIdAndEnv($siteId, $siteEnv) 
	{
	    $select = $this->tableGateway->getSql()->select();
	    
	    $select->columns(array('*'));
	    
	    $select->where(array("sdom_site_id" => $siteId, 'sdom_env' => $siteEnv));
	    $resultSet = $this->tableGateway->selectWith($select);
	    
	    return $resultSet;
	}
428761
public function getElementUrls($elementType, array $criteria = [], $siteId = null): array
    {
        $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
        $cache = Craft::$app->getCache();

        // Merge in the $criteria passed in
        $criteria = array_merge([
            'siteId' => $siteId,
            'limit'  => null,
        ], $criteria);
        // Set up our cache criteria
        $elementClass = \is_object($elementType) ? \get_class($elementType) : $elementType;
        $cacheKey = $this->getCacheKey($this::ROUTEMAP_ELEMENT_URLS, [$elementClass, $criteria, $siteId]);
        $duration = $devMode ? $this::DEVMODE_ROUTEMAP_CACHE_DURATION : $this::ROUTEMAP_CACHE_DURATION;
        $dependency = new TagDependency([
            'tags' => [
                $this::ROUTEMAP_CACHE_TAG,
            ],
        ]);

        // Just return the data if it's already cached
        $urls = $cache->getOrSet($cacheKey, function () use ($elementClass, $criteria) {
            Craft::info(
                'Route Map cache miss: '.$elementClass,
                __METHOD__
            );
            $resultingUrls = [];

            // Get all of the entries in the section
            $query = $this->getElementQuery($elementClass, $criteria);
            $elements = $query->all();

            // Iterate through the elements and grab their URLs
            foreach ($elements as $element) {
                if ($element instanceof Element
                    && $element->uri !== null
                    && !\in_array($element->uri, $resultingUrls, true)
                ) {
                    $uri = $this->normalizeUri($element->uri);
                    $resultingUrls[] = $uri;
                }
            }

            return $resultingUrls;
        }, $duration, $dependency);

        return $urls;
    }
829654
private function getResourceLookup($format)
    {
        if(in_array($format, self::$formats)){
            if(!isset($this->lookups)){
                $this->lookups = [
                    'list' => $this->getServiceManager()->get(ListResourceLookup::SERVICE_ID),
                    'tree' => $this->getServiceManager()->get(TreeResourceLookup::SERVICE_ID)
                ];
            }
            return $this->lookups[$format];
        }
        return null;
    }
972569
public function getAllPageIdsAndNamesBySiteThenType($siteId, $type)
    {
        $queryBuilder = $this->_em->createQueryBuilder();

        $queryBuilder->select('page.name, page.pageId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.site', 'site')
            ->where('page.pageType = :pageType')
            ->andWhere('site.siteId = :siteId')
            ->setParameter('pageType', $type)
            ->setParameter('siteId', $siteId);

        $result = $queryBuilder->getQuery()->getArrayResult();

        if (empty($result)) {
            return null;
        }

        $return = [];

        foreach ($result as &$page) {
            $return[$page['pageId']] = $page['name'];
        }

        return $return;
    }
620080
public function getRouteRules($siteId = null, $includeGlobal = true): array
    {
        $globalRules = $includeGlobal === true ? $this->getDbRoutes('global') : [];

        $siteRoutes = $this->getDbRoutes($siteId);

        $rules = array_merge(
            Craft::$app->getRoutes()->getConfigFileRoutes(),
            $globalRules,
            $siteRoutes
        );

        return $rules;
    }
1180048
public function getVisitorProfile($visitorId, $arguments = [], $format = null)
    {
        $arguments = array_add($arguments, 'visitorId', $visitorId);
        $options = $this->getOptions($format)->setArguments($arguments);

        return $this->request->send($options);
    }
1252862
public function getSectionRouteRules(string $section, string $format = 'Craft', $siteId = null): array
    {
        $devMode = Craft::$app->getConfig()->getGeneral()->devMode;
        $cache = Craft::$app->getCache();

        // Set up our cache criteria
        $cacheKey = $this->getCacheKey($this::ROUTEMAP_SECTION_RULES, [$section, $format, $siteId]);
        $duration = $devMode ? $this::DEVMODE_ROUTEMAP_CACHE_DURATION : $this::ROUTEMAP_CACHE_DURATION;
        $dependency = new TagDependency([
            'tags' => [
                $this::ROUTEMAP_CACHE_TAG,
            ],
        ]);

        // Just return the data if it's already cached
        $routes = $cache->getOrSet($cacheKey, function () use ($section, $format, $siteId) {
            Craft::info(
                'Route Map cache miss: '.$section,
                __METHOD__
            );
            $resultingRoutes = [];

            $section = Craft::$app->getSections()->getSectionByHandle($section);
            if ($section) {
                $sites = $section->getSiteSettings();

                foreach ($sites as $site) {
                    if ($site->hasUrls && ($siteId === null || $site->siteId === $siteId)) {
                        // Get section data to return
                        $route = [
                            'handle'   => $section->handle,
                            'siteId'   => $site->siteId,
                            'type'     => $section->type,
                            'url'      => $site->uriFormat,
                            'template' => $site->template,
                        ];

                        // Normalize the routes based on the format
                        $resultingRoutes[$site->siteId] = $this->normalizeFormat($format, $route);
                    }
                }
            }
            // If there's only one siteId for this section, just return it
            if (\count($resultingRoutes) === 1) {
                $resultingRoutes = reset($resultingRoutes);
            }

            return $resultingRoutes;
        }, $duration, $dependency);

        return $routes;
    }
474567
public function getActivePageThemeForSite($pageId, $themeId, $siteId = null, $mode = AbstractQuery::HYDRATE_OBJECT)
    {
        /** @var $query \Doctrine\ORM\QueryBuilder */
        try {
            $qb     = $this->getEntityManager()->createQueryBuilder();
            $params = [
                ':pageId'      => $pageId,
                ':active'      => 1,
                ':siteThemeId' => $themeId,
            ];
            $query  = $qb->select('e, p, t')
                ->from($this->getEntity(), 'e')
                ->innerJoin('e.template', 't')
                ->innerJoin('t.theme', 'th')
                ->innerJoin('e.page', 'p')
                ->where('e.page = :pageId')
                ->setParameters($params);

            if (is_numeric($themeId)) {
                $query->andWhere('t.theme = :siteThemeId');
            } else {
                $query->andWhere('th.slug = :siteThemeId');
            }

            $query->andWhere('e.isActive = :active');

            if ($siteId) {
                //$this->disableSiteFilter();
                $query->andWhere($query->expr()->eq('e.site', $siteId));
            }

            $query->setMaxResults(1);
            $result = $query->getQuery()->getOneOrNullResult($mode);

            return $result;
        } catch (\Exception $exception) {
            $this->getLogger()->logException($exception);

            return null;
        }
    }
784108
public function actionGetSectionUrls(string $section, array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId));
    }
402633
public function getSiteInfo($siteId)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select(
            'partial site.{
                owner,
                theme,
                status,
                favIcon,
                loginPage,
                notAuthorizedPage,
                siteLayout,
                siteTitle,
                siteId
            },
            language,
            country'
        )->from(\Rcm\Entity\Site::class, 'site')
            ->join('site.country', 'country')
            ->join('site.language', 'language')
            ->where('site.siteId = :siteId')
            ->setParameter('siteId', $siteId);

        try {
            return $queryBuilder->getQuery()->getSingleResult(
                Query::HYDRATE_ARRAY
            );
        } catch (NoResultException $e) {
            return null;
        }
    }
606982
public function findAllowedSites($siteId)
    {
        $qb = $this->createQueryBuilder();
        $qb->field('allowedSites')->in(array($siteId));

        return $qb->getQuery()->execute();
    }
1010581
public function getRedirectList($siteId)
    {
        try {
            $result = $this->getQuery($siteId)->getResult();
        } catch (NoResultException $e) {
            $result = [];
        }

        return $result;
    }
1257342
public function selectTypeAction($siteId = null)
    {
        $contentTypes = $this->get('opifer.content.content_type_manager')->getRepository()->findAll();

        $layouts = $this->get('opifer.content.content_manager')->getRepository()->findBy(['layout' => true]);

        if (!$contentTypes) {
            return $this->redirectToRoute('opifer_content_content_create');
        }

        return $this->render($this->getParameter('opifer_content.content_select_type'), [
            'content_types' => $contentTypes,
            'site_id' => $siteId,
            'layouts' => $layouts
        ]);
    }
310359
public function findByPathAndSite($path, $siteId)
    {
        $qb = $this->createQueryBuilder();
        $qb->field('siteId')->equals($siteId)
            ->field('path')->equals(new \MongoRegex('/^'.$path.'(\/.*)?$/'));

        return $qb->getQuery()->execute();
    }