public function generateAction($context, $lang, $id)
    {

        /** @var Request $request */
        $request = $this->getRequest();

        // context
        if ("" === $context){
            $context = "catalog";
        } else if (! in_array($context, array("catalog", "content", "brand")) ){
            $this->pageNotFound();
        }

        // the locale : fr_FR, en_US,
        if ("" !== $lang) {
            if (! $this->checkLang($lang)){
                $this->pageNotFound();
            }
        } else {
            try{
                $lang = Lang::getDefaultLanguage();
                $lang = $lang->getLocale();
            } catch (\RuntimeException $ex){
                // @todo generate error page
                throw new \RuntimeException("No default language is defined. Please define one.");
            }
        }
        if (null === $lang = LangQuery::create()->findOneByLocale($lang)){
            $this->pageNotFound();
        }
        $lang = $lang->getId();

        // check if element exists and is visible
        if ("" !== $id){
            if (false === $this->checkId($context, $id)){
                $this->pageNotFound();
            }
        }

        $flush = $request->query->get("flush", "");

        // check if feed already in cache
        $cacheContent = false;

        $cacheDir = $this->getCacheDir();
        $cacheKey = self::FEED_CACHE_KEY . $lang . $context . $id;
        $cacheExpire = intval(ConfigQuery::read("feed_ttl", '7200')) ?: 7200;

        $cacheDriver = new FilesystemCache($cacheDir);
        if (!($this->checkAdmin() && "" !== $flush)){
            $cacheContent = $cacheDriver->fetch($cacheKey);
        } else {
            $cacheDriver->delete($cacheKey);
        }

        // if not in cache
        if (false === $cacheContent){
            // render the view
            $cacheContent = $this->renderRaw(
                "feed",
                array(
                    "_context_" => $context,
                    "_lang_"    => $lang,
                    "_id_"      => $id
                )
            );
            // save cache
            $cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
        }

        $response = new Response();
        $response->setContent($cacheContent);
        $response->headers->set('Content-Type', 'application/rss+xml');

        return $response;
    }
public function generateAction($context, $lang, $id)
    {

        /** @var Request $request */
        $request = $this->getRequest();

        // context
        if ("" === $context){
            $context = "catalog";
        } else if (! in_array($context, array("catalog", "content", "brand")) ){
            $this->pageNotFound();
        }

        // the locale : fr_FR, en_US,
        if ("" !== $lang) {
            if (! $this->checkLang($lang)){
                $this->pageNotFound();
            }
        } else {
            try{
                $lang = Lang::getDefaultLanguage();
                $lang = $lang->getLocale();
            } catch (\RuntimeException $ex){
                // @todo generate error page
                throw new \RuntimeException("No default language is defined. Please define one.");
            }
        }
        if (null === $lang = LangQuery::create()->findOneByLocale($lang)){
            $this->pageNotFound();
        }
        $lang = $lang->getId();

        // check if element exists and is visible
        if ("" !== $id){
            if (false === $this->checkId($context, $id)){
                $this->pageNotFound();
            }
        }

        $flush = $request->query->get("flush", "");

        // check if feed already in cache
        $cacheContent = false;

        $cacheDir = $this->getCacheDir();
        $cacheKey = self::FEED_CACHE_KEY . $lang . $context . $id;
        $cacheExpire = intval(ConfigQuery::read("feed_ttl", '7200')) ?: 7200;

        $cacheDriver = new FilesystemCache($cacheDir);
        if (!($this->checkAdmin() && "" !== $flush)){
            $cacheContent = $cacheDriver->fetch($cacheKey);
        } else {
            $cacheDriver->delete($cacheKey);
        }

        // if not in cache
        if (false === $cacheContent){
            // render the view
            $cacheContent = $this->renderRaw(
                "feed",
                array(
                    "_context_" => $context,
                    "_lang_"    => $lang,
                    "_id_"      => $id
                )
            );
            // save cache
            $cacheDriver->save($cacheKey, $cacheContent, $cacheExpire);
        }

        $response = new Response();
        $response->setContent($cacheContent);
        $response->headers->set('Content-Type', 'application/rss+xml');

        return $response;
    }
public function generateAction ( $ context , $ lang , $ id ) { /** @var Request $request */ $ request = $ this -> getRequest ( ) ; // context if ( "" === $ context ) { $ context = "catalog" ; } else if ( ! in_array ( $ context , array ( "catalog" , "content" , "brand" ) ) ) { $ this -> pageNotFound ( ) ; } // the locale : fr_FR, en_US, if ( "" !== $ lang ) { if ( ! $ this -> checkLang ( $ lang ) ) { $ this -> pageNotFound ( ) ; } } else { try { $ lang = Lang :: getDefaultLanguage ( ) ; $ lang = $ lang -> getLocale ( ) ; } catch ( \ RuntimeException $ ex ) { // @todo generate error page throw new \ RuntimeException ( "No default language is defined. Please define one." ) ; } } if ( null === $ lang = LangQuery :: create ( ) -> findOneByLocale ( $ lang ) ) { $ this -> pageNotFound ( ) ; } $ lang = $ lang -> getId ( ) ; // check if element exists and is visible if ( "" !== $ id ) { if ( false === $ this -> checkId ( $ context , $ id ) ) { $ this -> pageNotFound ( ) ; } } $ flush = $ request -> query -> get ( "flush" , "" ) ; // check if feed already in cache $ cacheContent = false ; $ cacheDir = $ this -> getCacheDir ( ) ; $ cacheKey = self :: FEED_CACHE_KEY . $ lang . $ context . $ id ; $ cacheExpire = intval ( ConfigQuery :: read ( "feed_ttl" , '7200' ) ) ? : 7200 ; $ cacheDriver = new FilesystemCache ( $ cacheDir ) ; if ( ! ( $ this -> checkAdmin ( ) && "" !== $ flush ) ) { $ cacheContent = $ cacheDriver -> fetch ( $ cacheKey ) ; } else { $ cacheDriver -> delete ( $ cacheKey ) ; } // if not in cache if ( false === $ cacheContent ) { // render the view $ cacheContent = $ this -> renderRaw ( "feed" , array ( "_context_" => $ context , "_lang_" => $ lang , "_id_" => $ id ) ) ; // save cache $ cacheDriver -> save ( $ cacheKey , $ cacheContent , $ cacheExpire ) ; } $ response = new Response ( ) ; $ response -> setContent ( $ cacheContent ) ; $ response -> headers -> set ( 'Content-Type' , 'application/rss+xml' ) ; return $ response ; }
render the RSS feed

@param $context string   The context of the feed : catalog, content. default: catalog
@param $lang string      The lang of the feed : fr_FR, en_US, ... default: default language of the site
@param $id string        The id of the parent element. The id of the main parent category for catalog context.
The id of the content folder for content context
@return Response
@throws \RuntimeException
render the RSS feed