コード例 #1
0
ファイル: ArticleService.php プロジェクト: fuca/sportsclub
 public function createArticle(Article $a)
 {
     if ($a === NULL) {
         throw new Exceptions\NullPointerException("Argument Article was null");
     }
     try {
         $this->entityManager->beginTransaction();
         $a->setAuthor($a->getEditor());
         $a->setUpdated(new DateTime());
         $a->setCreated(new DateTime());
         $this->sportGroupsTypeHandle($a);
         $a->setAlias(Strings::webalize($a->getTitle()));
         $identifier = $this->imageService->storeNetteFile($a->getPicture());
         $a->setPicture($identifier);
         $this->articleDao->save($a);
         $this->invalidateEntityCache();
         $this->entityManager->commit();
     } catch (DBALException $ex) {
         $this->entityManager->rollback();
         $this->logWarning($ex);
         throw new Exceptions\DuplicateEntryException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     } catch (\Exception $ex) {
         $this->entityManager->rollback();
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
     $this->onCreate($a);
 }