@param string $siteId
@param string $name
@param Post[] $posts

@return Site
161659
public static function instance($siteId, $name, array $posts)
    {
        $site = new self();

        $site->siteId = $siteId;
        $site->name   = $name;
        $site->posts  = $posts;

        return $site;
    }
1320900
public function postSite(SitePostMessage $message): Site
    {
        $path = 'sites';
        $data = ['api_site' => $message->build()];

        $response = $this->getClient()->sendRequest('POST', $path, $data);

        /** @var Site $model */
        $model = $this->getModelFactory()->create(Site::class, $response);

        return $model;
    }
55213
public function buildPagesResourceId(
        $siteId
    ) {
        return $this->resourceName->get(
            ResourceName::RESOURCE_SITES,
            $siteId,
            ResourceName::RESOURCE_PAGES
        );
    }
868393
public function lookup($nodeId, $siteId)
    {
        if (!$this->isLoaded) {
            $this->load();
            $this->isLoaded = true;
        }

        // Build the array we will store at the end of the query if we have
        // anything changed during the request
        if ($this->queriedCount < self::MAX_CACHE_SIZE) {
            $this->queried[$nodeId][$siteId] = true;
        }
        $this->queriedCount++;

        if (!isset($this->loaded[$nodeId][$siteId])) {
            // We already have cached this path in the past, or it was not in
            // original cache source array, or it is non existing anymore or
            // outdated, our cache is broken, we need to lookup and update
            return $this->fetchAlias($nodeId, $siteId) ?? 'node/' . $nodeId;
        }

        // Best case scenario, it exists!
        return $this->loaded[$nodeId][$siteId];
    }
92
public static function clearCache($postId, $post)
    {
        if (wp_is_post_revision($postId) || get_post_status($postId) != 'publish') {
            return false;
        }

        wp_cache_delete($postId, self::getKeyGroup());
        wp_cache_delete($post->post_type, self::getKeyGroup());

        // Empty post type for all sites in network (?)
        if (function_exists('is_multisite') && is_multisite() && apply_filters('Municipio\Cache\EmptyForAllBlogs', false, $post)) {
            $blogs = get_sites();

            foreach ($blogs as $blog) {
                wp_cache_delete($post->post_type, self::getKeyGroup($blog->blog_id));
            }
        }

        return true;
    }
598112
public function getRevisionDbInfo($siteId, $name, $revisionId)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder()
            ->select(
                'container,'
                . 'publishedRevision.revisionId,'
                . 'revision,'
                . 'pluginWrappers,'
                . 'pluginInstances'
            )
            ->from(\Rcm\Entity\Container::class, 'container')
            ->leftJoin('container.publishedRevision', 'publishedRevision')
            ->leftJoin('container.site', 'site')
            ->leftJoin('container.revisions', 'revision')
            ->leftJoin('revision.pluginWrappers', 'pluginWrappers')
            ->leftJoin('pluginWrappers.instance', 'pluginInstances')
            ->where('site.siteId = :siteId')
            ->andWhere('container.name = :containerName')
            ->andWhere('revision.revisionId = :revisionId')
            ->orderBy('pluginWrappers.renderOrder', 'ASC')
            ->setParameter('siteId', $siteId)
            ->setParameter('containerName', $name)
            ->setParameter('revisionId', $revisionId);

        $getData = $queryBuilder->getQuery()->getSingleResult(
            Query::HYDRATE_ARRAY
        );

        $result = null;

        if (!empty($getData)) {
            $result = $getData[0];
            $result['revision'] = $result['revisions'][$revisionId];
            unset($result['revisions'], $getData);
        }

        return $result;
    }
1216612
public Post blogPost(String blogName, Long postId) {
        HashMap<String, String> options = new HashMap<String, String>();
        options.put("id", postId.toString());
        List<Post> posts = this.blogPosts(blogName, options);
        return posts.size() > 0 ? posts.get(0) : null;
    }
272701
public function deleteReferenceBulkFromSite($siteId, $nodeIdList)
    {
        if (!$nodeIdList) {
            return;
        }

        $this
            ->db
            ->delete('ucms_site_node')
            ->condition('nid', $nodeIdList)
            ->condition('site_id', $siteId)
            ->execute()
        ;

        $this
            ->entityManager
            ->getStorage('node')
            ->resetCache($nodeIdList)
        ;

        $this->eventDispatcher->dispatch(NodeEvents::ACCESS_CHANGE, new ResourceEvent('node', $nodeIdList));
        $this->eventDispatcher->dispatch(SiteEvents::EVENT_DETACH, new SiteAttachEvent($siteId, $nodeIdList));
    }
