diff --git a/Bootstraps/Symfony.php b/Bootstraps/Symfony.php index 748e696..4684621 100644 --- a/Bootstraps/Symfony.php +++ b/Bootstraps/Symfony.php @@ -5,6 +5,7 @@ use PHPPM\Symfony\StrongerNativeSessionStorage; use PHPPM\Utils; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Config\Resource\FileResource; use function PHPPM\register_file; /** @@ -87,6 +88,38 @@ public function getApplication() $app->booted = true; }, $app); + if ($this->debug) { + Utils::bindAndCall(function () use ($app) { + $container = $app->container; + + $containerClassName = substr(strrchr(get_class($app->container), "\\"), 1); + $metaName = $containerClassName . '.php.meta'; + + Utils::bindAndCall(function () use ($container) { + $container->publicContainerDir = $container->containerDir; + }, $container); + + if ($container->publicContainerDir === null) { + return; + } + + $metaContent = @file_get_contents($app->container->publicContainerDir . '/../' . $metaName); + + // Cannot read the Metadata, returning + if ($metaContent === false) { + return; + } + + $containerMetadata = unserialize($metaContent); + + foreach ($containerMetadata as $entry) { + if ($entry instanceof FileResource) { + register_file($entry->__toString()); + } + } + }, $app); + } + if ($trustedProxies = getenv('TRUSTED_PROXIES')) { Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST); } @@ -97,7 +130,7 @@ public function getApplication() return $app; } - + /** * Returns the vendor directory containing autoload.php * diff --git a/tests/SymfonyMocks/Container.php b/tests/SymfonyMocks/Container.php index 9f27388..4467305 100644 --- a/tests/SymfonyMocks/Container.php +++ b/tests/SymfonyMocks/Container.php @@ -4,6 +4,8 @@ class Container { + private $containerDir; + public function has($service) { return false;