This method creating Site page

@param String $siteName
@param Int $fatherId
@param Int $siteLangId
@param String $pageType
@param Int $pageId
@param Int $templateId
@param Int $platformId
@return Int
330347
private function createSitePage($siteName, $fatherId, $siteLangId, $pageType, $pageId, $templateId, $platformId)
	{
	    // Event parameters prepare
	    $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args());
	    
	    // Sending service start event
	    $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_start', $arrayParameters);
	    
	    // Service implementation start
	   
	    $pageTreeTable = $this->getServiceLocator()->get('MelisEngineTablePageTree');
	    $pageLangTable = $this->getServiceLocator()->get('MelisEngineTablePageLang');
	    $pageSavedTable = $this->getServiceLocator()->get('MelisEngineTablePageSaved');
	    $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds');
	    
	    /**
	     * Retrieving the Current Page tree
	     * with Father Id of -1 "root node of the page tree"
	     * to get the Order of the new entry
	     */
	    $treePageOrder = $pageTreeTable->getTotalData('tree_father_page_id', $fatherId);
	    // Saving Site page on Page tree
	    $pageTreeTable->save(array(
	        'tree_page_id' => $arrayParameters['pageId'],
	        'tree_father_page_id' => $fatherId,
	        'tree_page_order' => $treePageOrder + 1,
	    ));
	     
	    // Saving Site page Language
	    $pageLangTable->save(array(
	        'plang_page_id' => $arrayParameters['pageId'],
	        'plang_lang_id' => $arrayParameters['siteLangId'],
	        'plang_page_id_initial' => $arrayParameters['pageId']
	    ));
	    
	    // Saving Site page in Save Version as new page entry
	    $pageSavedTable->save(array(
	        'page_id' => $arrayParameters['pageId'],
	        'page_type' => $arrayParameters['pageType'],
	        'page_status' => 1,
	        'page_menu' => 'LINK',
	        'page_name' => $arrayParameters['siteName'],
	        'page_tpl_id' => $arrayParameters['templateId'],
	        'page_content' => '<?xml version="1.0" encoding="UTF-8"?><document type="MelisCMS" author="MelisTechnology" version="2.0"></document>',
	        'page_taxonomy' => '',
	        'page_creation_date' => date('Y-m-d H:i:s')
	    ));
	    
	    // Updating platform ids after site pages creation
	    $platform = array(
           'pids_page_id_current' => ++$arrayParameters['pageId']
        );
	    $cmsPlatformTable->save($platform, $arrayParameters['platformId']);
	    
	    // Service implementation end
	    
	    // Adding results to parameters for events treatment if needed
	    $arrayParameters['results'] = $arrayParameters['pageId'];
	    // Sending service end event
	    $arrayParameters = $this->sendEvent('meliscmssite_service_save_site_page_end', $arrayParameters);
	    
	    return $arrayParameters['results'];
	}
720081
public function creatorAction($type, $id = null, $content = null, $father = null)
    {
        //cant use @Secure(roles="ROLE_ADMIN") annotation beacause this method is called in anonymous mode
        if ($this->canEdit()) {
            return $this->render(
                'ClarolineCoreBundle:home/types:'.$type.'.creator.twig',
                $this->manager->getCreator($type, $id, $content, $father),
                true
            );
        }

        return new Response(); //return void and not an exeption
    }
597965
public function buildPageQuery($pageId)
    {
        $siteRepository = GeneralUtility::makeInstance(SiteRepository::class);
        $site = $siteRepository->getSiteByPageId($pageId);

        return $this->newSearchQuery('')
            ->useQueryString('*:*')
            ->useFilter('(type:pages AND uid:' . $pageId . ') OR (*:* AND pid:' . $pageId . ' NOT type:pages)', 'type')
            ->useFilter('siteHash:' . $site->getSiteHash(), 'siteHash')
            ->useReturnFields(ReturnFields::fromString('*'))
            ->useSortings(Sortings::fromString('type asc, title asc'))
            ->useQueryType('standard')
            ->getQuery();
    }
751356
public function resolvePageLayout($pageId, $themeId = null)
    {
        /** @var $site \PageBuilder\Entity\Site */
        /** @var $parent \PageBuilder\Entity\Page */
        /** @var $page \PageBuilder\Entity\Page */
        /** @var $templateObj \PageBuilder\Entity\Template */
        /** @var PageModel $pageModel */

        $layout    = [];
        $pageModel = $this->getServiceLocator()->get('pagebuilder\model\page');
        $page      = $pageModel->getMainPageById($pageId);

        if ($page['layout']) {
            return $page['layout'];
        } elseif ($page['parentId']) {
            $parentPage = $pageModel->getMainPageById($page['parentId']);
            if ($parentPage['layout']) {
                return $parentPage['layout'];
            }
        }

        if (is_object($page) and $templateObj = $page->getTemplate()) {
            if ($layout = $templateObj->getLayout()) {
                return $layout;
            }
        }

        //get the sites default template's layout
        if ($site = $this->getServiceLocator()->get('active\site')) {
            if ($templateObj = $site->getDefaultTemplate()) {
                return $templateObj->getLayout();
            }
        }

        return $layout;
    }
