Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion Bootstraps/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
Expand All @@ -97,7 +130,7 @@ public function getApplication()

return $app;
}

/**
* Returns the vendor directory containing autoload.php
*
Expand Down
2 changes: 2 additions & 0 deletions tests/SymfonyMocks/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

class Container
{
private $containerDir;

public function has($service)
{
return false;
Expand Down