public function indexAction(Request $request)
    {
        $hosts = $this->getParameter('jantao_dev_sitemap.hosts');
        $webDir = rtrim($this->getParameter('jantao_dev_sitemap.web_dir'), '/');
        if (!empty($hosts)) {
            $host = $request->getHttpHost();
            if (strpos($host, ':') !== false) {
                $host = substr($host, 0, strpos($host, ':'));
            }
            if (in_array($host, $hosts) && file_exists("$webDir/robots.$host.txt")) {
                return new BinaryFileResponse("$webDir/robots.$host.txt");
            }
        }
        if (file_exists("$webDir/robots.txt")) {
            return new BinaryFileResponse("$webDir/robots.txt");
        } else {
            throw $this->createNotFoundException('robots.txt not found');
        }
    }
public function indexAction(Request $request)
    {
        $hosts = $this->getParameter('jantao_dev_sitemap.hosts');
        $webDir = rtrim($this->getParameter('jantao_dev_sitemap.web_dir'), '/');
        if (!empty($hosts)) {
            $host = $request->getHttpHost();
            if (strpos($host, ':') !== false) {
                $host = substr($host, 0, strpos($host, ':'));
            }
            if (in_array($host, $hosts) && file_exists("$webDir/robots.$host.txt")) {
                return new BinaryFileResponse("$webDir/robots.$host.txt");
            }
        }
        if (file_exists("$webDir/robots.txt")) {
            return new BinaryFileResponse("$webDir/robots.txt");
        } else {
            throw $this->createNotFoundException('robots.txt not found');
        }
    }
public function indexAction ( Request $ request ) { $ hosts = $ this -> getParameter ( 'jantao_dev_sitemap.hosts' ) ; $ webDir = rtrim ( $ this -> getParameter ( 'jantao_dev_sitemap.web_dir' ) , '/' ) ; if ( ! empty ( $ hosts ) ) { $ host = $ request -> getHttpHost ( ) ; if ( strpos ( $ host , ':' ) !== false ) { $ host = substr ( $ host , 0 , strpos ( $ host , ':' ) ) ; } if ( in_array ( $ host , $ hosts ) && file_exists ( "$webDir/robots.$host.txt" ) ) { return new BinaryFileResponse ( "$webDir/robots.$host.txt" ) ; } } if ( file_exists ( "$webDir/robots.txt" ) ) { return new BinaryFileResponse ( "$webDir/robots.txt" ) ; } else { throw $ this -> createNotFoundException ( 'robots.txt not found' ) ; } }
Switch robots.txt files by requested host and configuration

@param Request $request
@return BinaryFileResponse
@throws NotFoundException
Switch robots . txt files by requested host and configuration