コード例 #1
0
 /**
  * @param \Product\Entity\Product|Post $entity
  */
 public function addEntityInfo($entity)
 {
     $this->writer->startElement('url');
     $this->writer->writeElement('lastmod', date(\Datetime::ATOM, time()));
     $this->writer->startElement('image:image');
     if ($entity instanceof Post) {
         $this->writer->writeElement('image:loc', "http://www.infolightingco.com/images/posts/" . $entity->getThumbnail());
         $this->writer->writeElement('loc', "http://www.infolightingco.com/news/" . $entity->getUrl());
     } else {
         $this->writer->writeElement('image:loc', "http://www.infolightingco.com/images/posts/" . $entity->getThumbnail());
         $this->writer->writeElement('loc', "http://www.infolightingco.com/products/view/" . $entity->getProductNumber());
     }
     $this->writer->endElement();
     $this->writer->endElement();
 }
コード例 #2
0
 public function addAction()
 {
     $form = new PostForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post = new Post();
         $form->setInputFilter($post->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $post->setAuthor($data['author']);
             $post->setTitle($data['title']);
             $post->setBody($data['body']);
             $post->getId($data['id']);
             /*echo "<pre>";
               print_r($post);
               exit;*/
             // $post->exchangeArray($form->getData());
             $this->getEntityManager()->persist($post);
             $this->getEntityManager()->flush();
             return $this->redirect()->toRoute('post');
         }
     }
     return array('form' => $form);
 }
コード例 #3
0
ファイル: PostService.php プロジェクト: JoshBour/karolina
 /**
  * Get the post url
  *
  * @param \Post\Entity\Post $post
  * @return string
  */
 private function getPostUrl($post)
 {
     $encodedUrl = $post->encodeUrl();
     $posts = $this->getPostRepository('post')->findBy(array("url" => $encodedUrl));
     return count($posts) > 0 ? $encodedUrl . '-' . (count($posts) + 1) : $encodedUrl;
 }