1182732
protected function createPagePlugins(
        Site $site,
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON,
        $pagesData = [],
        $doFlush = true
    ) {
        $entityManager = $this->getEntityManager();

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

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

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

        $pages = [];
        $pageRevisions = [];

        foreach ($pagesData as $pageName => $pageData) {
            if (empty($pageData['plugins'])) {
                continue;
            }

            $page = $pageRepo->getPageByName($site, $pageData['name']);

            if (empty($page)) {
                continue;
            }

            $page->setModifiedByUserId(
                $createdByUserId,
                $createdReason
            );

            $pages[] = $page;

            $pageRevision = $page->getPublishedRevision();

            if (empty($pageRevision)) {
                throw new \Exception(
                    "Could not find published revision for page {$page->getPageId()}"
                );
            }

            foreach ($pageData['plugins'] as $pluginData) {
                $pluginInstance = $pluginInstanceRepo->createPluginInstance(
                    $pluginData,
                    $site,
                    $createdByUserId,
                    $createdReason,
                    null,
                    $doFlush
                );

                $pluginData['pluginInstanceId'] = $pluginInstance->getInstanceId();

                $wrapper = $pluginWrapperRepo->savePluginWrapper(
                    $pluginData,
                    $site,
                    $createdByUserId,
                    $createdReason,
                    null,
                    $doFlush
                );

                $pageRevision->addPluginWrapper($wrapper);

                $pageRevision->setModifiedByUserId(
                    $createdByUserId,
                    $createdReason
                );

                $entityManager->persist($pageRevision);

                $pageRevisions[] = $pageRevision;
            }
        }

        if ($doFlush) {
            $entityManager->flush($pages);
            $entityManager->flush($pageRevisions);
        }
    }
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;
        }
    }
126019
static function Page404(Site $site)
    {
        $sql = Access::SqlBuilder();
        $tblPage = Page::Schema()->Table();
        $where = $sql->Equals($tblPage->Field('Type'), $sql->Value((string) PageType::NotFound()))
                ->And_($sql->Equals($tblPage->Field('Site'), $sql->Value($site->GetID())));

        return Page::Schema()->First($where);
    }
