public function sitemap()
    {
        //Checks if the sitemap exist and is not expired
        if (is_readable(SITEMAP)) {
            $time = Time::createFromTimestamp(filemtime(SITEMAP));

            if (!$time->modify(getConfigOrFail('main.sitemap_expiration'))->isPast()) {
                $sitemap = file_get_contents(SITEMAP);
            }
        }

        if (empty($sitemap)) {
            $sitemap = gzencode(Sitemap::generate(), 9);

            (new File(SITEMAP, true, 0777))->write($sitemap);
        }

        return $this->response->withFile(SITEMAP);
    }
public function sitemap()
    {
        //Checks if the sitemap exist and is not expired
        if (is_readable(SITEMAP)) {
            $time = Time::createFromTimestamp(filemtime(SITEMAP));

            if (!$time->modify(getConfigOrFail('main.sitemap_expiration'))->isPast()) {
                $sitemap = file_get_contents(SITEMAP);
            }
        }

        if (empty($sitemap)) {
            $sitemap = gzencode(Sitemap::generate(), 9);

            (new File(SITEMAP, true, 0777))->write($sitemap);
        }

        return $this->response->withFile(SITEMAP);
    }
public function sitemap ( ) { //Checks if the sitemap exist and is not expired if ( is_readable ( SITEMAP ) ) { $ time = Time :: createFromTimestamp ( filemtime ( SITEMAP ) ) ; if ( ! $ time -> modify ( getConfigOrFail ( 'main.sitemap_expiration' ) ) -> isPast ( ) ) { $ sitemap = file_get_contents ( SITEMAP ) ; } } if ( empty ( $ sitemap ) ) { $ sitemap = gzencode ( Sitemap :: generate ( ) , 9 ) ; ( new File ( SITEMAP , true , 0777 ) ) -> write ( $ sitemap ) ; } return $ this -> response -> withFile ( SITEMAP ) ; }
Returns the site sitemap.
If the sitemap doesn't exist or has expired, it generates and writes
the sitemap.
@return \Cake\Network\Response
Returns the site sitemap . If the sitemap doesn t exist or has expired it generates and writes the sitemap .