コード例 #1
0
ファイル: Generator.php プロジェクト: spartaksun/sitemap-php
 /**
  * @param $startUrl
  * @param $maxLevel
  * @param $filePath
  */
 public function generate($startUrl, $maxLevel, $filePath)
 {
     $this->startUrl = $startUrl;
     try {
         $this->storage->init();
         $this->siteProcessor->setMaxLevel($maxLevel);
         $this->siteProcessor->process($startUrl);
         $this->writer->write($startUrl, $filePath);
         $this->storage->deInit();
     } catch (loader\LoaderException $e) {
         echo $e->getMessage();
     } catch (parser\ParserException $e) {
         echo $e->getMessage();
     } finally {
         $this->storage->deInit();
     }
 }
コード例 #2
0
 /**
  * @param $url
  * @param $currentLevel
  * @throws loader\LoaderException
  * @return array
  */
 private function processUrl($url, $currentLevel)
 {
     $html = $this->loader->load($url);
     $normalizedUrls = UrlHelper::normalizeUrls($this->parser->getUrls($html), $this->mainPage, $url);
     return $this->storage->add($normalizedUrls, $currentLevel);
 }