Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30576: Upgrade ezsystems/ezplatform-design-engine to use Symfony 4 components #19

Merged
merged 3 commits into from
Jun 10, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function getConfiguration(array $config, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container)
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$loader->load('default_settings.yml');
$loader->load('services.yaml');
$loader->load('default_settings.yaml');

$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
Expand Down
2 changes: 1 addition & 1 deletion bundle/EzPlatformDesignEngineBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function build(ContainerBuilder $container)
/** @var \eZ\Bundle\EzPublishCoreBundle\DependencyInjection\EzPublishCoreExtension $eZExtension */
$eZExtension = $container->getExtension('ezpublish');
$eZExtension->addConfigParser(new DesignConfigParser());
$eZExtension->addDefaultSettings(__DIR__ . '/Resources/config', ['default_settings.yml']);
$eZExtension->addDefaultSettings(__DIR__ . '/Resources/config', ['default_settings.yaml']);

$container->addCompilerPass(new TwigThemePass());
$container->addCompilerPass(new AssetThemePass(), PassConfig::TYPE_OPTIMIZE);
Expand Down
21 changes: 15 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,24 @@
"email": "dev-team@ez.no"
}
],
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"ezsystems/ezpublish-kernel": "^6.0.0|^7.0|^8.0",
"twig/twig": "^1.27|^2.0",
"symfony/symfony": "^2.8.25|^3.1.6|^3.2.12|^3.3.5"
"ezsystems/ezpublish-kernel": "^8.0@dev",
"twig/twig": "^2.11",
"symfony/dependency-injection": "^4.3",
"symfony/http-kernel": "^4.3",
"symfony/http-foundation": "^4.3",
"symfony/config": "^4.3",
"symfony/finder": "^4.3",
"symfony/filesystem": "^4.3",
"symfony/asset": "^4.3",
"symfony/templating": "^4.3"
},
"require-dev": {
"phpunit/phpunit": "^5.7|^6.0",
"friendsofphp/php-cs-fixer": "~2.7.1",
"mikey179/vfsStream": "^1.6.3"
"phpunit/phpunit": "^8.1",
"friendsofphp/php-cs-fixer": "^2.15",
"mikey179/vfsstream": "^1.6"
},
"autoload": {
"psr-4": {
Expand Down
40 changes: 12 additions & 28 deletions lib/Templating/Twig/TwigThemeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,16 @@

use EzSystems\EzPlatformDesignEngine\Templating\TemplateNameResolverInterface;
use EzSystems\EzPlatformDesignEngine\Templating\TemplatePathRegistryInterface;
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
use Symfony\Component\Config\FileLocatorInterface;
use Symfony\Component\Templating\TemplateNameParserInterface;
use Twig_ExistsLoaderInterface;
use Twig_LoaderInterface;
use Twig\Loader\ExistsLoaderInterface;
use Twig\Loader\FilesystemLoader;
use Twig\Loader\LoaderInterface;
use Twig\Loader\SourceContextLoaderInterface;

/**
* Proxy to regular Twig FilesystemLoader.
* Decorates regular Twig FilesystemLoader.
* It resolves generic @ezdesign namespace to the actual current namespace.
*
* @note It extends \Symfony\Bundle\TwigBundle\Loader\FilesystemLoader because methods specific to this loader
* (e.g. related to paths and namespaces) are not part of an interface.
* It also does that by convenience for resolving @ezdesign templates paths in debug mode.
*/
class TwigThemeLoader extends FilesystemLoader implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
class TwigThemeLoader implements LoaderInterface, ExistsLoaderInterface, SourceContextLoaderInterface
{
/**
* @var TemplateNameResolverInterface
Expand All @@ -38,22 +33,18 @@ class TwigThemeLoader extends FilesystemLoader implements Twig_LoaderInterface,
private $pathRegistry;

/**
* @var Twig_LoaderInterface|Twig_ExistsLoaderInterface|\Twig_Loader_Filesystem
* @var FilesystemLoader
*/
private $innerFilesystemLoader;

public function __construct(
TemplateNameResolverInterface $templateNameResolver,
TemplatePathRegistryInterface $templatePathRegistry,
Twig_LoaderInterface $innerFilesystemLoader,
FileLocatorInterface $locator,
TemplateNameParserInterface $parser
LoaderInterface $innerFilesystemLoader
) {
$this->innerFilesystemLoader = $innerFilesystemLoader;
$this->nameResolver = $templateNameResolver;
$this->pathRegistry = $templatePathRegistry;

parent::__construct($locator, $parser);
}

public function exists($name)
Expand Down Expand Up @@ -84,7 +75,7 @@ public function isFresh($name, $time)
return $this->innerFilesystemLoader->isFresh($this->nameResolver->resolveTemplateName($name), $time);
}

public function getPaths($namespace = self::MAIN_NAMESPACE)
public function getPaths($namespace = FilesystemLoader::MAIN_NAMESPACE)
{
return $this->innerFilesystemLoader->getPaths($namespace);
}
Expand All @@ -94,25 +85,18 @@ public function getNamespaces()
return $this->innerFilesystemLoader->getNamespaces();
}

public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
public function setPaths($paths, $namespace = FilesystemLoader::MAIN_NAMESPACE)
{
parent::setPaths($paths, $namespace);
$this->innerFilesystemLoader->setPaths($paths, $namespace);
}

public function addPath($path, $namespace = self::MAIN_NAMESPACE)
public function addPath($path, $namespace = FilesystemLoader::MAIN_NAMESPACE)
{
parent::addPath($path, $namespace);
$this->innerFilesystemLoader->addPath($path, $namespace);
}

public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
public function prependPath($path, $namespace = FilesystemLoader::MAIN_NAMESPACE)
{
$this->innerFilesystemLoader->prependPath($path, $namespace);
}

public function findTemplate($template, $throw = true)
{
return parent::findTemplate($template, $throw);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something, but what change made this removal possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for late reply @lolautruche. This method became protected in parent class after migrating to Twig 2.11.

}
4 changes: 2 additions & 2 deletions tests/lib/Asset/ProvisionedPathResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class ProvisionedPathResolverTest extends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|AssetPathResolverInterface
* @var \PHPUnit\Framework\MockObject\MockObject|AssetPathResolverInterface
*/
private $innerResolver;

Expand All @@ -27,7 +27,7 @@ class ProvisionedPathResolverTest extends TestCase
*/
private $webrootDir;

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->innerResolver = $this->createMock(AssetPathResolverInterface::class);
Expand Down
8 changes: 4 additions & 4 deletions tests/lib/Asset/ThemePackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@
class ThemePackageTest extends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|\EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface
* @var \PHPUnit\Framework\MockObject\MockObject|\EzSystems\EzPlatformDesignEngine\Asset\AssetPathResolverInterface
*/
private $assetPathResolver;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Asset\PackageInterface
* @var \PHPUnit\Framework\MockObject\MockObject|\Symfony\Component\Asset\PackageInterface
*/
private $innerPackage;

/**
* @var \PHPUnit_Framework_MockObject_MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface
* @var \PHPUnit\Framework\MockObject\MockObject|\eZ\Publish\Core\MVC\ConfigResolverInterface
*/
private $configResolver;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Templating/ThemeTemplateNameResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
class ThemeTemplateNameResolverTest extends TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|ConfigResolverInterface
* @var \PHPUnit\Framework\MockObject\MockObject|ConfigResolverInterface
*/
private $configResolver;

public function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down