Skip to content
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
6 changes: 2 additions & 4 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ jobs:
- php-version: '8.3'
- php-version: '8.4'
- php-version: '8.5'
symfony-version: '8.*'

steps:
- name: Checkout project
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -46,8 +47,5 @@ jobs:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Prepare phpunit
run: vendor/bin/simple-phpunit install

- name: Execute test cases
run: make test
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog
=========

3.2.0
-----

* Support Symfony 8.
* Rewrote service configurations from XML to PHP.

3.1.2
-----

Expand Down
40 changes: 37 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,43 @@ list:
@echo 'functional_tests_phpcr: will run functional tests with PHPCR'
@echo 'functional_tests_orm: will run functional tests with ORM'

include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk
include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk
include ${TESTING_SCRIPTS_DIR}/make/functional_tests_orm.mk
unit_tests:
@echo
@echo '+++ run unit tests +++'
ifeq ($(HAS_XDEBUG), 0)
@vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testsuite "unit tests"
else
@vendor/bin/phpunit --testsuite "unit tests"
endif

functional_tests_orm:
@if [ "${CONSOLE}" = "" ]; then echo "Console executable missing"; exit 1; fi
@echo
@echo '+++ create ORM database +++'
@${CONSOLE} doctrine:schema:drop --env=orm --force
@${CONSOLE} doctrine:database:create --env=orm || echo "Failed to create database. If this is sqlite, this is normal. Otherwise there will be an error with schema creation"
@${CONSOLE} doctrine:schema:create --env=orm
@echo '+++ run ORM functional tests +++'
ifeq ($(HAS_XDEBUG), 0)
@vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testsuite "functional tests with orm"
else
@vendor/bin/phpunit --testsuite "functional tests with orm"
endif
@${CONSOLE} doctrine:database:drop --force

functional_tests_phpcr:
@if [ "${CONSOLE}" = "" ]; then echo "Console executable missing"; exit 1; fi
@echo
@echo '+++ create PHPCR +++'
@${CONSOLE} doctrine:phpcr:init:dbal --drop --force
@${CONSOLE} doctrine:phpcr:repository:init
@echo '+++ run PHPCR functional tests +++'
ifeq ($(HAS_XDEBUG), 0)
@vendor/bin/phpunit --coverage-clover build/logs/clover.xml --testsuite "functional tests with phpcr"
else
@vendor/bin/phpunit --testsuite "functional tests with phpcr"
endif
@${CONSOLE} doctrine:database:drop --force

