public function createNewPage($user, int $siteId, string $name, string $pageType, $data)
    {
        if (empty($user)) {
            throw new TrackingException('A valid user is required in ' . get_class($this));
        }
        $validatedData = $data;
        $pageData = [
            'name' => $name,
            'siteId' => $siteId,
            'pageTitle' => $validatedData['pageTitle'],
            'pageType' => $pageType, // "n" means "normal"
            'siteLayoutOverride' => (
                isset($validatedData['siteLayoutOverride']) ? $validatedData['siteLayoutOverride'] : null
            ),
            'createdByUserId' => $user->getId(),
            'createdReason' => 'New page in ' . get_class($this),
            'author' => $user->getName(),
        ];

        $createdPage = $this->pageRepo->createPage(
            $this->entityManager->find(Site::class, $siteId),
            $pageData
        );

        $this->immuteblePageVersionRepo->createUnpublished(
            new PageLocator(
                $siteId,
                $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType())
            ),
            $this->immutablePageContentFactory->__invoke(
                $createdPage->getPageTitle(),
                $createdPage->getDescription(),
                $createdPage->getKeywords(),
                $this->revisionRepo->find($createdPage->getStagedRevision())->getPluginWrappers()->toArray()
            ),
            $user->getId(),
            __CLASS__ . '::' . __FUNCTION__
        );

        return $createdPage;
    }
public function createNewPage($user, int $siteId, string $name, string $pageType, $data)
    {
        if (empty($user)) {
            throw new TrackingException('A valid user is required in ' . get_class($this));
        }
        $validatedData = $data;
        $pageData = [
            'name' => $name,
            'siteId' => $siteId,
            'pageTitle' => $validatedData['pageTitle'],
            'pageType' => $pageType, // "n" means "normal"
            'siteLayoutOverride' => (
                isset($validatedData['siteLayoutOverride']) ? $validatedData['siteLayoutOverride'] : null
            ),
            'createdByUserId' => $user->getId(),
            'createdReason' => 'New page in ' . get_class($this),
            'author' => $user->getName(),
        ];

        $createdPage = $this->pageRepo->createPage(
            $this->entityManager->find(Site::class, $siteId),
            $pageData
        );

        $this->immuteblePageVersionRepo->createUnpublished(
            new PageLocator(
                $siteId,
                $this->rcmPageNameToPathname->__invoke($createdPage->getName(), $createdPage->getPageType())
            ),
            $this->immutablePageContentFactory->__invoke(
                $createdPage->getPageTitle(),
                $createdPage->getDescription(),
                $createdPage->getKeywords(),
                $this->revisionRepo->find($createdPage->getStagedRevision())->getPluginWrappers()->toArray()
            ),
            $user->getId(),
            __CLASS__ . '::' . __FUNCTION__
        );

        return $createdPage;
    }
public function createNewPage ( $ user , int $ siteId , string $ name , string $ pageType , $ data ) { if ( empty ( $ user ) ) { throw new TrackingException ( 'A valid user is required in ' . get_class ( $ this ) ) ; } $ validatedData = $ data ; $ pageData = [ 'name' => $ name , 'siteId' => $ siteId , 'pageTitle' => $ validatedData [ 'pageTitle' ] , 'pageType' => $ pageType , // "n" means "normal" 'siteLayoutOverride' => ( isset ( $ validatedData [ 'siteLayoutOverride' ] ) ? $ validatedData [ 'siteLayoutOverride' ] : null ) , 'createdByUserId' => $ user -> getId ( ) , 'createdReason' => 'New page in ' . get_class ( $ this ) , 'author' => $ user -> getName ( ) , ] ; $ createdPage = $ this -> pageRepo -> createPage ( $ this -> entityManager -> find ( Site :: class , $ siteId ) , $ pageData ) ; $ this -> immuteblePageVersionRepo -> createUnpublished ( new PageLocator ( $ siteId , $ this -> rcmPageNameToPathname -> __invoke ( $ createdPage -> getName ( ) , $ createdPage -> getPageType ( ) ) ) , $ this -> immutablePageContentFactory -> __invoke ( $ createdPage -> getPageTitle ( ) , $ createdPage -> getDescription ( ) , $ createdPage -> getKeywords ( ) , $ this -> revisionRepo -> find ( $ createdPage -> getStagedRevision ( ) ) -> getPluginWrappers ( ) -> toArray ( ) ) , $ user -> getId ( ) , __CLASS__ . '::' . __FUNCTION__ ) ; return $ createdPage ; }
Creates a new page which starts out "staged" instead of "published".

Note: This code was moved pretty mush as-is from "PageController" and that is why it is a bit messy.

@param $user
@param int $siteId
@param string $name
@param string $pageType
@param $data
@return Page
@throws TrackingException
@throws \Rcm\Exception\PageException
Creates a new page which starts out staged instead of published .