Returns a block by its ID.

@param int      $blockId The Super Table block’s ID.
@param int|null $siteId  The site ID to return. Defaults to the current site.

@return SuperTableBlock|null The Super Table block, or `null` if it didn’t exist.
481641
public function getBlockById(int $blockId, int $siteId = null)
    {
        /** @var SuperTableBlock|null $block */
        $block = Craft::$app->getElements()->getElementById($blockId, SuperTableBlockElement::class, $siteId);

        return $block;
    }
448213
public function deploySite($serverId, $siteId, $wait = true)
    {
        $this->post("servers/$serverId/sites/$siteId/deployment/deploy");

        if ($wait) {
            $this->retry($this->getTimeout(), function () use ($serverId, $siteId) {
                return is_null($this->site($serverId, $siteId)->deploymentStatus);
            });
        }
    }
790262
public function countChildren($parentId, $siteId)
    {
        $qa = $this->createAggregationQuery();
        $qa->match(
            array(
                'siteId'     => $siteId,
                'parent.$id' => new \MongoId($parentId)
            )
        );

        return $this->countDocumentAggregateQuery($qa);
    }
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;
        }
    }
313766
protected function iblockGetIdByCode($code, $siteId = null)
    {
        $siteId = $siteId ?: $this->iblockGetDefaultSiteId();
        $res = CIBlock::getList([], [
            'CODE' => $code,
            'CHECK_PERMISSIONS' => 'N',
            'SITE_ID' => $siteId,
        ]);
        $iblock = $res->fetch();

        return !empty($iblock['ID']) ? $iblock['ID'] : null;
    }
1035059
public BlockMeta getBlockMeta(long blockId) throws BlockDoesNotExistException {
    BlockMeta blockMeta = mBlockIdToBlockMap.get(blockId);
    if (blockMeta == null) {
      throw new BlockDoesNotExistException(ExceptionMessage.BLOCK_META_NOT_FOUND, blockId);
    }
    return blockMeta;
  }
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;
    }
56938
public function getSiteByRootPageId($rootPageId)
    {
        $cacheId = 'SiteRepository' . '_' . 'getSiteByPageId' . '_' . $rootPageId;

        $methodResult = $this->runtimeCache->get($cacheId);
        if (!empty($methodResult)) {
            return $methodResult;
        }

        $methodResult = $this->buildSite($rootPageId);
        $this->runtimeCache->set($cacheId, $methodResult);

        return $methodResult;
    }
403594
public function getPerimeterConfiguration($siteId)
    {
        $treeNodes = $this->nodeRepository->findTreeNode(
            $siteId,
            $this->contextManager->getSiteContributionLanguage(),
            NodeInterface::ROOT_PARENT_ID
        );

        return $this->getTreePerimeterConfiguration($treeNodes);
    }
211102
protected function getSiteName($sites, $site_id)
    {
        if ($site = $this->getSite($sites, $site_id)) {
            return $site->name;
        }
        return null;
    }
1336279
protected function getDbRoutes($siteId = null): array
    {
        if ($siteId === null) {
            $siteId = Craft::$app->getSites()->currentSite->id;
        }
        if ($siteId === 'global') {
            $siteId = null;
        }
        // If we're on Craft 3.1 or later, just return the array from getProjectConfigRoutes();
        if (RouteMap::$craft31) {
            return Craft::$app->getRoutes()->getProjectConfigRoutes();
        }

        // Normalize the URL
        $results = (new Query())
            ->select(['uriPattern', 'template'])
            ->from(['{{%routes}}'])
            ->where([
                'or',
                ['siteId' => $siteId],
            ])
            ->orderBy(['sortOrder' => SORT_ASC])
            ->all();

        return ArrayHelper::map($results, 'uriPattern', function ($results) {
            return ['template' => $results['template']];
        });
    }
678296
public function find_instance($instanceid) {
        foreach ($this->regions as $region => $notused) {
            $this->ensure_instances_exist($region);
            foreach($this->blockinstances[$region] as $instance) {
                if ($instance->instance->id == $instanceid) {
                    return $instance;
                }
            }
        }
        throw new block_not_on_page_exception($instanceid, $this->page);
    }
320199
private function getRootView(BlockView $rootView, $rootId)
    {
        if ($rootId !== null) {
            $rootView = $this->findBlockById($rootView, $rootId);
            if ($rootView === null) {
                throw new BlockViewNotFoundException(sprintf("BlockView with id \"%s\" is not found.", $rootId));
            }
        }

        return $rootView;
    }
1233797
protected function getBlock($id)
    {
        $block = $this->blockManager->findOneBy(['id' => $id]);

        if (null === $block) {
            throw new NotFoundHttpException(sprintf('Block (%d) not found', $id));
        }

        return $block;
    }
544407
public function loadBlockData($blockId, int $status): array
    {
        $query = $this->getBlockSelectQuery();
        $query->where(
            $query->expr()->eq('b.id', ':id')
        )
        ->setParameter('id', $blockId, Type::INTEGER);

        $this->applyStatusCondition($query, $status, 'b.status');

        return $query->execute()->fetchAll(PDO::FETCH_ASSOC);
    }
482777
public static function preloadPageBlock($pageId, $blockId, $version = 0, $preloadBy = 'page_id')
    {
        ($preloadBy == 'page_id') ? static::_preloadDataByPage($pageId, $version) : static::_preloadDataByBlock($blockId, $version);
        return static::_preloadGet('byVersionPage', [$version, $pageId, $blockId]) ?: [];
    }
782690
public function getOnlyPageIdByName($siteId, $name, $pageType = PageTypes::NORMAL)
    {
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('page.pageId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->where('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->andWhere('page.site = :siteId')
            ->setParameter('pageName', $name)
            ->setParameter('pageType', $pageType)
            ->setParameter('siteId', $siteId);

        return $queryBuilder->getQuery()->getSingleScalarResult();
    }