Skip to content
Open
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
22 changes: 14 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.1
extensions: json, mbstring
tools: composer, php-cs-fixer:2.19
tools: composer, php-cs-fixer:3.0

- name: Display tools versions
run: |
Expand All @@ -33,15 +33,18 @@ jobs:
strategy:
matrix:
include:
- php: '7.4'
- php: '8.0'
dependencies: 'lowest'
symfony_require: '3.4.*'
- php: '7.4'
symfony_require: '6.0.*'
- php: '8.1'
dependencies: 'highest'
symfony_require: '4.4.*'
- php: '8.0'
symfony_require: '6.4.*'
- php: '8.2'
dependencies: 'highest'
symfony_require: '4.4.*'
symfony_require: '6.4.*'
- php: '8.3'
dependencies: 'highest'
symfony_require: '6.4.*'
fail-fast: false
steps:
- name: Checkout
Expand All @@ -57,6 +60,9 @@ jobs:
- name: Globally install symfony/flex
run: composer global require --no-progress --no-scripts --no-plugins symfony/flex

- name: Allow Symfony Flex plugin
run: composer global config --no-plugins allow-plugins.symfony/flex true

- name: Install Composer dependencies (${{ matrix.dependencies }})
uses: ramsey/composer-install@v1
with:
Expand Down
15 changes: 10 additions & 5 deletions .php_cs → .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@
with this source code in the file LICENSE.
EOF;

return PhpCsFixer\Config::create()
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->exclude('vendor')
;

$config = new PhpCsFixer\Config();

return $config
->setRules([
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
Expand All @@ -27,8 +34,6 @@
])
->setUsingCache(true)
->setRiskyAllowed(true)
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__)
)
->setFinder($finder)
;

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ FOSCommentBundle

The FOSCommentBundle adds support for a comment system in Symfony. Features include:

- Supports Symfony 3.4, 4.4
- Requires **PHP 8.0.2+** and supports **Symfony 6.x**
- Manages trees of comments
- Can include comment threads in any page
- Compatible with any persistence backend. Doctrine2 mongodb-odm and ORM are implemented.
- Configurable sorting of the comment tree
- REST api (via FOSRestBundle)
- Extensible through events fired during the comment lifecycle
- Optional use of Symfony Acl to protect comments
- Optional integration with FOS\UserBundle
- Optional integration with `Akismet`
- Optional integration with FOSUserBundle
- Optional integration with Akismet
- Optional markup parser support (eg HtmlPurifier or php-sundown)

