Example #1
0
 /**
  * Add attachments
  *
  * @param Keosu\DataModel\ArticleModelBundle\Entity\ArticleAttachment $attachments
  * @return ArticleBody
  */
 public function addAttachment(\Keosu\DataModel\ArticleModelBundle\Entity\ArticleAttachment $attachments)
 {
     $this->attachments[] = $attachments;
     $attachments->setArticleBody($this);
     return $this;
 }
Example #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();
 }