Skip to content

Commit

Permalink
Merge pull request #285 from symfony-cmf/sf6
Browse files Browse the repository at this point in the history
allow installation with symfony 6
  • Loading branch information
dbu authored May 4, 2024
2 parents 43c99e0 + 64234eb commit 511d1ff
Show file tree
Hide file tree
Showing 43 changed files with 457 additions and 960 deletions.
29 changes: 11 additions & 18 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,24 @@ jobs:
name: 'PHP ${{ matrix.php-version }}, Symfony ${{ matrix.symfony-version }} ${{ matrix.dependencies}}'
runs-on: ubuntu-20.04
env:
SYMFONY_PHPUNIT_VERSION: 8
SYMFONY_PHPUNIT_VERSION: 9
SYMFONY_DEPRECATIONS_HELPER: "/.*each.*/"
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}

strategy:
fail-fast: false
matrix:
include:
- php-version: '7.4'
- php-version: '8.1'
dependencies: 'lowest'
- php-version: '7.4'
symfony-version: 4.4.*
test-installation: true
- php-version: '7.4'
symfony-version: 5.0.*
test-installation: true
- php-version: '8.0'
symfony-version: 5.1.*
test-installation: true
- php-version: '8.1'
- php-version: '8.2'
- php-version: '8.3'
symfony-version: 6.4.*

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

- name: Install and configure PHP
uses: shivammathur/setup-php@v2
Expand All @@ -45,17 +40,15 @@ jobs:
tools: 'composer:v2'

- name: Install Symfony Flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex
run: |
composer global require --no-progress --no-scripts --no-plugins symfony/flex
composer global config --no-plugins allow-plugins.symfony/flex true
- name: Install dependencies with Composer
uses: ramsey/composer-install@v1
uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist

- name: Execute test cases
run: make test

- name: Test installation
if: ${{ matrix.test-installation == true }}
run: make test
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Changelog
3.0.0 (unreleased)
-----

* Support Symfony 6
* Use DateTimeInterface instead of DateTime.
* Adjust to doctrine and twig BC breaks. If you extended classes or customized services, check for old `Twig_*` classes or `Doctrine\Common\Persistence` namespace.
* Drop support for old Symfony versions
* Drop support for old PHP versions
Expand Down Expand Up @@ -41,7 +43,7 @@ Released 2.0.0
2.0.0-RC1
---------

