Skip to content

Commit 6c34e96

Browse files
authored
Merge pull request #459 from garak/deprecate-templating
deprecate templating component
2 parents fd2696b + b2b9ead commit 6c34e96

File tree

8 files changed

+17
-8
lines changed

8 files changed

+17
-8
lines changed

.github/workflows/build.yaml

+1-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
- description: 'Lowest deps'
3838
php: '8.0'
3939
composer_option: '--prefer-lowest'
40-
env:
41-
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
4240
- description: 'Symfony 5.4'
4341
php: '8.0'
4442
symfony: 5.4.*
@@ -59,7 +57,7 @@ jobs:
5957
with:
6058
php-version: ${{ matrix.php }}
6159
- run: |
62-
sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
60+
sed -ri 's/"symfony\/(expression-language|framework-bundle|templating)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
6361
if: matrix.symfony
6462
- run: composer config minimum-stability dev
6563
if: matrix.dev

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* Increased minimum PHP version to 8.0 (to be consistent with KnpMenu 3.4)
44
* Dropped support for Symfony 3 and 4
5+
* Deprecated use of Symfony templating component
56

67
## 3.2.0 (2021-10-30)
78

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"require": {
2222
"php": "^8.0",
2323
"knplabs/knp-menu": "^3.3",
24+
"symfony/deprecation-contracts": "^2.5 | ^3.3",
2425
"symfony/framework-bundle": "^5.4 | ^6.0"
2526
},
2627
"require-dev": {

docs/index.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ You can define these options if you need to change them:
6363
# use "twig: false" to disable the Twig extension and the TwigRenderer
6464
twig:
6565
template: KnpMenuBundle::menu.html.twig
66-
# if true, enables the helper for PHP templates
66+
# if true, enables the helper for PHP templates
67+
# support for templating is deprecated, it will be removed in next major version
6768
templating: false
6869
# the renderer to use, list is also available by default
6970
default_renderer: twig
@@ -76,7 +77,7 @@ You can define these options if you need to change them:
7677
xmlns:knp-menu="http://knplabs.com/schema/dic/menu">
7778
7879
<!--
79-
templating: if true, enabled the helper for PHP templates
80+
templating: if true, enable the helper for PHP templates (deprecated)
8081
default-renderer: the renderer to use, list is also available by default
8182
-->
8283
<knp-menu:config
@@ -96,7 +97,7 @@ You can define these options if you need to change them:
9697
'twig' => [
9798
'template' => 'KnpMenuBundle::menu.html.twig'
9899
],
99-
// if true, enabled the helper for PHP templates
100+
// if true, enable the helper for PHP templates (deprecated)
100101
'templating' => false,
101102
// the renderer to use, list is also available by default
102103
'default_renderer' => 'twig',

src/DependencyInjection/KnpMenuExtension.php

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function load(array $configs, ContainerBuilder $container): void
3636
$container->setParameter('knp_menu.renderer.twig.template', $config['twig']['template']);
3737
}
3838
if ($config['templating']) {
39+
trigger_deprecation('knplabs/knp-menu-bundle', '3.3', 'Using the templating component is deprecated since version 3.3, this option will be removed in version 4.');
3940
$loader->load('templating.xml');
4041
}
4142

tests/DependencyInjection/KnpMenuExtensionTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ public function testDisableTwig(): void
4747
$this->assertFalse($container->hasDefinition('knp_menu.renderer.twig'));
4848
}
4949

50-
public function testEnsablePhpTemplates(): void
50+
/**
51+
* @group legacy
52+
*/
53+
public function testEnablePhpTemplates(): void
5154
{
5255
$container = new ContainerBuilder();
5356
$loader = new KnpMenuExtension();

tests/Provider/BuilderAliasProviderTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Knp\Bundle\MenuBundle\Provider\BuilderAliasProvider;
66
use Knp\Bundle\MenuBundle\Tests\Stubs\TestKernel;
77
use PHPUnit\Framework\TestCase;
8-
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
8+
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
99

1010
class BuilderAliasProviderTest extends TestCase
1111
{
@@ -44,6 +44,9 @@ public function testGetExistentMenu(): void
4444

4545
public function testGetContainerAwareMenu(): void
4646
{
47+
if (!interface_exists(ContainerAwareInterface::class)) {
48+
self::markTestSkipped('missing interface');
49+
}
4750
$item = $this->getMockBuilder('Knp\Menu\ItemInterface')->getMock();
4851
// mock the factory to return a set value when the builder creates the menu
4952
$factory = $this->getMockBuilder('Knp\Menu\FactoryInterface')->getMock();

tests/Templating/MenuHelperTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Test for MenuHelper class.
1111
*
1212
* @author Leszek Prabucki <[email protected]>
13+
* @group legacy
1314
*/
1415
class MenuHelperTest extends TestCase
1516
{

0 commit comments

Comments
 (0)