partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit c9f9437ad5a54a8b45639be0cb34698f3ca757a0
parent 915ba69d8b3cae5ef5f58bdd6b75cdb5da28cf6a
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu,  8 Oct 2015 17:34:28 +0200

Directly call the console commands instead of calling their methods

Diffstat:
Msrc/PartKeepr/SetupBundle/Controller/CacheWarmupSetupController.php | 35+++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/src/PartKeepr/SetupBundle/Controller/CacheWarmupSetupController.php b/src/PartKeepr/SetupBundle/Controller/CacheWarmupSetupController.php @@ -1,6 +1,9 @@ <?php namespace PartKeepr\SetupBundle\Controller; +use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\NullOutput; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -20,17 +23,33 @@ class CacheWarmupSetupController extends SetupController ); try { - $warmer = $this->get('cache_warmer'); - $warmer->enableOptionalWarmers(); - $warmer->warmUp($this->getParameter('kernel.cache_dir')); + $kernel = $this->get('kernel'); + $application = new Application($kernel); + $application->setAutoExit(false); + $output = new NullOutput(); + + $input = new ArrayInput(array( + 'command' => 'cache:warmup', + )); + + $application->run($input, $output); + + $input = new ArrayInput(array( + 'command' => 'generate:extjs:entities', + )); + + $application->run($input, $output); + + $input = new ArrayInput(array( + 'command' => 'assetic:dump', + )); + + $application->run($input, $output); - $reflectionService = $this->get("doctrine_reflection_service"); - $cacheDir = $this->get("kernel")->getCacheDir(); - $reflectionService->createCache($cacheDir); } catch (\Exception $e) { $response["success"] = false; $response["message"] = "Cache warm up error"; - $response["errors"] = [$e->getMessage()]; + $response["errors"] = [$e->getMessage(), $e->getTrace()]; } return new JsonResponse($response); @@ -41,7 +60,7 @@ class CacheWarmupSetupController extends SetupController */ public function cacheWarmupAction(Request $request) { - // Clear old cache + // Clear old cache. We don't do that directly as it could happen that old files are loaded prior clearing the cache $cacheDir = $this->get("kernel")->getRootDir()."/cache/prod"; $filesystem = $this->get("filesystem");