[![Build Status](https://travis-ci.org/FriendsOfSymfony/FOSCommentBundle.svg?branch=master)](https://travis-ci.org/FriendsOfSymfony/FOSCommentBundle) [![Total Downloads](https://poser.pugx.org/friendsofsymfony/comment-bundle/downloads.svg)](https://packagist.org/packages/friendsofsymfony/comment-bundle) [![Latest Stable Version](https://poser.pugx.org/friendsofsymfony/comment-bundle/v/stable.svg)](https://packagist.org/packages/friendsofsymfony/comment-bundle)
Expand Down
42 changes: 42 additions & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
6.0.x (Symfony 6.x Support with PHP 8.0+):

* **[BC BREAK]** The bundle now requires PHP 8.0.2+ and Symfony 6.0+.
Support for Symfony 5.x and PHP 7.x has been dropped.
* The bundle now supports Symfony 6.x exclusively
* This version uses modern PHP 8.0+ features (typed properties, union types, etc.)
* Dependencies have been updated:
- PHP: >=8.0.2
- Symfony: ^6.0 (all 6.x versions)
- FOSRestBundle: ^3.0
- JMSSerializerBundle: ^3.0, ^4.0, or ^5.0
- Twig: ^3.0
- PHPUnit: ^9.5 (for development)
- PHP CS Fixer: ^3.0 (for development)
* Code modernization with PHP 8.0+ features where applicable

5.0.x (Symfony 5.0+ Support - Transition Version):

* **[BC BREAK]** The bundle now requires PHP 7.2.5+ and Symfony 5.0+.
Support for Symfony 4.4 and earlier versions has been dropped.
* The bundle now supports Symfony 5.0+ (5.0, 5.1, 5.2, 5.3, 5.4)
* This is a transition version. Use version 6.0+ for Symfony 6.x and 7.x support.
* Dependencies have been updated:
- PHP: >=7.2.5
- Symfony: ^5.0 (all 5.x versions including 5.4 LTS)
- FOSRestBundle: ^2.8 or ^3.0
- JMSSerializerBundle: ^2.0, ^3.0, ^4.0, or ^5.0
- Twig: ^2.0 or ^3.0
- PHPUnit: ^8.5 or ^9.5 (for development)
- PHP CS Fixer: ^3.0 (for development)
* **[BC BREAK]** The `ThreadController` now uses constructor dependency injection
instead of container service location. This is required for Symfony 6+
compatibility. If you have extended this controller, you will need to update
your code to inject the required services in your constructor.
* Form type tags in service configuration no longer use the `alias` or
`extended-type` attributes as they are deprecated in Symfony 5+. The form
types now rely on their `getBlockPrefix()` method for identification.
* PHPUnit configuration has been updated to PHPUnit 9.5+ format.
* Test suite has been updated with proper type hints for PHPUnit 9 compatibility.
* All services are now properly configured for autowiring and autoconfiguration
in modern Symfony applications.

2.0.x:

* The dependencies to FOS RestBundle have changed and as a result, you need to ensure that you have defined
Expand Down
61 changes: 33 additions & 28 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@
"issues": "https://github.com/FriendsOfSymfony/FOSCommentBundle/issues"
},
"require": {
"php": "^7.4 || ^8.0",
"friendsofsymfony/rest-bundle": "~2.8",
"jms/serializer-bundle": "~2.0|~3.0",
"symfony/framework-bundle": "~3.4|^4.3",
"symfony/asset": "~3.4|^4.3",
"symfony/dependency-injection": "~3.4|^4.3",
"symfony/routing": "~3.4|^4.3",
"symfony/security-bundle": "~3.4|^4.3",
"symfony/yaml": "~3.4|^4.3",
"symfony/form": "~3.4|^4.3",
"symfony/validator": "~3.4|^4.3",
"symfony/twig-bundle": "~3.4|^4.3",
"symfony/twig-bridge": "~3.4|^4.3",
"twig/twig": "~2.0|~3.0",
"phpoption/phpoption": "~1.1",
"doctrine/annotations": "~1.0"
"php": ">=8.0.2",
"friendsofsymfony/rest-bundle": "^3.0",
"jms/serializer-bundle": "^3.0 || ^4.0 || ^5.0",
"symfony/framework-bundle": "^6.0",
"symfony/asset": "^6.0",
"symfony/dependency-injection": "^6.0",
"symfony/routing": "^6.0",
"symfony/security-bundle": "^6.0",
"symfony/yaml": "^6.0",
"symfony/form": "^6.0",
"symfony/validator": "^6.0",
"symfony/twig-bundle": "^6.0",
"symfony/twig-bridge": "^6.0",
"twig/twig": "^3.0",
"phpoption/phpoption": "^1.1",
"doctrine/annotations": "^1.0 || ^2.0"
},
"suggest": {
"friendsofsymfony/user-bundle": "Allows for user integration.",
Expand All @@ -47,21 +47,21 @@
"symfony/assetic-bundle": "Integrates Assetic into Symfony."
},
"require-dev": {
"symfony/browser-kit": "~3.4|^4.3",
"symfony/dom-crawler": "~3.4|^4.3",
"symfony/css-selector": "~3.4|^4.3",
"doctrine/orm": "~2.3",
"doctrine/doctrine-bundle": "^1.6|^2.0",
"friendsofsymfony/user-bundle": "~2.0",
"symfony/browser-kit": "^6.0",
"symfony/dom-crawler": "^6.0",
"symfony/css-selector": "^6.0",
"doctrine/orm": "^2.7",
"doctrine/doctrine-bundle": "^2.7",
"friendsofsymfony/user-bundle": "^3.0",
"ornicar/akismet-bundle": "dev-master",
"symfony/expression-language": "~3.4|^4.3",
"symfony/phpunit-bridge": "~3.4|^4.3",
"phpunit/phpunit": "^6.5",
"friendsofphp/php-cs-fixer": "^2.2"
"symfony/expression-language": "^6.0",
"symfony/phpunit-bridge": "^6.0",
"phpunit/phpunit": "^9.5",
"friendsofphp/php-cs-fixer": "^3.0"
},
"extra": {
"branch-alias": {
"dev-master": "4.0.x-dev"
"dev-master": "6.0.x-dev"
}
},
"autoload": {
Expand All @@ -74,5 +74,10 @@
"FOS\\CommentBundle\\Tests\\": "tests/"
}
},
"prefer-stable": true
"prefer-stable": true,
"config": {
"allow-plugins": {
"symfony/flex": true
}
}
}
22 changes: 18 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./tests/bootstrap.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
cacheResultFile=".phpunit.cache/test-results"
executionOrder="depends,defects"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<php>
<ini name="xdebug.max_nesting_level" value="200" />
<ini name="xdebug.max_nesting_level" value="200"/>
</php>
<testsuites>
<testsuite name="FOSCommentBundle test suitei">
<testsuite name="FOSCommentBundle test suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
Expand Down
66 changes: 7 additions & 59 deletions src/Acl/RoleCommentAcl.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,69 +21,17 @@
*/
class RoleCommentAcl implements CommentAclInterface
{
/**
* @var AuthorizationCheckerInterface
*/
private $authorizationChecker;

/**
* The FQCN of the Comment object.
*
* @var string
*/
private $commentClass;

/**
* The role that will grant create permission for a comment.
*
* @var string
*/
private $createRole;

/**
* The role that will grant view permission for a comment.
*
* @var string
*/
private $viewRole;

/**
* The role that will grant edit permission for a comment.
*
* @var string
*/
private $editRole;

/**
* The role that will grant delete permission for a comment.
*
* @var string
*/
private $deleteRole;

/**
* Constructor.
*
* @param AuthorizationCheckerInterface $authorizationChecker
* @param string $createRole
* @param string $viewRole
* @param string $editRole
* @param string $deleteRole
* @param string $commentClass
*/
public function __construct(AuthorizationCheckerInterface $authorizationChecker,
$createRole,
$viewRole,
$editRole,
$deleteRole,
$commentClass
public function __construct(
private AuthorizationCheckerInterface $authorizationChecker,
private string $createRole,
private string $viewRole,
private string $editRole,
private string $deleteRole,
private string $commentClass
) {
$this->authorizationChecker = $authorizationChecker;
$this->createRole = $createRole;
$this->viewRole = $viewRole;
$this->editRole = $editRole;
$this->deleteRole = $deleteRole;
$this->commentClass = $commentClass;
}

/**
Expand Down
Loading
Loading