Beispiel #1
0
 /**
  * Add article action
  */
 public function addAction()
 {
     $article = new ArticleBody();
     $article->setIdext("0");
     $article->setVersion("1.0");
     return $this->editArticle($article);
 }
Beispiel #2
0
 private function storeArticle($title, $body, $date, $idext, $img, $author, $reader)
 {
     $em = $this->get('doctrine')->getManager();
     $article = $em->getRepository('KeosuDataModelArticleModelBundle:ArticleBody')->findOneByIdext($idext);
     //Create a new article if we can't find one in database
     if ($article == null) {
         $article = new ArticleBody();
         //If article exist and allowpdate is false we quit
     } else {
         if ($reader->getAllowupdate() == false) {
             return;
         }
     }
     $article->setAuthor($author);
     $article->setBody($body);
     $article->setDate($date);
     $article->setReader($reader);
     $article->setTitle($title);
     $article->setIdext($idext);
     $article->setVersion("1.0");
     //RSS attachment
     if ($img != null) {
         $attachment = new ArticleAttachment();
         $filePath = $this->downloadFile($img, $attachment->getUploadRootDir());
         $baseName = basename($img);
         $attachment->setName($baseName);
         $attachment->setPath($baseName);
         $attachment->createThumb($filePath);
         $attachment->setOrientation($filePath);
         $article->addAttachment($attachment);
     }
     $article->setDate($date);
     $em->persist($article);
     $em->flush();
 }