Skip to content

Commit

Permalink
Merge 4.x into 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
SonataCI committed Aug 2, 2023
2 parents c519590 + 4816a37 commit d85761a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [4.10.3](https://github.com/sonata-project/SonataMediaBundle/compare/4.10.2...4.10.3) - 2023-08-01
### Fixed
- [[#2411](https://github.com/sonata-project/SonataMediaBundle/pull/2411)] Deprecation of Event Subscribers on Symfony 6.3. The MediaEventSubscriber now uses Event Listeners ([@Hanmac](https://github.com/Hanmac))

## [4.10.2](https://github.com/sonata-project/SonataMediaBundle/compare/4.10.1...4.10.2) - 2023-07-29
### Changed
- [[#2402](https://github.com/sonata-project/SonataMediaBundle/pull/2402)] Resole "Admin has no subject" error from the getMediaBuilder ([@Elkawaie](https://github.com/Elkawaie))
Expand Down
1 change: 1 addition & 0 deletions src/Listener/BaseMediaEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/**
* @phpstan-template T of ObjectManager
* NEXT_MAJOR: do not implement EventSubscriber interface anymore
*/
abstract class BaseMediaEventSubscriber implements EventSubscriber
{
Expand Down
3 changes: 3 additions & 0 deletions src/Listener/ODM/MediaEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
final class MediaEventSubscriber extends BaseMediaEventSubscriber
{
/**
* NEXT_MAJOR: remove this method.
*/
public function getSubscribedEvents(): array
{
return [
Expand Down
3 changes: 3 additions & 0 deletions src/Listener/ORM/MediaEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function __construct(
parent::__construct($pool);
}

/**
* NEXT_MAJOR: remove this method.
*/
public function getSubscribedEvents(): array
{
return [
Expand Down
20 changes: 19 additions & 1 deletion src/Resources/config/doctrine_mongodb.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Doctrine\ODM\MongoDB\Events;
use Sonata\MediaBundle\Document\GalleryManager;
use Sonata\MediaBundle\Document\MediaManager;
use Sonata\MediaBundle\Generator\UuidGenerator;
Expand All @@ -38,7 +39,24 @@
->set('sonata.media.generator.default', UuidGenerator::class)

->set('sonata.media.doctrine.event_subscriber', MediaEventSubscriber::class)
->tag('doctrine_mongodb.odm.event_subscriber')
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::prePersist,
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::preUpdate,
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::preRemove,
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::postUpdate,
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::postRemove,
])
->tag('doctrine_mongodb.odm.event_listener', [
'event' => Events::postPersist,
])
->args([
service('sonata.media.pool'),
]);
Expand Down
23 changes: 22 additions & 1 deletion src/Resources/config/doctrine_orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Doctrine\ORM\Events;
use Sonata\MediaBundle\Entity\GalleryManager;
use Sonata\MediaBundle\Entity\MediaManager;
use Sonata\MediaBundle\Generator\IdGenerator;
Expand All @@ -36,7 +37,27 @@
->set('sonata.media.generator.default', IdGenerator::class)

->set('sonata.media.doctrine.event_subscriber', MediaEventSubscriber::class)
->tag('doctrine.event_subscriber')
->tag('doctrine.event_listener', [
'event' => Events::prePersist,
])
->tag('doctrine.event_listener', [
'event' => Events::preUpdate,
])
->tag('doctrine.event_listener', [
'event' => Events::preRemove,
])
->tag('doctrine.event_listener', [
'event' => Events::postUpdate,
])
->tag('doctrine.event_listener', [
'event' => Events::postRemove,
])
->tag('doctrine.event_listener', [
'event' => Events::postPersist,
])
->tag('doctrine.event_listener', [
'event' => Events::onClear,
])
->args([
service('sonata.media.pool'),
service('sonata.media.manager.category')->nullOnInvalid(),
Expand Down
3 changes: 2 additions & 1 deletion tests/Command/CleanMediaCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ public function testExecute(): void
/**
* Asserts whether all expected texts can be found in the output within a given context.
*
* @param string[] $expected
* @param non-empty-string $extractor
* @param string[] $expected
*/
private function assertOutputFoundInContext(
string $extractor,
Expand Down

0 comments on commit d85761a

Please sign in to comment.