1160711
public function getDriveBySite($siteId)
    {
        $siteLocator  = "/sites/$siteId";
        $driveLocator = '/drive';
        $endpoint     = "$siteLocator$driveLocator";

        $response = $this
            ->graph
            ->createRequest('GET', $endpoint)
            ->execute();

        $status = $response->getStatus();

        if ($status != 200) {
            throw new \Exception();
        }

        $drive = $response->getResponseAsObject(Model\Drive::class);

        return new DriveProxy($this->graph, $drive);
    }
27305
public function makeDir($name, $parentID = 0)
    {
        $data = [
            'name'      => $name,
            'parent_id' => $parentID
        ];

        return $this->post('files/create-folder', $data, \false, 'file');
    }
583886
public function update($siteId, $data)
    {
        //ACCESS CHECK
        if (!$this->isAllowed(
            ResourceName::RESOURCE_SITES,
            'admin'
        )
        ) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_401);

            return $this->getResponse();
        }

        if (!is_array($data)) {
            throw new \Exception('Invalid data format');
        }

        /** @var \Doctrine\ORM\EntityManager $entityManager */
        $entityManager = $this->getEntityManager();

        /** @var \Rcm\Repository\Site $siteRepo */
        $siteRepo = $entityManager->getRepository(\Rcm\Entity\Site::class);

        if (!$siteRepo->isValidSiteId($siteId)) {
            $this->getResponse()->setStatusCode(Response::STATUS_CODE_400);

            return $this->getResponse();
        }

        /** @var \Rcm\Entity\Site $site */
        $site = $siteRepo->findOneBy(['siteId' => $siteId]);

        $newStatus = $site->getStatus();

        if ($data['status'] == 'D') {
            $newStatus = 'D';
        }
        if ($data['status'] == 'A') {
            $newStatus = 'A';
        }

        $site->setStatus($newStatus);

        $site->setModifiedByUserId(
            $this->getCurrentUserId(),
            "Update site status to {$newStatus} in " . get_class($this)
        );

        $entityManager->persist($site);
        $entityManager->flush($site);

        $this->siteVersionRepo->publish(
            new SiteLocator($site->getDomainName()),
            $this->getSiteManager()->siteToImmutableSiteContent($site),
            $this->getCurrentUserTracking()->getId(),
            __CLASS__ . '::' . __FUNCTION__,
            $site->getSiteId()
        );

        return new JsonModel($site);
    }
1181336
public function setSite($siteId, $siteName, $siteDefaultLanguage, array $languages)
    {
        $this->siteId = $siteId;
        $this->session->set(
            self::KEY_SITE,
            array(
                'siteId' => $siteId,
                'name' => $siteName,
                'defaultLanguage' => $siteDefaultLanguage,
                'languages' => $languages,
            )
        );
    }
906939
public function postAddressBooks($name, $visibility = 'Public')
    {
        $data = [
            'Name' => $name,
            'Visibility' => $visibility,
        ];
        $url = $this->getApiEndpoint() . self::REST_ADDRESS_BOOKS;
        $this->setUrl($url)
            ->setVerb('POST')
            ->buildPostBody($data);

        $response = $this->execute();

        if (isset($response->message)) {
            $this->helper->debug('postAddressBooks', $data);
        }

        return $response;
    }
961526
public function cloneMenu(int $menuId, int $siteId, string $name): Tree
    {
        $source = $this->menuStorage->load($menuId);
        $values = [
            'title'       => $source->getTitle(),
            'description' => $source->getDescription(),
            'site_id'     => $siteId,
        ];
        $target = $this->menuStorage->create($name, $values);

        return $this->cloneTreeIn($target->getId(), $this->buildTree($menuId));
    }
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;
    }
272961
public static function nPost(string $name, $data, $workerID = -1)
    {
        $task = TaskParser::getInstance()->getTask($name);
        $paramClass = $task['Task']->paramClass;
        return static::post(new TaskInfo(new $task['className'], new $paramClass($data)), $workerID);
    }
223300
public function findOneByProductIdAndWebsite($productId, $websiteId)
    {

        // prepare the params
        $params = array(
            MemberNames::PRODUCT_ID => $productId,
            MemberNames::WEBSITE_ID => $websiteId
        );

        // load and return the product with the passed product/website ID
        $this->productWebsiteStmt->execute($params);
        return $this->productWebsiteStmt->fetch(\PDO::FETCH_ASSOC);
    }