* **2017-01-17**: [BC BREAK] Removed DoctrineOrmMappingsPass - all active Doctrine versions contain the mapping pass. Use `Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass` instead.
* **2017-01-17**: [BC BREAK] Removed DoctrineOrmMappingsPass - all active Doctrine versions contain the mapping pass. Use `Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass` instead.
* **2017-01-13**: [BC BREAK] Removed the `Slugifier` classes and the
dependency on `symfony-cmf/slugifier-api`.
* **2016-12-03**: [BC BREAK] Moved sonata admin related classes and
Expand Down
53 changes: 26 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,37 @@
}
],
"require": {
"php": "^7.4 || ^8.0",
"symfony/framework-bundle": "^4.4 || ^5.0",
"symfony/security-core": "^4.4 || ^5.0"
"php": "^8.1",
"symfony/framework-bundle": "^6.4",
"symfony/security-core": "^6.4"
},
"require-dev": {
"jackalope/jackalope-doctrine-dbal": "^1.3",
"symfony/security-bundle": "^4.4 || ^5.0",
"symfony/phpunit-bridge": "^4.4.34 || ^5.0",
"ext-dom": "*",
"jackalope/jackalope-doctrine-dbal": "^1.12 || ^2.0",
"mockery/mockery": "^1.4.1",
"symfony-cmf/routing-bundle": "^2.1.0",
"symfony-cmf/testing": "^4.0.0",
"doctrine/dbal": "^2.5",
"symfony-cmf/routing-bundle": "3.1.0",
"symfony-cmf/testing": "5.0.2",
"doctrine/dbal": "^3.8.4 || ^4.0",
"doctrine/doctrine-bundle": "^2.0",
"doctrine/phpcr-odm": "^1.4|^2.0 ",
"doctrine/phpcr-bundle": "^2.3.0",
"symfony/browser-kit": "^4.4 || ^5.0",
"symfony/form": "^4.4 || ^5.0",
"symfony/monolog-bridge": "^4.4 || ^5.0",
"doctrine/phpcr-bundle": "^3.0",
"doctrine/phpcr-odm": "^1.4 || ^2.0 ",
"symfony/browser-kit": "^6.4",
"symfony/form": "^6.4",
"symfony/monolog-bridge": "^6.4",
"symfony/monolog-bundle": "^3.0",
"symfony/templating": "^4.4 || ^5.0",
"symfony/translation": "^4.4 || ^5.0",
"symfony/twig-bundle": "^4.4 || ^5.0",
"symfony/validator": "^4.4 || ^5.0",
"symfony/yaml": "^4.4 || ^5.0",
"symfony/asset": "^4.4 || ^5.0"
"symfony/phpunit-bridge": "^7.0.3",
"symfony/security-bundle": "^6.4",
"symfony/templating": "^6.4",
"symfony/translation": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/validator": "^6.4",
"symfony/yaml": "^6.4",
"symfony/asset": "^6.4"
},
"suggest": {
"symfony/twig-bundle": "To get access to the CMF twig extension (^4.4 || ^5.0)",
"doctrine/phpcr-bundle": "To be able to use the CMF twig extension (^1.0)",
"doctrine/phpcr-odm": "To be able to use the CMF twig extension (^1.0)",
"symfony/security-bundle": "To be able to use the publish workflow system (^4.4 || ^5.0)",
"symfony-cmf/routing": "To be able to use the CMF twig extension functions cmf_prev_linkable/cmf_next_linkable (^2.1)",
"symfony-cmf/routing-bundle": "To be able to enable the publish_workflow_listener (^2.1)",
"symfony/twig-bundle": "To get access to the CMF twig extension",
"symfony/security-bundle": "To be able to use the publish workflow system",
"symfony-cmf/routing-bundle": "For the wtig extension functions cmf_prev_linkable/cmf_next_linkable and the publish_workflow_listener",
"symfony-cmf/sonata-admin-integration-bundle": "To provide an admin interface for the PHPCR ODM documents."
},
"autoload": {
Expand All @@ -63,5 +61,6 @@
"branch-alias": {
"dev-master": "3.x-dev"
}
}
},
"minimum-stability": "dev"
}
2 changes: 1 addition & 1 deletion src/CmfCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

class CmfCoreBundle extends Bundle
{
public function build(ContainerBuilder $container)
public function build(ContainerBuilder $container): void
{
$container->addCompilerPass(new AddPublishedVotersPass());
}
Expand Down
21 changes: 6 additions & 15 deletions src/DependencyInjection/CmfCoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CmfCoreExtension extends Extension implements PrependExtensionInterface
*
* {@inheritdoc}
*/
public function prepend(ContainerBuilder $container)
public function prepend(ContainerBuilder $container): void
{
// process the configuration of CmfCoreExtension
$configs = $container->getExtensionConfig($this->getAlias());
Expand Down Expand Up @@ -243,10 +243,7 @@ public function prepend(ContainerBuilder $container)
}
}

/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$config = $this->processConfiguration(new Configuration(), $configs);

Expand Down Expand Up @@ -283,7 +280,7 @@ public function load(array $configs, ContainerBuilder $container)
/**
* Setup the cmf_core_checkbox_url_label form type if the routing bundle is there.
*/
public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loader)
public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loader): void
{
$bundles = $container->getParameter('kernel.bundles');
if (isset($bundles['CmfRoutingBundle'])) {
Expand All @@ -302,7 +299,7 @@ public function setupFormTypes(ContainerBuilder $container, LoaderInterface $loa
*
* @throws InvalidConfigurationException
*/
private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBuilder $container)
private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBuilder $container): void
{
$bundles = $container->getParameter('kernel.bundles');

Expand Down Expand Up @@ -336,18 +333,12 @@ private function loadPublishWorkflow($config, XmlFileLoader $loader, ContainerBu
}
}

/**
* {@inheritdoc}
*/
public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): bool|string
{
return __DIR__.'/../Resources/config/schema';
}

