Beispiel #1
0
 /**
  * @param AbstractQuery $query
  */
 public function handle(AbstractQuery $query)
 {
     try {
         $books = $this->bookReadService->getAllBooks();
         $posts = $this->blogPostReadService->getAllPosts();
         $page = new ThemePage('Posts/Read/Pages/Abstract.twig', ['books' => $books, 'posts' => $posts]);
         $page->respond();
     } catch (BlogException $e) {
         $requestInfo = $query->getRequestInfo();
         $page = new ThemePage('Blog/Read/Pages/Error500.twig', ['requestUri' => $requestInfo->getUri()], Http::NOT_FOUND);
         $page->respond();
     }
 }
Beispiel #2
0
 /**
  * @param ShowPostQuery $query
  */
 public function handle(ShowPostQuery $query)
 {
     $requestInfo = $query->getRequestInfo();
     try {
         $postData = $this->blogPostReadService->getPostDataByUrl($requestInfo->getUri());
         $previousPost = $this->blogPostReadService->getPreviousPostOf($postData);
         $nextPost = $this->blogPostReadService->getNextPostOf($postData);
         $page = new ThemePage('Posts/Read/Pages/ShowPost.twig', ['post' => $postData, 'previous' => $previousPost, 'next' => $nextPost]);
         $page->respond();
     } catch (BlogPostDataNotFound $e) {
         $page = new ThemePage('Blog/Read/Pages/Error404.twig', ['requestUri' => $requestInfo->getUri()], Http::NOT_FOUND);
         $page->respond();
     }
 }
Beispiel #3
0
 /**
  * @param SitemapQuery $query
  */
 public function handle(SitemapQuery $query)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $urlSet = $dom->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset');
     $urlSet->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:image', 'http://www.google.com/schemas/sitemap-image/1.1');
     $urlSet->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:video', 'http://www.google.com/schemas/sitemap-video/1.1');
     $dom->appendChild($urlSet);
     $url = $dom->createElement('url');
     $homeLoc = $dom->createElement('loc', App::getUrl());
     $homeImage = $dom->createElement('image:image');
     $homeImageLoc = $dom->createElement('image:loc', App::getUrl() . '/img/phpindd-logo.png');
     $homeImageCaption = $dom->createElement('image:caption', 'PHP in DD Blog');
     $homeImage->appendChild($homeImageLoc);
     $homeImage->appendChild($homeImageCaption);
     $url->appendChild($homeLoc);
     $url->appendChild($homeImage);
     $urlSet->appendChild($url);
     $posts = $this->blogPostReadService->getAllPosts();
     foreach ($posts as $post) {
         $url = $dom->createElement('url');
         $postLoc = $dom->createElement('loc', App::getUrl() . $post->url);
         $url->appendChild($postLoc);
         $urlSet->appendChild($url);
     }
     # hwoltersdorf
     $url = $dom->createElement('url');
     $authorLoc = $dom->createElement('loc', App::getUrl() . '/about/author/holger-woltersdorf');
     $authorImage = $dom->createElement('image:image');
     $authorImageLoc = $dom->createElement('image:loc', App::getUrl() . '/img/hwoltersdorf.jpg');
     $authorImageCaption = $dom->createElement('image:caption', 'Holger Woltersdorf');
     $authorImage->appendChild($authorImageLoc);
     $authorImage->appendChild($authorImageCaption);
     $url->appendChild($authorLoc);
     $url->appendChild($authorImage);
     $urlSet->appendChild($url);
     # dmersiowsky
     $url = $dom->createElement('url');
     $authorLoc = $dom->createElement('loc', App::getUrl() . '/about/author/daniel-mersiowsky');
     $authorImage = $dom->createElement('image:image');
     $authorImageLoc = $dom->createElement('image:loc', App::getUrl() . '/img/dmersiowsky.jpg');
     $authorImageCaption = $dom->createElement('image:caption', 'Daniel Mersiowsky');
     $authorImage->appendChild($authorImageLoc);
     $authorImage->appendChild($authorImageCaption);
     $url->appendChild($authorLoc);
     $url->appendChild($authorImage);
     $urlSet->appendChild($url);
     # tmissner
     $url = $dom->createElement('url');
     $authorLoc = $dom->createElement('loc', App::getUrl() . '/about/author/tobias-missner');
     $authorImage = $dom->createElement('image:image');
     $authorImageLoc = $dom->createElement('image:loc', App::getUrl() . '/img/tmissner.png');
     $authorImageCaption = $dom->createElement('image:caption', 'Tobias Mißner');
     $authorImage->appendChild($authorImageLoc);
     $authorImage->appendChild($authorImageCaption);
     $url->appendChild($authorLoc);
     $url->appendChild($authorImage);
     $urlSet->appendChild($url);
     $content = $dom->saveXML();
     header('Content-Type: text/xml; charset=utf-8');
     header('Content-Length: ' . grapheme_strlen($content));
     echo $content;
 }