protected function add(array $values)
    {
        $values =
            $this->dispatchBeforeOperationEvent(
                '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeSeoAddingEvent',
                SeoEvents::BEFORE_ADD_SEO,
                $values,
                array(
                    'message' => 'exception_seo_adding_aborted',
                    'domain' => 'exceptions',
                )
            );

        try {
            $this->validator->checkEmptyParams($values);
            $this->validator->checkRequiredParamsExists(array('PageId' => '', 'LanguageId' => '', 'Permalink' => ''), $values);

            if (empty($values['PageId'])) {
                throw new General\ArgumentIsEmptyException('exception_page_id_required_to_save_seo');
            }

            if (empty($values['LanguageId'])) {
                throw new General\ArgumentIsEmptyException('exception_language_id_required_to_save_seo');
            }

            if (empty($values['Permalink'])) {
                throw new General\ArgumentIsEmptyException('exception_permalink_required_to_save_seo');
            }

            $values["Permalink"] = PageManager::slugify($values["Permalink"]);

            $this->seoRepository->startTransaction();
            if (null === $this->alSeo) {
                $className = $this->seoRepository->getRepositoryObjectClassName();
                $this->alSeo = new $className();
            }

            $values = $this->checkCreatedAt($values);
            $result = $this->seoRepository
                    ->setRepositoryObject($this->alSeo)
                    ->save($values);
            if (false !== $result) {
                $eventName = SeoEvents::BEFORE_ADD_SEO_COMMIT;
                $result = !$this->eventsHandler
                                ->createEvent($eventName, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeAddSeoCommitEvent', array($this, $values))
                                ->dispatch()
                                ->getEvent($eventName)
                                ->isAborted();
            }

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

                $this->eventsHandler
                     ->createEvent(SeoEvents::AFTER_ADD_SEO, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\AfterSeoAddedEvent', array($this))
                     ->dispatch();

                return $result;
            }

            $this->seoRepository->rollBack();

            return $result;
        } catch (General\ArgumentIsEmptyException $ex) {
        } catch (General\EmptyArgumentsException $ex) {
        } catch (General\ArgumentExpectedException $ex) {
        } catch (\Exception $e) {
            if (isset($this->seoRepository) && $this->seoRepository !== null) {
                $this->seoRepository->rollBack();
            }

            throw $e;
        }
    }
protected function add(array $values)
    {
        $values =
            $this->dispatchBeforeOperationEvent(
                '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeSeoAddingEvent',
                SeoEvents::BEFORE_ADD_SEO,
                $values,
                array(
                    'message' => 'exception_seo_adding_aborted',
                    'domain' => 'exceptions',
                )
            );

        try {
            $this->validator->checkEmptyParams($values);
            $this->validator->checkRequiredParamsExists(array('PageId' => '', 'LanguageId' => '', 'Permalink' => ''), $values);

            if (empty($values['PageId'])) {
                throw new General\ArgumentIsEmptyException('exception_page_id_required_to_save_seo');
            }

            if (empty($values['LanguageId'])) {
                throw new General\ArgumentIsEmptyException('exception_language_id_required_to_save_seo');
            }

            if (empty($values['Permalink'])) {
                throw new General\ArgumentIsEmptyException('exception_permalink_required_to_save_seo');
            }

            $values["Permalink"] = PageManager::slugify($values["Permalink"]);

            $this->seoRepository->startTransaction();
            if (null === $this->alSeo) {
                $className = $this->seoRepository->getRepositoryObjectClassName();
                $this->alSeo = new $className();
            }

            $values = $this->checkCreatedAt($values);
            $result = $this->seoRepository
                    ->setRepositoryObject($this->alSeo)
                    ->save($values);
            if (false !== $result) {
                $eventName = SeoEvents::BEFORE_ADD_SEO_COMMIT;
                $result = !$this->eventsHandler
                                ->createEvent($eventName, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeAddSeoCommitEvent', array($this, $values))
                                ->dispatch()
                                ->getEvent($eventName)
                                ->isAborted();
            }

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

                $this->eventsHandler
                     ->createEvent(SeoEvents::AFTER_ADD_SEO, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\AfterSeoAddedEvent', array($this))
                     ->dispatch();

                return $result;
            }

            $this->seoRepository->rollBack();

            return $result;
        } catch (General\ArgumentIsEmptyException $ex) {
        } catch (General\EmptyArgumentsException $ex) {
        } catch (General\ArgumentExpectedException $ex) {
        } catch (\Exception $e) {
            if (isset($this->seoRepository) && $this->seoRepository !== null) {
                $this->seoRepository->rollBack();
            }

            throw $e;
        }
    }
protected function add ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeSeoAddingEvent' , SeoEvents :: BEFORE_ADD_SEO , $ values , array ( 'message' => 'exception_seo_adding_aborted' , 'domain' => 'exceptions' , ) ) ; try { $ this -> validator -> checkEmptyParams ( $ values ) ; $ this -> validator -> checkRequiredParamsExists ( array ( 'PageId' => '' , 'LanguageId' => '' , 'Permalink' => '' ) , $ values ) ; if ( empty ( $ values [ 'PageId' ] ) ) { throw new General \ ArgumentIsEmptyException ( 'exception_page_id_required_to_save_seo' ) ; } if ( empty ( $ values [ 'LanguageId' ] ) ) { throw new General \ ArgumentIsEmptyException ( 'exception_language_id_required_to_save_seo' ) ; } if ( empty ( $ values [ 'Permalink' ] ) ) { throw new General \ ArgumentIsEmptyException ( 'exception_permalink_required_to_save_seo' ) ; } $ values [ "Permalink" ] = PageManager :: slugify ( $ values [ "Permalink" ] ) ; $ this -> seoRepository -> startTransaction ( ) ; if ( null === $ this -> alSeo ) { $ className = $ this -> seoRepository -> getRepositoryObjectClassName ( ) ; $ this -> alSeo = new $ className ( ) ; } $ values = $ this -> checkCreatedAt ( $ values ) ; $ result = $ this -> seoRepository -> setRepositoryObject ( $ this -> alSeo ) -> save ( $ values ) ; if ( false !== $ result ) { $ eventName = SeoEvents :: BEFORE_ADD_SEO_COMMIT ; $ result = ! $ this -> eventsHandler -> createEvent ( $ eventName , '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\BeforeAddSeoCommitEvent' , array ( $ this , $ values ) ) -> dispatch ( ) -> getEvent ( $ eventName ) -> isAborted ( ) ; } if ( false !== $ result ) { $ this -> seoRepository -> commit ( ) ; $ this -> eventsHandler -> createEvent ( SeoEvents :: AFTER_ADD_SEO , '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Seo\AfterSeoAddedEvent' , array ( $ this ) ) -> dispatch ( ) ; return $ result ; } $ this -> seoRepository -> rollBack ( ) ; return $ result ; } catch ( General \ ArgumentIsEmptyException $ ex ) { } catch ( General \ EmptyArgumentsException $ ex ) { } catch ( General \ ArgumentExpectedException $ ex ) { } catch ( \ Exception $ e ) { if ( isset ( $ this -> seoRepository ) && $ this -> seoRepository !== null ) { $ this -> seoRepository -> rollBack ( ) ; } throw $ e ; } }
Adds a new Seo object from the given params

@param  array                                                                                     $values
@return boolean
@throws \RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Exception\Content\General\InvalidArgumentTypeException
@throws \RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Exception\Content\General\ArgumentIsEmptyException

@api
Adds a new Seo object from the given params