src/Kunstmaan/SeoBundle/Controller/RobotsController.php
public function indexAction(Request $request)
    {
        $entity = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots')->findOneBy(array());
        $robots = $this->getParameter('robots_default');

        if ($entity && $entity->getRobotsTxt()) {
            $robots = $entity->getRobotsTxt();
        } else {
            $file = $request->getBasePath() . 'robots.txt';
            if (file_exists($file)) {
                $robots = file_get_contents($file);
            }
        }

        return array('robots' => $robots);
    }
public function indexAction(Request $request)
    {
        $entity = $this->getDoctrine()->getRepository('KunstmaanSeoBundle:Robots')->findOneBy(array());
        $robots = $this->getParameter('robots_default');

        if ($entity && $entity->getRobotsTxt()) {
            $robots = $entity->getRobotsTxt();
        } else {
            $file = $request->getBasePath() . 'robots.txt';
            if (file_exists($file)) {
                $robots = file_get_contents($file);
            }
        }

        return array('robots' => $robots);
    }
public function indexAction ( Request $ request ) { $ entity = $ this -> getDoctrine ( ) -> getRepository ( 'KunstmaanSeoBundle:Robots' ) -> findOneBy ( array ( ) ) ; $ robots = $ this -> getParameter ( 'robots_default' ) ; if ( $ entity && $ entity -> getRobotsTxt ( ) ) { $ robots = $ entity -> getRobotsTxt ( ) ; } else { $ file = $ request -> getBasePath ( ) . 'robots.txt' ; if ( file_exists ( $ file ) ) { $ robots = file_get_contents ( $ file ) ; } } return array ( 'robots' => $ robots ) ; }
Generates the robots.txt content when available in the database and falls back to normal robots.txt if exists

@Route(path="/robots.txt", name="KunstmaanSeoBundle_robots", defaults={"_format": "txt"})
@Template(template="@KunstmaanSeo/Admin/Robots/index.html.twig")

@param Request $request

@return array
Generates the robots . txt content when available in the database and falls back to normal robots . txt if exists