コード例 #1
0
ファイル: RequestTest.php プロジェクト: Rovak/zf2
 /**
  * @dataProvider baseUrlAndPathProvider
  * @param array  $server
  * @param string $baseUrl
  * @param string $basePath
  */
 public function testBasePathDetection(array $server, $baseUrl, $basePath)
 {
     $_SERVER = $server;
     $request = new Request();
     $this->assertEquals($baseUrl, $request->getBaseUrl());
     $this->assertEquals($basePath, $request->getBasePath());
 }
コード例 #2
0
ファイル: Sitemap.php プロジェクト: gotcms/gotcms
 /**
  * Generate Xml
  *
  * @param array   $documents Array with all documents
  * @param Request $request   Request
  *
  * @return string
  */
 protected function generateXml($documents, Request $request)
 {
     $xml = '<?xml version="1.0" encoding="UTF-8"?>';
     $xml .= '<urlset
         xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
         http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';
     $url = $request->getBasePath();
     foreach ($documents as $document) {
         $xml .= '<url>';
         $xml .= '<loc><![CDATA[' . $url . $document->getUrl() . ']]></loc>';
         $xml .= '<lastmod>' . date('Y-m-d\\TH:i:s\\Z', strtotime($document->getUpdatedAt())) . '</lastmod>';
         $xml .= '<changefreq>weekly</changefreq>';
         $xml .= '<priority>0.5</priority>';
         $xml .= '</url>';
     }
     $xml .= '</urlset>';
     return $xml;
 }
コード例 #3
0
 /**
  * Get the URI path of the request, relative to the application base URL.
  *
  * @param HttpRequest $request
  * @return string
  */
 protected function _getRelativePath(HttpRequest $request)
 {
     $basePath = $request->getBasePath();
     $relPath = $request->getUri()->getPath();
     if (!empty($basePath) && strpos($relPath, $basePath) === 0) {
         $relPath = substr($relPath, strlen($basePath));
     }
     return $relPath;
 }
コード例 #4
0
 /**
  * Gets the base path.
  *
  * @return string The base path
  */
 public function getBasePath()
 {
     return $this->request->getBasePath();
 }