public function save(BlockManagerApprover $approver, array $options, $saveCommonSlots = true)
    {
        $this->contributorDefined();

        $filesystem = new Filesystem();
        $pageDir = $this->pagesDir . '/' . $options["page"];
        $filesystem->copy($pageDir . '/' . $this->pageFile, $pageDir . '/page.json', true);

        $pageDir .= '/' . $options["language"] . '_' . $options["country"];
        if ($this->seoFile != "seo.json") {

            $sourceFile = $pageDir . '/' . $this->seoFile;
            $values = json_decode(file_get_contents($sourceFile), true);
            if (array_key_exists("current_permalink", $values)) {
                $values["changed_permalinks"][] = $values["current_permalink"];
                unset($values["current_permalink"]);
                file_put_contents($sourceFile, json_encode($values));
            }

            $filesystem->copy($sourceFile, $pageDir . '/seo.json', true);
        }
        $approvedBlocks = $this->saveBlocks($approver, $pageDir, $options);

        if ($saveCommonSlots) {
            $slotsDir = $this->baseDir . '/slots';
            $approvedCommonBlocks = $this->saveBlocks($approver, $slotsDir, $options);
            $approvedBlocks = array_merge($approvedBlocks, $approvedCommonBlocks);
        }

        Dispatcher::dispatch(PageEvents::PAGE_SAVED, new PageSavedEvent($pageDir, null, $approvedBlocks));
        DataLogger::log(sprintf('Page "%s" was successfully saved in production', $options["page"]));
    }
public function save(BlockManagerApprover $approver, array $options, $saveCommonSlots = true)
    {
        $this->contributorDefined();

        $filesystem = new Filesystem();
        $pageDir = $this->pagesDir . '/' . $options["page"];
        $filesystem->copy($pageDir . '/' . $this->pageFile, $pageDir . '/page.json', true);

        $pageDir .= '/' . $options["language"] . '_' . $options["country"];
        if ($this->seoFile != "seo.json") {

            $sourceFile = $pageDir . '/' . $this->seoFile;
            $values = json_decode(file_get_contents($sourceFile), true);
            if (array_key_exists("current_permalink", $values)) {
                $values["changed_permalinks"][] = $values["current_permalink"];
                unset($values["current_permalink"]);
                file_put_contents($sourceFile, json_encode($values));
            }

            $filesystem->copy($sourceFile, $pageDir . '/seo.json', true);
        }
        $approvedBlocks = $this->saveBlocks($approver, $pageDir, $options);

        if ($saveCommonSlots) {
            $slotsDir = $this->baseDir . '/slots';
            $approvedCommonBlocks = $this->saveBlocks($approver, $slotsDir, $options);
            $approvedBlocks = array_merge($approvedBlocks, $approvedCommonBlocks);
        }

        Dispatcher::dispatch(PageEvents::PAGE_SAVED, new PageSavedEvent($pageDir, null, $approvedBlocks));
        DataLogger::log(sprintf('Page "%s" was successfully saved in production', $options["page"]));
    }
public function save ( BlockManagerApprover $ approver , array $ options , $ saveCommonSlots = true ) { $ this -> contributorDefined ( ) ; $ filesystem = new Filesystem ( ) ; $ pageDir = $ this -> pagesDir . '/' . $ options [ "page" ] ; $ filesystem -> copy ( $ pageDir . '/' . $ this -> pageFile , $ pageDir . '/page.json' , true ) ; $ pageDir .= '/' . $ options [ "language" ] . '_' . $ options [ "country" ] ; if ( $ this -> seoFile != "seo.json" ) { $ sourceFile = $ pageDir . '/' . $ this -> seoFile ; $ values = json_decode ( file_get_contents ( $ sourceFile ) , true ) ; if ( array_key_exists ( "current_permalink" , $ values ) ) { $ values [ "changed_permalinks" ] [ ] = $ values [ "current_permalink" ] ; unset ( $ values [ "current_permalink" ] ) ; file_put_contents ( $ sourceFile , json_encode ( $ values ) ) ; } $ filesystem -> copy ( $ sourceFile , $ pageDir . '/seo.json' , true ) ; } $ approvedBlocks = $ this -> saveBlocks ( $ approver , $ pageDir , $ options ) ; if ( $ saveCommonSlots ) { $ slotsDir = $ this -> baseDir . '/slots' ; $ approvedCommonBlocks = $ this -> saveBlocks ( $ approver , $ slotsDir , $ options ) ; $ approvedBlocks = array_merge ( $ approvedBlocks , $ approvedCommonBlocks ) ; } Dispatcher :: dispatch ( PageEvents :: PAGE_SAVED , new PageSavedEvent ( $ pageDir , null , $ approvedBlocks ) ) ; DataLogger :: log ( sprintf ( 'Page "%s" was successfully saved in production' , $ options [ "page" ] ) ) ; }
Saves the handled page

@param \RedKiteCms\Content\BlockManager\BlockManagerApprover $approver
@param array $options
@param bool $saveCommonSlots Saves the common slots when true
Saves the handled page