public function buildSitemap($returnAsArray = false)
    {
        $urls = $this->urls;
        foreach ($this->models as $modelName) {
            /** @var \kato\modules\sitemap\behaviors\SitemapBehavior $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());
        }

        if ($returnAsArray === true) {
            return $urls;
        }

        $sitemapData = $this->createControllerByID('default')->renderPartial('index', [
            'urls' => $urls
        ]);

        $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire);
        return $sitemapData;
    }
public function buildSitemap($returnAsArray = false)
    {
        $urls = $this->urls;
        foreach ($this->models as $modelName) {
            /** @var \kato\modules\sitemap\behaviors\SitemapBehavior $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());
        }

        if ($returnAsArray === true) {
            return $urls;
        }

        $sitemapData = $this->createControllerByID('default')->renderPartial('index', [
            'urls' => $urls
        ]);

        $this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire);
        return $sitemapData;
    }
public function buildSitemap ( $ returnAsArray = false ) { $ urls = $ this -> urls ; foreach ( $ this -> models as $ modelName ) { /** @var \kato\modules\sitemap\behaviors\SitemapBehavior $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 ( ) ) ; } if ( $ returnAsArray === true ) { return $ urls ; } $ sitemapData = $ this -> createControllerByID ( 'default' ) -> renderPartial ( 'index' , [ 'urls' => $ urls ] ) ; $ this -> cacheProvider -> set ( $ this -> cacheKey , $ sitemapData , $ this -> cacheExpire ) ; return $ sitemapData ; }
Build and cache a site map.
@param bool $returnAsArray
@return array|string
@throws InvalidConfigException
Build and cache a site map .