.PHONY: test
test: unit_tests functional_tests_phpcr functional_tests_orm
33 changes: 16 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,31 @@
"require": {
"php": "^8.1",
"symfony-cmf/routing": "^3.0.3",
"symfony/framework-bundle": "^6.4 || ^7.0"
"symfony/framework-bundle": "^6.4 || ^7.0 || ^8.0"
},
"require-dev": {
"doctrine/data-fixtures": "^1.0.0",
"doctrine/doctrine-bundle": "^2.8",
"doctrine/data-fixtures": "^1.2 || ^2.0",
"doctrine/doctrine-bundle": "^2.8 || ^3.0",
"doctrine/orm": "^2.9 || ^3.0.1",
"doctrine/phpcr-bundle": "^3.0",
"doctrine/phpcr-odm": "^2.0",
"doctrine/phpcr-odm": "^3.0",
"jackalope/jackalope-doctrine-dbal": "^2.0",
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-symfony": "^2.0",
"phpunit/phpunit": "^9.5.28",
"matthiasnoback/symfony-dependency-injection-test": "^4.1.0 || ^5.1.0",
"matthiasnoback/symfony-config-test": "^4.1.0 || ^5.1.0",
"symfony/phpunit-bridge": "^7.0.3",
"symfony/form": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.5",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/serializer": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"symfony/var-exporter": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony-cmf/testing": "5.0.2",
"phpunit/phpunit": "^10.5.63 || ^11.5.55 || ^13",
"matthiasnoback/symfony-dependency-injection-test": "^6.3",
"matthiasnoback/symfony-config-test": "^6.2",
"symfony/form": "^6.4 || ^7.0 || ^8.0",
"symfony/monolog-bundle": "^3.5 || ^4.0",
"symfony/security-bundle": "^6.4 || ^7.0 || ^8.0",
"symfony/serializer": "^6.4 || ^7.0 || ^8.0",
"symfony/translation": "^6.4 || ^7.0 || ^8.0",
"symfony/validator": "^6.4 || ^7.0 || ^8.0",
"symfony/var-exporter": "^6.4 || ^7.0 || ^8.0",
"symfony/twig-bundle": "^6.4 || ^7.0 || ^8.0",
"symfony-cmf/testing": "5.0.4",
"twig/twig": "^2.4.4 || ^3.0"
},
"suggest": {
Expand Down
18 changes: 9 additions & 9 deletions src/DependencyInjection/CmfRoutingExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;

Expand All @@ -30,7 +30,7 @@ final class CmfRoutingExtension extends Extension
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

if ($this->isConfigEnabled($container, $config['dynamic'])) {
$this->setupDynamicRouter($config['dynamic'], $container, $loader);
Expand All @@ -39,12 +39,12 @@ public function load(array $configs, ContainerBuilder $container): void
$this->setupChainRouter($config, $container, $loader);
$this->setupFormTypes($config, $container, $loader);

$loader->load('validators.xml');
$loader->load('validators.php');
}

private function setupChainRouter(array $config, ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load('routing-chain.xml');
$loader->load('routing-chain.php');

$container->setParameter('cmf_routing.replace_symfony_router', $config['chain']['replace_symfony_router']);

Expand All @@ -57,7 +57,7 @@ private function setupChainRouter(array $config, ContainerBuilder $container, Lo

private function setupFormTypes(array $config, ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load('form-type.xml');
$loader->load('form-type.php');

if (\array_key_exists('dynamic', $config)) {
$routeTypeTypeDefinition = $container->getDefinition('cmf_routing.route_type_form_type');
Expand All @@ -73,7 +73,7 @@ private function setupFormTypes(array $config, ContainerBuilder $container, Load
*/
private function setupDynamicRouter(array $config, ContainerBuilder $container, LoaderInterface $loader): void
{
$loader->load('routing-dynamic.xml');
$loader->load('routing-dynamic.php');

$container->setParameter('cmf_routing.redirectable_url_matcher', $config['redirectable_url_matcher']);

Expand Down Expand Up @@ -205,7 +205,7 @@ private function setupDynamicRouter(array $config, ContainerBuilder $container,

private function loadPhpcrProvider(array $config, LoaderInterface $loader, ContainerBuilder $container, array $locales, $matchImplicitLocale): void
{
$loader->load('provider-phpcr.xml');
$loader->load('provider-phpcr.php');

$container->setParameter('cmf_routing.backend_type_phpcr', true);
$container->setParameter('cmf_routing.dynamic.persistence.phpcr.route_basepaths', array_values(array_unique($config['route_basepaths'])));
Expand Down Expand Up @@ -234,12 +234,12 @@ private function loadInitializer(LoaderInterface $loader, ContainerBuilder $cont
$initializedBasepaths
);

$loader->load('initializer-phpcr.xml');
$loader->load('initializer-phpcr.php');
}

private function loadOrmProvider(array $config, LoaderInterface $loader, ContainerBuilder $container, $matchImplicitLocale): void
{
$loader->load('provider-orm.xml');
$loader->load('provider-orm.php');

$container->setParameter('cmf_routing.backend_type_orm', true);
$container->setParameter('cmf_routing.dynamic.persistence.orm.manager_name', $config['manager_name']);
Expand Down
11 changes: 11 additions & 0 deletions src/Resources/config/form-type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->set('cmf_routing.route_type_form_type', \Symfony\Cmf\Bundle\RoutingBundle\Form\Type\RouteTypeType::class)
->tag('form.type', ['alias' => 'cmf_routing_route_type']);
};
11 changes: 0 additions & 11 deletions src/Resources/config/form-type.xml

This file was deleted.

15 changes: 15 additions & 0 deletions src/Resources/config/initializer-phpcr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->set('cmf_routing.initializer', \Doctrine\Bundle\PHPCRBundle\Initializer\GenericInitializer::class)
->args([
'CmfRoutingBundle',
'%cmf_routing.dynamic.persistence.phpcr.initialized_basepaths%',
])
->tag('doctrine_phpcr.initializer');
};
16 changes: 0 additions & 16 deletions src/Resources/config/initializer-phpcr.xml

This file was deleted.

30 changes: 30 additions & 0 deletions src/Resources/config/provider-orm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->set('cmf_routing.orm_content_repository', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\ContentRepository::class)
->args([service('doctrine')])
->call('setManagerName', ['%cmf_routing.dynamic.persistence.orm.manager_name%']);

$services->alias('cmf_routing.content_repository', 'cmf_routing.orm_content_repository');

$services->set('cmf_routing.orm_candidates', \Symfony\Cmf\Component\Routing\Candidates\Candidates::class)
->args([
'%cmf_routing.dynamic.locales%',
'%cmf_routing.dynamic.limit_candidates%',
]);

$services->set('cmf_routing.route_provider', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\RouteProvider::class)
->public()
->args([
service('doctrine'),
service('cmf_routing.orm_candidates'),
'%cmf_routing.dynamic.persistence.orm.route_class%',
])
->call('setManagerName', ['%cmf_routing.dynamic.persistence.orm.manager_name%'])
->call('setRouteCollectionLimit', ['%cmf_routing.route_collection_limit%']);
};
31 changes: 0 additions & 31 deletions src/Resources/config/provider-orm.xml

This file was deleted.

52 changes: 52 additions & 0 deletions src/Resources/config/provider-phpcr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

return static function (ContainerConfigurator $container) {
$services = $container->services();
$parameters = $container->parameters();

$services->set('cmf_routing.phpcr_route_provider', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RouteProvider::class)
->args([
service('doctrine_phpcr'),
service('cmf_routing.phpcr_candidates_prefix'),
null,
service('logger')->ignoreOnInvalid(),
])
->call('setManagerName', ['%cmf_routing.dynamic.persistence.phpcr.manager_name%'])
->call('setRouteCollectionLimit', ['%cmf_routing.route_collection_limit%']);

$services->alias('cmf_routing.route_provider', 'cmf_routing.phpcr_route_provider')
->public();

$services->set('cmf_routing.phpcr_candidates_prefix', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\PrefixCandidates::class)
->args([
'%cmf_routing.dynamic.persistence.phpcr.route_basepaths%',
'%cmf_routing.dynamic.locales%',
service('doctrine_phpcr'),
'%cmf_routing.dynamic.limit_candidates%',
])
->call('setManagerName', ['%cmf_routing.dynamic.persistence.phpcr.manager_name%']);

$services->set('cmf_routing.phpcr_content_repository', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\ContentRepository::class)
->args([service('doctrine_phpcr')])
->call('setManagerName', ['%cmf_routing.dynamic.persistence.phpcr.manager_name%']);

$services->alias('cmf_routing.content_repository', 'cmf_routing.phpcr_content_repository');

$services->set('cmf_routing.phpcrodm_route_idprefix_listener', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\IdPrefixListener::class)
->args([service('cmf_routing.phpcr_candidates_prefix')])
->tag('doctrine_phpcr.event_listener', ['event' => 'postLoad'])
->tag('doctrine_phpcr.event_listener', ['event' => 'postPersist'])
->tag('doctrine_phpcr.event_listener', ['event' => 'postMove']);

$services->set('cmf_routing.phpcrodm_route_locale_listener', \Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\LocaleListener::class)
->args([
service('cmf_routing.phpcr_candidates_prefix'),
'%cmf_routing.dynamic.locales%',
'%cmf_routing.dynamic.auto_locale_pattern%',
])
->tag('doctrine_phpcr.event_listener', ['event' => 'postLoad'])
->tag('doctrine_phpcr.event_listener', ['event' => 'postPersist'])
->tag('doctrine_phpcr.event_listener', ['event' => 'postMove']);
};
Loading
Loading