protected function add(array $values)
    {
        $values =
            $this->dispatchBeforeOperationEvent(
                '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforePageAddingEvent',
                PageEvents::BEFORE_ADD_PAGE,
                $values,
                array(
                    'message' => 'exception_page_adding_aborted',
                    'domain' => 'exceptions',
                )
            );

        try {
            $this->validator->checkEmptyParams($values);
            $this->validator->checkRequiredParamsExists(array('PageName' => '', 'TemplateName' => ''), $values);

            if (empty($values['PageName'])) {
                throw new General\ArgumentIsEmptyException("exception_invalid_page_name");
            }

            if (empty($values['TemplateName'])) {
                throw new General\ArgumentIsEmptyException("exception_page_template_param_missing");
            }

            if ($this->validator->pageExists($values['PageName'])) {
                throw new PageException\PageExistsException("exception_page_already_exists");
            }

            if (!$this->validator->hasLanguages()) {
                throw new PageException\AnyLanguageExistsException("exception_website_has_no_languages");
            }

            $result = true;
            $this->pageRepository->startTransaction();
            if (null === $this->alPage) {
                $className = $this->pageRepository->getRepositoryObjectClassName();
                $this->alPage = new $className();
            }

            $hasPages = $this->validator->hasPages();
            $values['IsHome'] = ($hasPages) ? (isset($values['IsHome'])) ? $values['IsHome'] : 0 : 1;
            if ($values['IsHome'] == 1 && $hasPages) {
                $result = $this->resetHome();
            }

            if (false !== $result) {
                $values['PageName'] = $this->slugify($values['PageName']);
                $values = $this->checkCreatedAt($values);

                // Saves the page
                $result = $this->pageRepository
                               ->setRepositoryObject($this->alPage)
                               ->save($values);
                if (false !== $result) {
                    $eventName = PageEvents::BEFORE_ADD_PAGE_COMMIT;
                    $result = !$this->eventsHandler
                                    ->createEvent($eventName, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforeAddPageCommitEvent', array($this, $values))
                                    ->dispatch()
                                    ->getEvent($eventName)
                                    ->isAborted();
                }
            }

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

                $this->eventsHandler
                     ->createEvent(PageEvents::AFTER_ADD_PAGE, '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\AfterPageAddedEvent', array($this))
                     ->dispatch();

                return $result;
            }

            $this->pageRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            if (isset($this->pageRepository) && $this->pageRepository !== null) {
                $this->pageRepository->rollBack();
            }

            throw $e;
        }
    }