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

Fix phpcr migrations for Symfony 7 without ContainerAwareInterface #700

Merged
merged 6 commits into from
Aug 27, 2024
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
15 changes: 13 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

$header = <<<EOF
This file is part of Sulu.

Expand All @@ -10,8 +19,10 @@
EOF;

$finder = PhpCsFixer\Finder::create()
->exclude(['Tests/Application/var/cache'])
->in(__DIR__);
->in(__DIR__)
->ignoreDotFiles(false)
->exclude(['Tests/Application/var'])
;

$config = new PhpCsFixer\Config();
$config->setRiskyAllowed(true)
Expand Down
2 changes: 1 addition & 1 deletion Content/ArticleDataItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ public function getResource()

public function getImage()
{
return;
return null;
}
}
2 changes: 1 addition & 1 deletion Content/ArticleDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function resolveResourceItems(

public function resolveDatasource($datasource, array $propertyParameter, array $options)
{
return;
return null;
}

private function getWebspaceKey(array $propertyParameter, array $options): ?string
Expand Down
38 changes: 38 additions & 0 deletions Resources/phpcr-migrations/ContainerAwareInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

/*
* This file is part of Sulu.
*
* (c) Sulu GmbH
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sulu\Bundle\ArticleBundle;

use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface as PhpcrContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface as SymfonyContainerAwareInterface;

if (\interface_exists(PhpcrContainerAwareInterface::class)) {
/**
* @internal
*/
interface ContainerAwareInterface extends PhpcrContainerAwareInterface
{
}
} elseif (\interface_exists(SymfonyContainerAwareInterface::class)) {
/**
* @internal
*/
interface ContainerAwareInterface extends SymfonyContainerAwareInterface
{
}
} else {
/**
* @internal
*/
interface ContainerAwareInterface
{
}
}
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version201702211450.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,26 @@
use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Sulu\Component\Localization\Localization;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Removes the property `i18n:<locale>-authors` and adds `i18n:<locale>-author`.
*/
class Version201702211450 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version201712041018.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,26 @@
use PHPCR\NodeInterface;
use PHPCR\SessionInterface;
use Sulu\Component\Localization\Localization;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Removes the property `sulu:author(ed)` and adds `i18n:<locale>-author(ed)`.
*/
class Version201712041018 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public const AUTHOR_PROPERTY_NAME = 'sulu:author';

Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version201811091000.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,27 @@
use PHPCR\NodeInterface;
use PHPCR\SessionInterface;
use Sulu\Component\Localization\Localization;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Removes the property `mainWebspace` and adds `i18n:<locale>-mainWebspace`.
* Removes the property `additionalWebspaces` and adds `i18n:<locale>-additionalWebspaces`.
*/
class Version201811091000 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public const MAIN_WEBSPACE_PROPERTY_NAME = 'mainWebspace';

Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version201905071542.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@

use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version201905071542 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version202005151141.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@

use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version202005151141 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version202005191117.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@

use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version202005191117 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version202005250920.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@

use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version202005250920 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version202210140922.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,26 @@

use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version202210140922 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
17 changes: 14 additions & 3 deletions Resources/phpcr-migrations/Version202210241106.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@
use PHPCR\Migrations\VersionInterface;
use PHPCR\SessionInterface;
use Sulu\Component\Localization\Localization;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Version202210241106 implements VersionInterface, ContainerAwareInterface
{
use ContainerAwareTrait;
/**
* @var ContainerInterface
*/
private $container;

public function setContainer(?ContainerInterface $container = null): void
{
if (null === $container) {
throw new \RuntimeException('Container is required to run this migration.');
}

$this->container = $container;
}

public function up(SessionInterface $session)
{
Expand Down
1 change: 0 additions & 1 deletion Resources/phpcr-migrations/Version202407111600.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use Jackalope\Query\Row;
use PHPCR\Migrations\VersionInterface;
use PHPCR\PhpcrMigrationsBundle\ContainerAwareInterface;
use PHPCR\SessionInterface;
use Sulu\Bundle\ArticleBundle\Document\Subscriber\RoutableSubscriber;
use Sulu\Component\Content\Metadata\Factory\StructureMetadataFactoryInterface;
Expand Down
Loading
Loading