33424
public function getPublishedRevisionId($siteId, $name, $type = PageTypes::NORMAL)
    {
        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();
        $queryBuilder->select('publishedRevision.revisionId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->join('page.publishedRevision', 'publishedRevision')
            ->join('page.site', 'site')
            ->where('site.siteId = :siteId')
            ->andWhere('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->setParameter('siteId', $siteId)
            ->setParameter('pageName', $name)
            ->setParameter('pageType', $type);

        try {
            return $queryBuilder->getQuery()->getSingleScalarResult();
        } catch (NoResultException $e) {
            return null;
        }
    }
1348981
public function countWithFilterAndSiteIds(PaginateFinderConfiguration $configuration, $language, array $siteIds)
    {
        $qa = $this->createAggregationQuery();
        $this->filterSearchAndSiteIds($configuration, $language, $siteIds, $qa);

        return $this->countDocumentAggregateQuery($qa);
    }
679300
public function createPage(
        $refEntityType,
        $pageTitle,
        $locale,
        Node $parentNode = null)
    {
        $user = $this->getAdminUser();

        $newPage = $this->createNewPage($refEntityType, $pageTitle);
        if (null !== $parentNode) {
            $parentNodeTranslation = $parentNode->getNodeTranslation($locale, true);
            $parentNodeVersion = $parentNodeTranslation->getPublicNodeVersion();
            $parentPage = $parentNodeVersion->getRef($this->em);
            $newPage->setParent($parentPage);
        }

        /* @var Node $nodeNewPage */
        $nodeNewPage = $this->em->getRepository('KunstmaanNodeBundle:Node')->createNodeFor($newPage, $locale, $user);
        $nodeTranslation = $nodeNewPage->getNodeTranslation($locale, true);
        if (null !== $parentNode) {
            $weight = $this->em->getRepository('KunstmaanNodeBundle:NodeTranslation')->getMaxChildrenWeight(
                    $parentNode,
                    $locale
                ) + 1;
            $nodeTranslation->setWeight($weight);
        }

        if ($newPage->isStructureNode()) {
            $nodeTranslation->setSlug('');
        }

        $this->em->persist($nodeTranslation);
        $this->em->flush();

        $nodeVersion = $nodeTranslation->getPublicNodeVersion();

        $this->eventDispatcher->dispatch(
            Events::ADD_NODE,
            new NodeEvent(
                $nodeNewPage, $nodeTranslation, $nodeVersion, $newPage
            )
        );

        return $nodeTranslation;
    }
896426
public static function createPage(UtilityContext $context, string $pageName, ?string ...$parameters)
    {
        /* Note: no return type to enable type-hinting */

        if (self::$factory === null) {
            self::$factory = self::getFactory(self::$installType);
        }

        return self::$factory::createPage($context, $pageName, ...$parameters);
    }
445531
private function createSitePageTemplate($tplId, $siteId, $siteName, $tempName, $controler, $action, $platformId)
	{
	    $cmsTemplateTbl = $this->getServiceLocator()->get('MelisEngineTableTemplate');
	    $cmsPlatformTable = $this->getServiceLocator()->get('MelisEngineTablePlatformIds');
	    
	    // Template data
	    $template = array(
	        'tpl_id' => $tplId,
	        'tpl_site_id' => $siteId,
	        'tpl_name' => $tempName,
	        'tpl_type' => 'ZF2',
	        'tpl_zf2_website_folder' => $siteName,
	        'tpl_zf2_layout' => 'defaultLayout',
	        'tpl_zf2_controller' => $controler,
	        'tpl_zf2_action' => $action,
	        'tpl_php_path' => '',
	        'tpl_creation_date' => date('Y-m-d H:i:s'),
	    );
	    
	    // Saving template
	    $templateId = $cmsTemplateTbl->save($template);
	    
	    // Updating platform ids after site pages creation
	    $platform = array(
	        'pids_tpl_id_current' => ++$tplId
	    );
	    $cmsPlatformTable->save($platform, $platformId);
	    
	    return $templateId;
	}
165384
public function createInHierarchy( $parentId, $parentType, $rootId, $childId ) {

		$root = $this->getRoot( $rootId, $parentType );

		// Add Root
		if( !isset( $root ) ) {

			$model	= $this->getModelObject();

			$model->rootId		= $rootId;
			$model->parentType	= $parentType;
			$model->lValue		= CoreGlobal::HIERARCHY_VALUE_L;
			$model->rValue		= CoreGlobal::HIERARCHY_VALUE_R;

			// Create Model
			$model->save();
		}

		$model	= $this->getModelObject();

		$model->rootId		= $rootId;
		$model->parentType	= $parentType;

		$model->parentId	= $parentId;
		$model->childId		= $childId;

		// Create Model
		$model->save();
	}
460826
public function savePage(
        SiteEntity $siteEntity,
        $pageName,
        $pageRevision,
        $pageType,
        $saveData,
        $modifiedByUserId,
        $modifiedReason = Tracking::UNKNOWN_REASON,
        $author = Tracking::UNKNOWN_AUTHOR
    ): array {
        if (empty($pageType)) {
            $pageType = PageTypes::NORMAL;
        }

        $modifiedSiteWideContainers = [];

        if (!empty($saveData['containers'])) {
            foreach ($saveData['containers'] as $containerName => $containerData) {
                /** @var \Rcm\Entity\Container $container */
                $container = $siteEntity->getContainer($containerName);

                if (empty($container)) {
                    /** @var \Rcm\Repository\Container $containerRepo */
                    $containerRepo = $this->_em->getRepository(
                        \Rcm\Entity\Container::class
                    );
                    $container = $containerRepo->createContainer(
                        $siteEntity,
                        $containerName,
                        $modifiedByUserId,
                        $modifiedReason,
                        $author
                    );
                }

                $resultRevisionId = $this->saveContainer(
                    $container,
                    $containerData,
                    $modifiedByUserId,
                    $modifiedReason,
                    $author
                );

                /**
                 * If it deterimins there was no change, it saves nothing a returns an empty $resultRevisionId.
                 */
                $savedANewVersion = !empty($resultRevisionId);

                if ($savedANewVersion) {
                    $modifiedSiteWideContainers[$resultRevisionId] = $container;
                }
            }
        }

        $page = $this->getPageByName($siteEntity, $pageName, $pageType);

        return [
            'newPageRevisionId' => $this->saveContainer(
                $page,
                $saveData['pageContainer'],
                $modifiedByUserId,
                $modifiedReason,
                $author,
                $pageRevision
            ),
            'modifiedSiteWideContainers' => $modifiedSiteWideContainers
        ];
    }
1068557
public function createNewErrorNode($nodeId, $name, $parentId, $siteId, $language, $template)
    {
        $node = $this->initializeNode(NodeInterface::ROOT_NODE_ID, $language, $siteId);
        $node->setNodeId($nodeId);
        $node->setParentId($parentId);
        $node->setNodeType(ReadNodeInterface::TYPE_ERROR);
        $node->setName($name);
        $node->setInFooter(false);
        $node->setInMenu(false);
        $node->setTemplate($template);
        $node->setOrder(-1);
        $node = $this->setVersionName($node);

        $this->eventDispatcher->dispatch(NodeEvents::NODE_CREATION, new NodeEvent($node));

        return $node;
    }
1173289
public function sitePageExists(
        SiteEntity $site,
        $pageName,
        $pageType
    ) {
        try {
            $page = $this->getPageByName(
                $site,
                $pageName,
                $pageType
            );
        } catch (\Exception $e) {
            $page = null;
        }

        return !empty($page);
    }
950015
public function createRootNode($siteId, $language, $name, $routePattern, $template)
    {
        $node = $this->initializeNode(NodeInterface::ROOT_PARENT_ID, $language, $siteId);
        $node->setTemplate($template);
        $node->setRoutePattern($routePattern);
        $node->setName($name);
        $node->setInMenu(true);
        $node->setInFooter(true);
        $node = $this->setVersionName($node);

        return $node;
    }