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

deprecate templating component #459

Merged
merged 9 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ jobs:
- description: 'Lowest deps'
php: '8.0'
composer_option: '--prefer-lowest'
env:
SYMFONY_DEPRECATIONS_HELPER: max[self]=0
- description: 'Symfony 5.4'
php: '8.0'
symfony: 5.4.*
Expand All @@ -59,9 +57,11 @@ jobs:
with:
php-version: ${{ matrix.php }}
- run: |
sed -ri 's/"symfony\/(.+)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
sed -ri 's/"symfony\/(expression-language|framework-bundle|templating)": "(.+)"/"symfony\/\1": "'${{ matrix.symfony }}'"/' composer.json;
if: matrix.symfony
- run: composer config minimum-stability dev
if: matrix.dev
- run: composer update --no-interaction --no-progress --ansi ${{ matrix.composer_option }}
- run: vendor/bin/phpunit
env:
SYMFONY_DEPRECATIONS_HELPER: max[self]=1
garak marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

## 3.2.0 (2021-10-30)

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"require": {
"php": "^8.0",
"knplabs/knp-menu": "^3.3",
"symfony/deprecation-contracts": "^2.5 | ^3.3",
"symfony/framework-bundle": "^5.4 | ^6.0"
},
"require-dev": {
Expand Down
7 changes: 4 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ You can define these options if you need to change them:
# use "twig: false" to disable the Twig extension and the TwigRenderer
twig:
template: KnpMenuBundle::menu.html.twig
# if true, enables the helper for PHP templates
# if true, enables the helper for PHP templates
# support for templating is deprecated, it will be removed in next major version
templating: false
# the renderer to use, list is also available by default
default_renderer: twig
Expand All @@ -76,7 +77,7 @@ You can define these options if you need to change them:
xmlns:knp-menu="http://knplabs.com/schema/dic/menu">

<!--
templating: if true, enabled the helper for PHP templates
templating: if true, enable the helper for PHP templates (deprecated)
default-renderer: the renderer to use, list is also available by default
-->
<knp-menu:config
Expand All @@ -96,7 +97,7 @@ You can define these options if you need to change them:
'twig' => [
'template' => 'KnpMenuBundle::menu.html.twig'
],
// if true, enabled the helper for PHP templates
// if true, enabled the helper for PHP templates (deprecated)
'templating' => false,
// the renderer to use, list is also available by default
'default_renderer' => 'twig',
Expand Down
1 change: 1 addition & 0 deletions src/DependencyInjection/KnpMenuExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function load(array $configs, ContainerBuilder $container): void
$container->setParameter('knp_menu.renderer.twig.template', $config['twig']['template']);
}
if ($config['templating']) {
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.');
$loader->load('templating.xml');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Provider/BuilderAliasProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function getBuilder(string $bundleName, string $className): object
}

$builder = new $try();
if ($builder instanceof ContainerAwareInterface) {
if (interface_exists(ContainerAwareInterface::class) && $builder instanceof ContainerAwareInterface) {
garak marked this conversation as resolved.
Show resolved Hide resolved
$builder->setContainer($this->container);
}

Expand Down
10 changes: 9 additions & 1 deletion tests/Provider/BuilderAliasProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
use Knp\Bundle\MenuBundle\Provider\BuilderAliasProvider;
use Knp\Bundle\MenuBundle\Tests\Stubs\TestKernel;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;

class BuilderAliasProviderTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
if (!interface_exists(ContainerAwareInterface::class)) {
garak marked this conversation as resolved.
Show resolved Hide resolved
self::markTestSkipped();
}
}

public function testHas(): void
{
$provider = new BuilderAliasProvider(
Expand Down