Created
June 3, 2015 14:31
-
-
Save fabricekabongo/9c9fc1cd4e81f6575820 to your computer and use it in GitHub Desktop.
How to bypass request scope issue on command with twig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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