/**
* {@inheritdoc}
*/
public function getNamespace()
public function getNamespace(): string
{
return 'http://cmf.symfony.com/schema/dic/core';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AddPublishedVotersPass implements CompilerPassInterface
*
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('cmf_core.publish_workflow.access_decision_manager')) {
return;
Expand Down
5 changes: 1 addition & 4 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('cmf_core');
$rootNode = $treeBuilder->getRootNode();
Expand Down
9 changes: 3 additions & 6 deletions src/Doctrine/Phpcr/NonTranslatableMetadataListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
*/
class NonTranslatableMetadataListener implements EventSubscriber
{
/**
* @return array
*/
public function getSubscribedEvents()
public function getSubscribedEvents(): array
{
return [
'loadClassMetadata',
Expand All @@ -37,9 +34,9 @@ public function getSubscribedEvents()
* Handle the load class metadata event: remove translated attribute from
* fields and remove the locale mapping if present.
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
{
/** @var $meta ClassMetadata */
/** @var ClassMetadata $meta */
$meta = $eventArgs->getClassMetadata();

if (!$meta->translator) {
Expand Down
23 changes: 6 additions & 17 deletions src/Doctrine/Phpcr/TranslatableMetadataListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,12 @@
*/
class TranslatableMetadataListener implements EventSubscriber
{
/**
* @var string
*/
private $translationStrategy;

/**
* @param string $translationStrategy
*/
public function __construct($translationStrategy)
{
$this->translationStrategy = $translationStrategy;
public function __construct(
private string $translationStrategy
) {
}

/**
* @return array
*/
public function getSubscribedEvents()
public function getSubscribedEvents(): array
{
return [
'loadClassMetadata',
Expand All @@ -49,9 +38,9 @@ public function getSubscribedEvents()
/**
* Handle the load class metadata event: set the translation strategy.
*/
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs): void
{
/** @var $meta ClassMetadata */
/** @var ClassMetadata $meta */
$meta = $eventArgs->getClassMetadata();

if ($meta->getReflectionClass()->implementsInterface(TranslatableInterface::class)) {
Expand Down
40 changes: 10 additions & 30 deletions src/EventListener/PublishWorkflowListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,29 @@
*/
class PublishWorkflowListener implements EventSubscriberInterface
{
/**
* @var PublishWorkflowChecker
*/
protected $publishWorkflowChecker;

/**
* The attribute to check with the workflow checker, typically VIEW or VIEW_ANONYMOUS.
*
* @var string
*/
private $publishWorkflowPermission;

/**
* @param string $attribute the attribute name to check
*/
public function __construct(PublishWorkflowChecker $publishWorkflowChecker, $attribute = PublishWorkflowChecker::VIEW_ATTRIBUTE)
public function __construct(
private PublishWorkflowChecker $publishWorkflowChecker,
/**
* The attribute to check with the workflow checker, typically VIEW or VIEW_ANONYMOUS.
*/
private string $publishWorkflowPermission = PublishWorkflowChecker::VIEW_ATTRIBUTE)
{
$this->publishWorkflowChecker = $publishWorkflowChecker;
$this->publishWorkflowPermission = $attribute;
}

/**
* @return string
*/
public function getPublishWorkflowPermission()
public function getPublishWorkflowPermission(): string
{
return $this->publishWorkflowPermission;
}

/**
* @param string $attribute specify what permission to check, typically VIEW or VIEW_ANONYMOUS
*/
public function setPublishWorkflowPermission($attribute)
public function setPublishWorkflowPermission(string $attribute): void
{
$this->publishWorkflowPermission = $attribute;
}

/**
* Handling the request event.
*/
public function onKernelRequest(RequestEvent $event)
public function onKernelRequest(RequestEvent $event): void
{
$request = $event->getRequest();

Expand All @@ -83,10 +65,8 @@ public function onKernelRequest(RequestEvent $event)

/**
* We are only interested in request events.
*
* @return array
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => [['onKernelRequest', 1]],
Expand Down
Loading

0 comments on commit 511d1ff

Please sign in to comment.