@param array $siteIds

@return int
335924
public function countFilterBySiteIds(array $siteIds)
    {
        $qa = $this->createAggregationQuery();
        $qa->match($this->getReferenceFilter('groups', $this->generateFilterSiteId($siteIds)));

        return $this->countDocumentAggregateQuery($qa);
    }
34906
public function flushErrorsBySite(Site $site) : int
    {
        $queryBuilder = $this->getQueryBuilder();
        $affectedRows = $this->getPreparedFlushErrorQuery($queryBuilder)
            ->andWhere(
                $queryBuilder->expr()->eq('root', (int)$site->getRootPageId())
            )
            ->execute();
        return $affectedRows;
    }
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;
    }
1064519
public function getProductsByModificationDate(\DateTimeInterface $modificationDate, int $siteId) : array
    {
        Assert::that($siteId)->greaterThan(0, 'The $siteId has to be positive');

        return (array)$this->master->doRequest(
            'GET',
            sprintf('/admin/WEBAPI/Endpoints/v1_0/ProductService/{KEY}/ByModificationDate/%s/%d', $modificationDate->format('Y-m-d'), $siteId)
        );
    }
18757
public function getSettingBySiteId($siteId)
    {
        /** @var $query QueryBuilder */
        $params = ['dataSource' => $siteId];
        $qb     = $this->getFindByQueryBuilder($params, null, 'e', ['id','settingValue']);
        $qb->addSelect('partial k.{id,code,defaultValue}')
            ->innerJoin('e.settingKey', 'k');

        return $qb->getQuery()->getResult();
    }
1348697
public function getSegmentsMetadata($siteIds, $format = null)
    {
        $idSites = implode(',', $siteIds);
        $arguments = [
            'idSites' => $idSites,
        ];
        $options = $this->getOptions($format)
            ->usePeriod(false)
            ->useSiteId(false)
            ->setArguments($arguments);

        return $this->request->send($options);
    }
211102
protected function getSiteName($sites, $site_id)
    {
        if ($site = $this->getSite($sites, $site_id)) {
            return $site->name;
        }
        return null;
    }
59365
public function count($blogId, array $params = array())
    {
        $endpoint = '/admin/blogs/'.$blogId.'/articles/count.json';
        $response = $this->request($endpoint, 'GET', $params);
        return $response['count'];
    }
1371985
public function setSiteTemplates($siteId, $templates = array()) {
        $sort = 150;

        $validTemplates = array();
        foreach ($templates as $template) {
            if (!empty($template['IN_DIR'])) {
                $template['CONDITION'] = sprintf('CSite::InDir(\'%s\')',
                    $template['IN_DIR']
                );
            } elseif (!empty($template['IN_PERIOD']) && is_array($template['IN_PERIOD'])) {
                list($t1, $t2) = $template['IN_PERIOD'];
                $t1 = is_numeric($t1) ? $t1 : strtotime($t1);
                $t2 = is_numeric($t2) ? $t2 : strtotime($t2);
                $template['CONDITION'] = sprintf('CSite::InPeriod(%s,%s)',
                    $t1,
                    $t2
                );
            } elseif (!empty($template['IN_GROUP']) && is_array($template['IN_GROUP'])) {
                $template['CONDITION'] = sprintf('CSite::InGroup(array(%s))',
                    implode(',', $template['IN_GROUP'])
                );
            } elseif (!empty($template['GET_PARAM']) && is_array($template['GET_PARAM'])) {
                $val = reset($template['GET_PARAM']);
                $key = key($template['GET_PARAM']);
                $template['CONDITION'] = sprintf('$_GET[\'%s\']==\'%s\'',
                    $key,
                    $val
                );
            }

            if (empty($template['TEMPLATE'])) {
                continue;
            }

            if (!isset($template['CONDITION'])) {
                continue;
            }

            $validTemplates[] = array(
                'TEMPLATE' => $template['TEMPLATE'],
                'CONDITION' => $template['CONDITION'],
                'SORT' => $sort
            );

            $sort++;
        }

        $langs = new \CLang;
        $ok = $langs->Update($siteId, array(
            'TEMPLATE' => $validTemplates
        ));

        return $ok;
    }
1161681
public function getPerimeterConfiguration($siteId)
    {
        $treeFolders = $this->folderRepository->findFolderTree($siteId);

        return $this->getTreePerimeterConfiguration($treeFolders);
    }
193358
public function setCurrentSite($siteId, $siteName, $siteDefaultLanguage, array $languages)
    {
        parent::setSite($siteId, $siteName, $siteDefaultLanguage, $languages);
    }
1326338
protected function writeSiteAliases($site_id, array $aliases) {

    if (!is_dir($this->siteAliasDir)) {
      mkdir($this->siteAliasDir);
    }
    $filePath = $this->siteAliasDir . '/' . $site_id . '.site.yml';
    if (file_exists($filePath)) {
      if (!$this->confirm("File $filePath already exists and will be overwritten. Continue?")) {
        throw new \Exception("Aborted at user request");
      }
    }

    file_put_contents($filePath, Yaml::dump($aliases));
    return $filePath;
  }
911504
public function getSiteDetails($siteId)
    {
        if ($this->connector->getURL() === null) {
            return 'Cannot find site URL from configuration.';
        }
        $url = $this->connector->getURL().self::VERSION.$siteId;
        $params = [];
        $response = $this->connector->connecting($url, $params, 'GET');

        return $response;
    }
750884
public function actionGetAllUrls(array $criteria = [], $siteId = null): Response
    {
        return $this->asJson(RouteMap::$plugin->routes->getAllUrls($criteria, $siteId));
    }
517072
protected function getSite($sites, $site_id)
    {
        $site_found = collect($sites)->filter(function ($site) use ($site_id) {
            return $site->id === $site_id;
        })->first();

        if ($site_found) {
            return $site_found;
        }
        return null;
    }
922099
private void countCoordinates(int xCoord, int yCoord,
			ItemDocument itemDocument) {

		for (String siteKey : itemDocument.getSiteLinks().keySet()) {
			Integer count = this.siteCounts.get(siteKey);
			if (count == null) {
				this.siteCounts.put(siteKey, 1);
			} else {
				this.siteCounts.put(siteKey, count + 1);
			}
		}

		for (ValueMap vm : this.valueMaps) {
			vm.countCoordinates(xCoord, yCoord, itemDocument);
		}
	}
312798
public function generatePerimeter($siteId)
    {
        $treeFolders = $this->folderRepository->findFolderTree($siteId);

        return $this->generateTreePerimeter($treeFolders);
    }