Skip to content

Instantly share code, notes, and snippets.

@fabricekabongo
Created June 3, 2015 14:31
Show Gist options
  • Save fabricekabongo/9c9fc1cd4e81f6575820 to your computer and use it in GitHub Desktop.
Save fabricekabongo/9c9fc1cd4e81f6575820 to your computer and use it in GitHub Desktop.
How to bypass request scope issue on command with twig
try{
$em->flush();
}catch(InactiveScopeException $ex){
/*
* if the request scope is not yet created in another command
* we create a new request
* and try to save
*/
if (PHP_SAPI == 'cli') {
$request = new Request();
$request->create('/');
$this->getContainer()->enterScope('request');
$this->getContainer()->set('request', $request, 'request');
}
$em->flush();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment