コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @return boolean
  * @throws General\ArgumentIsEmptyException
  * @throws LanguageException\RemoveMainLanguageException
  * @throws LanguageException\LanguageExistsException
  *
  * @api
  */
 public function delete()
 {
     if (null === $this->alLanguage) {
         throw new General\ArgumentIsEmptyException('exception_no_languages_selected_delete_skipped');
     }
     if ($this->alLanguage->getMainLanguage() == 1) {
         throw new LanguageException\RemoveMainLanguageException('exception_website_main_languages_cannot_be_delete');
     }
     $this->dispatchBeforeOperationEvent('\\RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Event\\Content\\Language\\BeforeLanguageDeletingEvent', LanguageEvents::BEFORE_DELETE_LANGUAGE, array(), 'exception_language_deleting_aborted');
     try {
         $this->languageRepository->startTransaction();
         $result = $this->languageRepository->setRepositoryObject($this->alLanguage)->delete();
         if ($result) {
             $eventName = LanguageEvents::BEFORE_DELETE_LANGUAGE_COMMIT;
             $result = !$this->eventsHandler->createEvent($eventName, '\\RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Event\\Content\\Language\\BeforeDeleteLanguageCommitEvent', array($this, array()))->dispatch()->getEvent($eventName)->isAborted();
         }
         if (false !== $result) {
             $this->languageRepository->commit();
             $this->eventsHandler->createEvent(LanguageEvents::AFTER_DELETE_LANGUAGE, '\\RedKiteLabs\\RedKiteCms\\RedKiteCmsBundle\\Core\\Event\\Content\\Language\\AfterLanguageDeletedEvent', array($this))->dispatch();
             return $result;
         }
         $this->languageRepository->rollBack();
         return $result;
     } catch (\Exception $e) {
         if (isset($this->languageRepository) && $this->languageRepository !== null) {
             $this->languageRepository->rollBack();
         }
         throw $e;
     }
 }