Skip to content

Commit

Permalink
update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Jan 15, 2024
1 parent f876aa3 commit 6bd61de
Show file tree
Hide file tree
Showing 25 changed files with 125 additions and 146 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@ jobs:
test:
name: "PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }}"
runs-on: "ubuntu-20.04"
env:
SYMFONY_REQUIRE: ${{matrix.symfony-require}}

strategy:
fail-fast: false
matrix:
include:
- php-version: "8.0"
- php-version: "8.1"
phpunit-version: "9.5"
phpunit-flags: "-v --coverage-text"
symfony-version: "6.0.*"

- php-version: "8.0"
phpunit-version: "9.5"
symfony-version: "6.0.*"

- php-version: "8.1"
phpunit-version: "9.5"

Expand All @@ -47,11 +45,13 @@ jobs:
extensions: "pdo, pdo_sqlite"
tools: "composer:v2"

- name: "Require Specific Symfony Version"
- name: "Require specific symfony version"
if: "${{ matrix.symfony-version }}"
run: "composer require --no-update symfony/symfony:${{ matrix.symfony-version }}"
run: |
composer require --no-update symfony/flex
composer config --no-plugins allow-plugins.symfony/flex true
- name: "Require Additional dependencies"
- name: "Require additional dependencies"
if: "${{ matrix.composer-require }}"
run: "composer require --no-update ${{ matrix.composer-require }}"

Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Changelog
The configuration of metadata_cache_driver changed. By default, it creates an `array` cache.
To configure a service, specify `type: service` and specify your service in the `id` property.
To use a cache pool, specify the service id of that pool.
* Removed support for namespace alias, use the FQN names.
* Introduced the ManagerRegistryInterface for the ManagerRegistry and adjusted the service alias for autowiring to the interface.
* The following container parameters are no longer taken into account (memcache and apc seem to have never been used anyways).
If you have customised the array cache class, please check if this is still needed - and note that starting from this version,
Expand All @@ -27,6 +28,7 @@ Changelog
doctrine_phpcr.odm.cache.memcached_port
doctrine_phpcr.odm.cache.memcached_instance.class
doctrine_phpcr.odm.cache.xcache.class

* If no username is defined for a session, and if you use Jackalope >= 2.0, the
credentials service for this session is no longer created and `null` is
passed as credentials.
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
"require": {
"php": "^8.0",
"ext-dom": "*",
"phpcr/phpcr-utils": "^1.3 || ^2.0",
"symfony/cache": "^5.4 || ^6.0 || ^7.0",
"symfony/doctrine-bridge": "^5.4 || ^6.0 || ^7.0",
Expand All @@ -37,14 +38,14 @@
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.0.3",
"doctrine/phpcr-odm": "^2.0",
"doctrine/phpcr-odm": "2.x-dev",
"doctrine/orm": "^2.0 || ^3.0",
"jackalope/jackalope-doctrine-dbal": "^2.0",
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
"matthiasnoback/symfony-dependency-injection-test": "^4.3.1 || ^5.0",
"symfony/asset": "^5.4 || ^6.0 || ^7.0",
"symfony/browser-kit": "^5.4 || ^6.0 || ^7.0",
"symfony/css-selector": "^5.4 || ^6.0 || ^7.0",
"symfony/error-handler": "^4.4 || ^5.0 || ^6.0",
"symfony/error-handler": "^5.4 || ^6.0 || ^7.0",
"symfony/form": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.0 || ^7.0",
"symfony/monolog-bundle": "^3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/CacheWarmer/UniqueNodeTypeCacheWarmer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function isOptional(): bool
return true;
}

