public function onBeforeEditPageCommit(BeforeEditPageCommitEvent $event)
    {
        if ($event->isAborted()) {
            return;
        }

        $pageManager = $event->getContentManager();
        $pageRepository = $pageManager->getPageRepository();
        $values = $event->getValues();

        if (!is_array($values)) {
            throw new InvalidArgumentException('exception_invalid_value_array_required');
        }

        try {
            $pageInformation = $pageManager->getTemplateManager()
                    ->getPageBlocks()
                    ->getPageInformation();

            $idLanguage = $pageInformation["idLanguage"];
            $idPage = $pageInformation["idPage"];
            $seoRepository = $this->seoManager->getSeoRepository();
            $seo = $seoRepository->fromPageAndLanguage($idLanguage, $idPage);
            if (!empty($values)) {
                $seoRepository->setConnection($pageRepository->getConnection());
                $pageRepository->startTransaction();
                $this->seoManager->set($seo);
                $values = array_merge($values, array('PageId' => $idPage, 'LanguageId' => $idLanguage));
                $result = $this->seoManager->save($values);

                if (false !== $result) {
                    $pageRepository->commit();

                    return;
                }

                $pageRepository->rollBack();
                $event->abort();
            }
        } catch (\Exception $e) {
            $event->abort();

            if (isset($pageRepository) && $pageRepository !== null) {
                $pageRepository->rollBack();
            }

            throw $e;
        }
    }
public function onBeforeEditPageCommit(BeforeEditPageCommitEvent $event)
    {
        if ($event->isAborted()) {
            return;
        }

        $pageManager = $event->getContentManager();
        $pageRepository = $pageManager->getPageRepository();
        $values = $event->getValues();

        if (!is_array($values)) {
            throw new InvalidArgumentException('exception_invalid_value_array_required');
        }

        try {
            $pageInformation = $pageManager->getTemplateManager()
                    ->getPageBlocks()
                    ->getPageInformation();

            $idLanguage = $pageInformation["idLanguage"];
            $idPage = $pageInformation["idPage"];
            $seoRepository = $this->seoManager->getSeoRepository();
            $seo = $seoRepository->fromPageAndLanguage($idLanguage, $idPage);
            if (!empty($values)) {
                $seoRepository->setConnection($pageRepository->getConnection());
                $pageRepository->startTransaction();
                $this->seoManager->set($seo);
                $values = array_merge($values, array('PageId' => $idPage, 'LanguageId' => $idLanguage));
                $result = $this->seoManager->save($values);

                if (false !== $result) {
                    $pageRepository->commit();

                    return;
                }

                $pageRepository->rollBack();
                $event->abort();
            }
        } catch (\Exception $e) {
            $event->abort();

            if (isset($pageRepository) && $pageRepository !== null) {
                $pageRepository->rollBack();
            }

            throw $e;
        }
    }
public function onBeforeEditPageCommit ( BeforeEditPageCommitEvent $ event ) { if ( $ event -> isAborted ( ) ) { return ; } $ pageManager = $ event -> getContentManager ( ) ; $ pageRepository = $ pageManager -> getPageRepository ( ) ; $ values = $ event -> getValues ( ) ; if ( ! is_array ( $ values ) ) { throw new InvalidArgumentException ( 'exception_invalid_value_array_required' ) ; } try { $ pageInformation = $ pageManager -> getTemplateManager ( ) -> getPageBlocks ( ) -> getPageInformation ( ) ; $ idLanguage = $ pageInformation [ "idLanguage" ] ; $ idPage = $ pageInformation [ "idPage" ] ; $ seoRepository = $ this -> seoManager -> getSeoRepository ( ) ; $ seo = $ seoRepository -> fromPageAndLanguage ( $ idLanguage , $ idPage ) ; if ( ! empty ( $ values ) ) { $ seoRepository -> setConnection ( $ pageRepository -> getConnection ( ) ) ; $ pageRepository -> startTransaction ( ) ; $ this -> seoManager -> set ( $ seo ) ; $ values = array_merge ( $ values , array ( 'PageId' => $ idPage , 'LanguageId' => $ idLanguage ) ) ; $ result = $ this -> seoManager -> save ( $ values ) ; if ( false !== $ result ) { $ pageRepository -> commit ( ) ; return ; } $ pageRepository -> rollBack ( ) ; $ event -> abort ( ) ; } } catch ( \ Exception $ e ) { $ event -> abort ( ) ; if ( isset ( $ pageRepository ) && $ pageRepository !== null ) { $ pageRepository -> rollBack ( ) ; } throw $ e ; } }
Edits the seo attributes when a new page is edited

@param  BeforeEditPageCommitEvent $event
@return boolean
@throws InvalidArgumentException
@throws \Exception

@api
Edits the seo attributes when a new page is edited