Symfony\Bundle\FrameworkBundle\Client::getScript PHP Method

getScript() protected method

Returns the script to execute when the request must be insulated.
protected getScript ( Request $request ) : string
$request Symfony\Component\HttpFoundation\Request A Request instance
return string The script content
    protected function getScript($request)
    {
        $kernel = serialize($this->kernel);
        $request = serialize($request);

        $r = new \ReflectionObject($this->kernel);
        $path = $r->getFileName();

        return <<<EOF
<?php

require_once '$path';

\$kernel = unserialize('$kernel');
\$kernel->boot();
echo serialize(\$kernel->handle(unserialize('$request')));
EOF;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Returns the script to execute when the request must be insulated.
  *
  * It assumes that the autoloader is named 'autoload.php' and that it is
  * stored in the same directory as the kernel (this is the case for the
  * Symfony Standard Edition). If this is not your case, create your own
  * client and override this method.
  *
  * @param Request $request A Request instance
  *
  * @return string The script content
  */
 protected function getScript($request)
 {
     return $this->subject->getScript($request);
 }