Sitemap.php
public function buildSitemap()
    {
        $urls = $this->urls;
        foreach ($this->models as $modelName) {
            /** @var behaviors\SitemapBehavior|\yii\db\ActiveRecord $model */
            if (is_array($modelName)) {
                $model = new $modelName['class'];
                if (isset($modelName['behaviors'])) {
                    $model->attachBehaviors($modelName['behaviors']);
                }
            } else {
                $model = new $modelName;
            }

            $urls = array_merge($urls, $model->generateSiteMap());
        }

        $sitemapData = $this->createControllerByID('default')->renderPartial('index', ['urls' => $urls]);
        if ($this->enableGzipedCache) {
            $sitemapData = gzencode($sitemapData);
        }
        $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire);

        return $sitemapData;
    }
public function buildSitemap()
    {
        $urls = $this->urls;
        foreach ($this->models as $modelName) {
            /** @var behaviors\SitemapBehavior|\yii\db\ActiveRecord $model */
            if (is_array($modelName)) {
                $model = new $modelName['class'];
                if (isset($modelName['behaviors'])) {
                    $model->attachBehaviors($modelName['behaviors']);
                }
            } else {
                $model = new $modelName;
            }

            $urls = array_merge($urls, $model->generateSiteMap());
        }

        $sitemapData = $this->createControllerByID('default')->renderPartial('index', ['urls' => $urls]);
        if ($this->enableGzipedCache) {
            $sitemapData = gzencode($sitemapData);
        }
        $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire);

        return $sitemapData;
    }
public function buildSitemap ( ) { $ urls = $ this -> urls ; foreach ( $ this -> models as $ modelName ) { /** @var behaviors\SitemapBehavior|\yii\db\ActiveRecord $model */ if ( is_array ( $ modelName ) ) { $ model = new $ modelName [ 'class' ] ; if ( isset ( $ modelName [ 'behaviors' ] ) ) { $ model -> attachBehaviors ( $ modelName [ 'behaviors' ] ) ; } } else { $ model = new $ modelName ; } $ urls = array_merge ( $ urls , $ model -> generateSiteMap ( ) ) ; } $ sitemapData = $ this -> createControllerByID ( 'default' ) -> renderPartial ( 'index' , [ 'urls' => $ urls ] ) ; if ( $ this -> enableGzipedCache ) { $ sitemapData = gzencode ( $ sitemapData ) ; } $ this -> cacheProvider -> set ( $ this -> cacheKey , $ sitemapData , $ this -> cacheExpire ) ; return $ sitemapData ; }
Build and cache a site map.
@return string
@throws \yii\base\InvalidConfigException
@throws \yii\base\InvalidParamException
Build and cache a site map .