Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
* 1.x:
  Release 1.8.1 (#52)
  Make sure we are compatible with sf6
  • Loading branch information
Nyholm committed Aug 20, 2021
2 parents 1c1922b + 5d82bed commit 6819d09
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## 1.8.1

### Fixed

- Symfony 6 compatibility issues

## 1.8.0

### Added
Expand Down
14 changes: 14 additions & 0 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.8.1@f73f2299dbc59a3e6c4d66cff4605176e728ee69">
<file src="src/AppKernel.php">
<InvalidReturnStatement occurrences="1">
<code>$bundles</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>iterable</code>
</InvalidReturnType>
<ReservedWord occurrences="1">
<code>$loader-&gt;getResolver()-&gt;resolve($file, 'php')</code>
</ReservedWord>
<UndefinedClass occurrences="1">
<code>RouteCollectionBuilder</code>
</UndefinedClass>
</file>
<file src="src/BaseBundleTestCase.php">
<UndefinedClass occurrences="1">
<code>ResettableContainerInterface</code>
Expand Down
44 changes: 33 additions & 11 deletions src/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouteCollectionBuilder;

/**
Expand Down Expand Up @@ -79,17 +82,17 @@ public function addConfigFile($configFile)
$this->configFiles[] = $configFile;
}

public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir().'/NyholmBundleTest/'.$this->cachePrefix;
}

public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir().'/NyholmBundleTest/log';
}

public function getProjectDir()
public function getProjectDir(): string
{
if (null === $this->fakedProjectDir) {
return realpath(__DIR__.'/../../../../');
Expand All @@ -114,7 +117,7 @@ public function setProjectDir($projectDir)
$this->fakedProjectDir = $projectDir;
}

public function registerBundles()
public function registerBundles(): iterable
{
$this->bundlesToRegister = array_unique($this->bundlesToRegister);
$bundles = [];
Expand Down Expand Up @@ -169,21 +172,40 @@ public function registerContainerConfiguration(LoaderInterface $loader)
*/
public function loadRoutes(LoaderInterface $loader)
{
$routes = new RouteCollectionBuilder($loader);
if (class_exists(RoutingConfigurator::class)) {
$file = (new \ReflectionObject($this))->getFileName();
/** @var RoutingPhpFileLoader $kernelLoader */
$kernelLoader = $loader->getResolver()->resolve($file, 'php');
$kernelLoader->setCurrentDir(\dirname($file));

$collection = new RouteCollection();
$configurator = new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment());

if ($this->routingFile) {
$configurator->import($this->routingFile);
} else {
$configurator->import(__DIR__.'/config/routing.yml');
}

if ($this->routingFile) {
$routes->import($this->routingFile);
return $collection;
} else {
$routes->import(__DIR__.'/config/routing.yml');
}
// Legacy
$routes = new RouteCollectionBuilder($loader);

return $routes->build();
if ($this->routingFile) {
$routes->import($this->routingFile);
} else {
$routes->import(__DIR__.'/config/routing.yml');
}

return $routes->build();
}
}

/**
* {@inheritdoc}
*/
protected function buildContainer()
protected function buildContainer(): ContainerBuilder
{
$container = parent::buildContainer();

Expand Down

0 comments on commit 6819d09

Please sign in to comment.