public function populate($idLanguage, $idPage, $skipRepeated = false)
    {
        try {
            $this->dispatcher->dispatch(Content\TemplateManagerEvents::BEFORE_POPULATE, new Content\TemplateManager\BeforePopulateEvent($this));

            $result = false;
            $this->blockRepository->startTransaction();
            foreach ($this->slotManagers as $slotManager) {

                if ($skipRepeated && ($this->isIncluded($slotManager->getSlotName()) || $slotManager->getRepeated() != 'page')) {
                    continue;
                }

                $slotManager
                    ->setForceSlotAttributes(true)
                    ->setSkipSiteLevelBlocks(true)
                ;

                $result = $slotManager->addBlock(
                    array(
                        "idLanguage" => $idLanguage,
                        "idPage" => $idPage,
                    )
                );

                if (false === $result) {
                    break;
                }
            }

            $this->dispatcher->dispatch(Content\TemplateManagerEvents::BEFORE_POPULATE_COMMIT, new Content\TemplateManager\BeforePopulateCommitEvent($this));

            if ($result !== false) {
                $this->blockRepository->commit();
            } else {
                $this->blockRepository->rollBack();
            }
            $this->dispatcher->dispatch(Content\TemplateManagerEvents::AFTER_POPULATE, new Content\TemplateManager\AfterPopulateEvent($this));

            return $result;
        } catch (\Exception $e) {
            $this->blockRepository->rollBack();

            throw $e;
        }
    }
public function populate($idLanguage, $idPage, $skipRepeated = false)
    {
        try {
            $this->dispatcher->dispatch(Content\TemplateManagerEvents::BEFORE_POPULATE, new Content\TemplateManager\BeforePopulateEvent($this));

            $result = false;
            $this->blockRepository->startTransaction();
            foreach ($this->slotManagers as $slotManager) {

                if ($skipRepeated && ($this->isIncluded($slotManager->getSlotName()) || $slotManager->getRepeated() != 'page')) {
                    continue;
                }

                $slotManager
                    ->setForceSlotAttributes(true)
                    ->setSkipSiteLevelBlocks(true)
                ;

                $result = $slotManager->addBlock(
                    array(
                        "idLanguage" => $idLanguage,
                        "idPage" => $idPage,
                    )
                );

                if (false === $result) {
                    break;
                }
            }

            $this->dispatcher->dispatch(Content\TemplateManagerEvents::BEFORE_POPULATE_COMMIT, new Content\TemplateManager\BeforePopulateCommitEvent($this));

            if ($result !== false) {
                $this->blockRepository->commit();
            } else {
                $this->blockRepository->rollBack();
            }
            $this->dispatcher->dispatch(Content\TemplateManagerEvents::AFTER_POPULATE, new Content\TemplateManager\AfterPopulateEvent($this));

            return $result;
        } catch (\Exception $e) {
            $this->blockRepository->rollBack();

            throw $e;
        }
    }
public function populate ( $ idLanguage , $ idPage , $ skipRepeated = false ) { try { $ this -> dispatcher -> dispatch ( Content \ TemplateManagerEvents :: BEFORE_POPULATE , new Content \ TemplateManager \ BeforePopulateEvent ( $ this ) ) ; $ result = false ; $ this -> blockRepository -> startTransaction ( ) ; foreach ( $ this -> slotManagers as $ slotManager ) { if ( $ skipRepeated && ( $ this -> isIncluded ( $ slotManager -> getSlotName ( ) ) || $ slotManager -> getRepeated ( ) != 'page' ) ) { continue ; } $ slotManager -> setForceSlotAttributes ( true ) -> setSkipSiteLevelBlocks ( true ) ; $ result = $ slotManager -> addBlock ( array ( "idLanguage" => $ idLanguage , "idPage" => $ idPage , ) ) ; if ( false === $ result ) { break ; } } $ this -> dispatcher -> dispatch ( Content \ TemplateManagerEvents :: BEFORE_POPULATE_COMMIT , new Content \ TemplateManager \ BeforePopulateCommitEvent ( $ this ) ) ; if ( $ result !== false ) { $ this -> blockRepository -> commit ( ) ; } else { $ this -> blockRepository -> rollBack ( ) ; } $ this -> dispatcher -> dispatch ( Content \ TemplateManagerEvents :: AFTER_POPULATE , new Content \ TemplateManager \ AfterPopulateEvent ( $ this ) ) ; return $ result ; } catch ( \ Exception $ e ) { $ this -> blockRepository -> rollBack ( ) ; throw $ e ; } }
Populates each slot using the default contents and saves them to the database.

This method is used to add a new page based on the template managed by this object. The slots
are filled up using the dafault values provided by each single slot.


@param  int        $idLanguage   The id that identified the language to add
@param  int        $idPage       The id that identified the page to add
@param  boolean    $skipRepeated True skips the slots that are repeated on page
@throws \Exception
@return boolean

@api
Populates each slot using the default contents and saves them to the database .