Skip to content

Commit 5dd2c54

Browse files
committed
backport container aware
1 parent 321955f commit 5dd2c54

File tree

8 files changed

+61
-17
lines changed

8 files changed

+61
-17
lines changed

.github/workflows/ci.yaml

+5-6
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,15 @@ jobs:
4242
with:
4343
php-version: ${{ matrix.php-version }}
4444
extensions: ctype, iconv, mysql
45+
tools: composer:v2, flex
4546
ini-values: memory_limit=-1
4647
coverage: none
4748

48-
- name: Add additional packages
49+
- name: Composer update
50+
env:
51+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
4952
run: |
50-
composer require symfony/symfony:${{ matrix.symfony-version }} --no-update
51-
if: ${{ matrix.symfony-version }}
52-
53-
- name: Install composer dependencies
54-
uses: ramsey/composer-install@v3
53+
composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction --no-progress
5554
5655
- name: Prepare phpcr odm doctrine dbal
5756
run: vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh

CHANGELOG.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
CHANGELOG
22
=========
33

4+
1.x
5+
===
6+
7+
1.6.0
8+
-----
9+
10+
* Deprecate using `Symfony\Component\DependencyInjection\ContainerAwareInterface` in favor of
11+
`PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface` as Symfony 7 dropped its
12+
ContainerAwareInterface.
13+
On Symfony 6, the legacy ContainerAwareInterface continues to e supported.
14+
415
1.5.0
516
-----
617

7-
* Allow installation with Symfony 7
18+
* Allow installation with Symfony 7 (! broken if you use `Symfony\Component\DependencyInjection\ContainerAwareInterface`)
819
* Drop support for PHP < 8.1 and modernize code
920

1021
1.4.0

composer.json

+11-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"php": "^8.1",
1717
"phpcr/phpcr-migrations": "^1.1",
1818
"phpcr/phpcr-implementation": "^2.1",
19-
"doctrine/phpcr-bundle": "^1.3 || ^2.0",
19+
"doctrine/phpcr-bundle": "^1.3 || ^2.0 || ^3.0",
2020
"symfony/config": "^5.4 || ^6.0 || ^7.0",
2121
"symfony/console": "^5.4 || ^6.0 || ^7.0",
2222
"symfony/dependency-injection": "^5.4 || ^6.0 || ^7.0",
@@ -25,10 +25,18 @@
2525
"require-dev": {
2626
"doctrine/doctrine-bundle": "^1.8 || ^2.0",
2727
"doctrine/phpcr-odm": "^1.4 || ^2.0",
28+
"doctrine/annotations": "^2.0",
29+
"jackalope/jackalope-doctrine-dbal": "^1.4 || ^2.0",
2830
"symfony/monolog-bundle": "^3.0",
2931
"symfony/phpunit-bridge": "^7.0",
30-
"symfony/symfony": "^5.4 || ^6.0 || ^7.0",
31-
"symfony-cmf/testing": "^2.1 || ^3.0 || ^4.0"
32+
"symfony-cmf/testing": "^4.0 || ^5.0",
33+
"symfony/security-bundle": "^5.4 || ^6.0 || ^7.0",
34+
"symfony/twig-bundle": "^5.4 || ^6.0 || ^7.0",
35+
"symfony/yaml": "^5.4 || ^6.0 || ^7.0",
36+
"symfony/translation": "^5.4 || ^6.0 || ^7.0",
37+
"symfony/form": "^5.4 || ^6.0 || ^7.0",
38+
"symfony/validator": "^5.4 || ^6.0 || ^7.0",
39+
"symfony/property-access": "^5.4 || ^6.0 || ^7.0"
3240
},
3341
"autoload": {
3442
"psr-4": {

src/Command/MigrateCommand.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
namespace PHPCR\PhpcrMigrationsBundle\Command;
1313

1414
use PHPCR\Migrations\MigratorFactory;
15+
use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputArgument;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Output\OutputInterface;
19-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
20+
use Symfony\Component\DependencyInjection\ContainerAwareInterface as SymfonyContainerAwareInterface;
2021
use Symfony\Component\DependencyInjection\ContainerInterface;
2122

2223
class MigrateCommand extends Command
@@ -77,6 +78,9 @@ public function execute(InputInterface $input, OutputInterface $output): int
7778
foreach ($migrator->getVersions() as $version) {
7879
if ($version instanceof ContainerAwareInterface) {
7980
$version->setContainer($this->container);
81+
} elseif ($version instanceof SymfonyContainerAwareInterface) {
82+
$version->setContainer($this->container);
83+
@trigger_error('Relying on '.SymfonyContainerAwareInterface::class.' is deprecated and will break when upgrading to Symfony 7. Use '.ContainerAwareInterface::class.' instead.', \E_USER_DEPRECATED);
8084
}
8185
}
8286

src/ContainerAwareInterface.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHPCR Migrations package
5+
*
6+
* (c) Daniel Leech <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PHPCR\PhpcrMigrationsBundle;
13+
14+
use Symfony\Component\DependencyInjection\ContainerInterface;
15+
16+
/**
17+
* Interface for migrations to get the Symfony container injected.
18+
*/
19+
interface ContainerAwareInterface
20+
{
21+
public function setContainer(?ContainerInterface $container = null): void;
22+
}

tests/Resources/App/AppKernel.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
class AppKernel extends TestKernel
2222
{
23-
public function configure()
23+
public function configure(): void
2424
{
2525
$this->requireBundleSets([
2626
'default',
@@ -34,14 +34,14 @@ public function configure()
3434
]);
3535
}
3636

37-
public function registerContainerConfiguration(LoaderInterface $loader)
37+
public function registerContainerConfiguration(LoaderInterface $loader): void
3838
{
3939
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
4040
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
4141
$loader->load(__DIR__.'/config/config.yml');
4242
}
4343

44-
protected function prepareContainer(ContainerBuilder $container)
44+
protected function prepareContainer(ContainerBuilder $container): void
4545
{
4646
parent::prepareContainer($container);
4747
$container->setParameter('cmf_testing.bundle_fqn', 'Phpcr\PhpcrMigrationsBundle\PhpcrMigrationsBundle');

tests/Resources/App/config/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ phpcr_migrations:
22
version_node_name: "jcr:migrations"
33

44
framework:
5-
annotations: true
5+
property_access: ~

tests/Resources/Bundle/TwoTestBundle/Resources/phpcr-migrations/Version201401011300.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
*/
1111

1212
use PHPCR\Migrations\VersionInterface;
13+
use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface;
1314
use PHPCR\SessionInterface;
14-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
1515
use Symfony\Component\DependencyInjection\ContainerInterface;
1616

1717
class Version201401011300 implements VersionInterface, ContainerAwareInterface
1818
{
1919
private $container;
2020

21-
public function setContainer(?ContainerInterface $container = null)
21+
public function setContainer(?ContainerInterface $container = null): void
2222
{
2323
$this->container = $container;
2424
}

0 commit comments

Comments
 (0)