public function warmUp($cacheDir): array
public function warmUp(string $cacheDir, ?string $buildDir = null): array
{
$helper = new UniqueNodeTypeHelper();

Expand Down
25 changes: 12 additions & 13 deletions src/Command/LoadFixtureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
namespace Doctrine\Bundle\PHPCRBundle\Command;

use Doctrine\Bundle\PHPCRBundle\DataFixtures\PHPCRExecutor;
use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\Common\DataFixtures\Loader;
use Doctrine\Common\DataFixtures\Purger\PHPCRPurger;
use Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper;
use InvalidArgumentException;
use PHPCR\Util\Console\Command\BaseCommand;
use Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

/**
* Command to load PHPCR-ODM fixtures.
Expand All @@ -26,12 +25,18 @@
*/
class LoadFixtureCommand extends BaseCommand
{
use ContainerAwareTrait;
private const NAME = 'doctrine:phpcr:fixtures:load';

public function __construct(
private InitializerManager $initializerManager
) {
parent::__construct(self::NAME);
}

protected function configure(): void
{
$this
->setName('doctrine:phpcr:fixtures:load')
->setName(self::NAME)
->setDescription('Load data fixtures to your PHPCR database.')
->addOption('fixtures', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'The directory or file to load data fixtures from.')
->addOption('append', null, InputOption::VALUE_NONE, 'Append the data fixtures to the existing data - will not purge the workspace.')
Expand Down Expand Up @@ -100,7 +105,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
}

$loader = new ContainerAwareLoader($this->container);
$loader = new Loader();
foreach ($paths as $path) {
if (is_dir($path)) {
$loader->loadFromDirectory($path);
Expand All @@ -118,13 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$purger = new PHPCRPurger($dm);

if ($noInitialize) {
$initializerManager = null;
} else {
$initializerManager = $this->container->get('doctrine_phpcr.initializer_manager');
}

$executor = new PHPCRExecutor($dm, $purger, $initializerManager);
$executor = new PHPCRExecutor($dm, $purger, $noInitialize ? null : $this->initializerManager);
$executor->setLogger(function ($message) use ($output) {
$output->writeln(sprintf(' <comment>></comment> <info>%s</info>', $message));
});
Expand Down
12 changes: 9 additions & 3 deletions src/Command/MigratorMigrateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

class MigratorMigrateCommand extends BaseCommand
{
use ContainerAwareTrait;
private const NAME = 'doctrine:phpcr:migrator:migrate';

public function __construct(
private ContainerInterface $container
) {
parent::__construct(self::NAME);
}

protected function configure(): void
{
$this
->setName('doctrine:phpcr:migrator:migrate')
->setName(self::NAME)
->setDescription('Migrates PHPCR data.')
->addArgument('migrator_name', InputArgument::OPTIONAL, 'The name of the alias/service to be used to migrate the data.')
->addOption('identifier', null, InputOption::VALUE_REQUIRED, 'Path or UUID of the node to migrate', '/')
Expand Down
42 changes: 10 additions & 32 deletions src/Command/NodeDumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,30 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Wrapper to use this command in the symfony console with multiple sessions.
*
* @author Daniel Barsotti <daniel.barsotti@liip.ch>
*/
class NodeDumpCommand extends BaseDumpCommand implements ContainerAwareInterface
class NodeDumpCommand extends BaseDumpCommand
{
private ?ContainerInterface $container = null;
private PhpcrConsoleDumperHelper $consoleDumper;
private const NAME = 'doctrine:phpcr:node:dump';

protected function getContainer(): ContainerInterface
{
if (null === $this->container) {
$this->container = $this->getApplication()->getKernel()->getContainer();
}

return $this->container;
}

public function setContainer(ContainerInterface $container = null): void
{
if (!$container) {
unset($this->container);

return;
}

$this->container = $container;
}

public function setConsoleDumper(PhpcrConsoleDumperHelper $consoleDumper): void
{
$this->consoleDumper = $consoleDumper;
public function __construct(
private PhpcrConsoleDumperHelper $consoleDumper,
private int $dumpMaxLineLength
) {
parent::__construct(self::NAME);
}

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

$this
->setName('doctrine:phpcr:node:dump')
->setName(self::NAME)
->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
;
}
Expand All @@ -66,10 +46,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$helperSet = $application->getHelperSet();
$helperSet->set($this->consoleDumper);

if (!$input->hasOption('max_line_length')
&& $this->getContainer()->hasParameter('doctrine_phpcr.dump_max_line_length')
) {
$input->setOption('max_line_length', $this->getContainer()->getParameter('doctrine_phpcr.dump_max_line_length'));
if (!$input->hasOption('max_line_length')) {
$input->setOption('max_line_length', $this->dumpMaxLineLength);
}

return parent::execute($input, $output);
Expand Down
17 changes: 11 additions & 6 deletions src/Command/RepositoryInitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Doctrine\Bundle\PHPCRBundle\Command;

use Doctrine\Bundle\PHPCRBundle\Initializer\InitializerManager;
use Doctrine\ODM\PHPCR\Tools\Console\Command\RegisterSystemNodeTypesCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

/**
* Command to collect init operations from any interested bundles.
Expand All @@ -16,14 +16,20 @@
*/
class RepositoryInitCommand extends Command
{
use ContainerAwareTrait;
private const NAME = 'doctrine:phpcr:repository:init';

public function __construct(
private InitializerManager $initializerManager
) {
parent::__construct(self::NAME);
}

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

$this
->setName('doctrine:phpcr:repository:init')
->setName(self::NAME)
->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
->setDescription('Initialize the PHPCR repository.')
->setHelp(<<<'EOT'
Expand All @@ -47,12 +53,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$command->execute($input, $output);
}

$initializerManager = $this->container->get('doctrine_phpcr.initializer_manager');
$initializerManager->setLoggingClosure(function ($message) use ($output) {
$this->initializerManager->setLoggingClosure(function ($message) use ($output) {
$output->writeln($message);
});

$initializerManager->initialize($input->getOption('session'));
$this->initializerManager->initialize($input->getOption('session'));

return 0;
}
Expand Down
1 change: 0 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ private function getOdmDocumentManagersNode(): NodeDefinition
->scalarNode('mapping')->defaultValue(true)->end()
->scalarNode('type')->end()
->scalarNode('dir')->end()
->scalarNode('alias')->end()
->scalarNode('prefix')->end()
->booleanNode('is_bundle')->end()
->end()
Expand Down
15 changes: 10 additions & 5 deletions src/DependencyInjection/DoctrinePHPCRExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Doctrine\Bundle\PHPCRBundle\DependencyInjection;

use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand;
use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand;
use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
use Doctrine\ODM\PHPCR\Document\Generic;
use Doctrine\ODM\PHPCR\DocumentManagerInterface;
Expand Down Expand Up @@ -62,8 +64,14 @@ public function load(array $configs, ContainerBuilder $container)

$this->loader->load('phpcr.xml');
$this->loader->load('commands.xml');
if (class_exists(BaseJackrabbitCommand::class)) {
$this->loader->load('jackrabbit-commands.xml');
}
if (class_exists(BaseInitDoctrineDbalCommand::class)) {
$this->loader->load('jackalope_doctrine_dbal-commands.xml');
}

// default values in case no odm is configured. the manager registry needs these variables to be defined.
// default values in case no odm is configured. the manager registry needs these variables to be defined.
// if odm is enabled, the parameters are overwritten later in the `loadOdm` section.
$container->setParameter('doctrine_phpcr.odm.document_managers', []);
$container->setParameter('doctrine_phpcr.odm.default_document_manager', '');
Expand Down Expand Up @@ -500,9 +508,8 @@ private function loadOdmDocumentManager(array $documentManager, ContainerBuilder

private function loadOdmDocumentManagerMappingInformation(array $documentManager, Definition $odmConfig, ContainerBuilder $container): void
{
// reset state of drivers and alias map. They are only used by this methods and children.
// reset state of drivers map. It is only used by this methods and children.
$this->drivers = [];
$this->aliasMap = [];

if (!class_exists(Generic::class)) {
throw new \RuntimeException('PHPCR ODM is activated in the config but does not seem loadable.');
Expand All @@ -519,8 +526,6 @@ private function loadOdmDocumentManagerMappingInformation(array $documentManager
];
$this->loadMappingInformation($documentManager, $container);
$this->registerMappingDrivers($documentManager, $container);

$odmConfig->addMethodCall('setDocumentNamespaces', [$this->aliasMap]);
}

/**
Expand Down
7 changes: 1 addition & 6 deletions src/DoctrinePHPCRBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\InitializerPass;
use Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\MigratorPass;
use Doctrine\Bundle\PHPCRBundle\OptionalCommand\Jackalope\InitDoctrineDbalCommand;
use Doctrine\Bundle\PHPCRBundle\OptionalCommand\Jackalope\JackrabbitCommand;
use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\DocumentConvertTranslationCommand;
use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\DocumentMigrateClassCommand;
use Doctrine\Bundle\PHPCRBundle\OptionalCommand\ODM\InfoDoctrineCommand;
Expand All @@ -14,7 +13,6 @@
use Doctrine\ODM\PHPCR\Version;
use Jackalope\Session;
use Jackalope\Tools\Console\Command\InitDoctrineDbalCommand as BaseInitDoctrineDbalCommand;
use Jackalope\Tools\Console\Command\JackrabbitCommand as BaseJackrabbitCommand;
use Symfony\Bridge\Doctrine\DependencyInjection\CompilerPass\RegisterEventListenersAndSubscribersPass;
use Symfony\Component\Console\Application;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
Expand Down Expand Up @@ -50,9 +48,6 @@ public function registerCommands(Application $application): void
$application->add(new DocumentConvertTranslationCommand());
}

if (class_exists(BaseJackrabbitCommand::class)) {
$application->add(new JackrabbitCommand());
}
if (class_exists(BaseInitDoctrineDbalCommand::class)) {
$application->add(new InitDoctrineDbalCommand());
}
Expand All @@ -68,7 +63,7 @@ public function boot(): void
$container = &$this->container;

$this->autoloader = function ($class) use ($namespace, $dir, &$container) {
if (0 === strpos($class, $namespace)) {
if (str_starts_with($class, $namespace)) {
$fileName = str_replace('\\', '', substr($class, \strlen($namespace) + 1));
$file = $dir.\DIRECTORY_SEPARATOR.$fileName.'.php';

Expand Down
Loading

0 comments on commit 6bd61de

Please sign in to comment.