From a479cc18506cc5e661a1e20c0e0cc0c68f7f22e2 Mon Sep 17 00:00:00 2001 From: Besnard Julien Date: Thu, 20 Oct 2016 14:43:41 +0200 Subject: [PATCH] =?UTF-8?q?gestion=20du=20kernel=20si=20AppCache=20est=20a?= =?UTF-8?q?ctiv=C3=A9=20(#41)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gestion du kernel si AppCache est activé * verification si le kernel implémente bien kernelinterface * refacto ->kernel * code redondant --- sources/wordpress/sf2/sf2plugin.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sources/wordpress/sf2/sf2plugin.php b/sources/wordpress/sf2/sf2plugin.php index e7383a3..cd6286f 100755 --- a/sources/wordpress/sf2/sf2plugin.php +++ b/sources/wordpress/sf2/sf2plugin.php @@ -95,7 +95,16 @@ private function loadSf2() } } else { $this->kernel = $kernel; - $this->container = $kernel->getContainer(); + + if ($this->kernel instanceof AppCache) { + $this->kernel = $this->kernel->getKernel(); + } + + if (!is_subclass_of($this->kernel, 'Symfony\Component\HttpKernel\KernelInterface')) { + throw new RuntimeException("Le kernel doit implémenter Symfony\Component\HttpKernel\KernelInterface"); + } + + $this->container = $this->kernel->getContainer(); } $wp_loader = $this->container->get('wordpress.loader'); $wp_loader->load();