mirror of
https://github.com/wallabag/wallabag.git
synced 2025-01-31 07:47:28 +01:00
Merge pull request #6154 from wallabag/fix/event-dispatcher
Fix EventDispatcher & events
This commit is contained in:
commit
9c16dd7bd1
@ -84,18 +84,3 @@ parameters:
|
|||||||
message: "#^Property Tests\\\\Wallabag\\\\CoreBundle\\\\Helper\\\\RedirectTest\\:\\:\\$routerMock has unknown class PHPUnit_Framework_MockObject_MockObject as its type\\.$#"
|
message: "#^Property Tests\\\\Wallabag\\\\CoreBundle\\\\Helper\\\\RedirectTest\\:\\:\\$routerMock has unknown class PHPUnit_Framework_MockObject_MockObject as its type\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php
|
path: tests/Wallabag/CoreBundle/Helper/RedirectTest.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
|
|
||||||
count: 1
|
|
||||||
path: src/Wallabag/ApiBundle/Controller/UserRestController.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
|
|
||||||
count: 1
|
|
||||||
path: src/Wallabag/CoreBundle/Command/InstallCommand.php
|
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method Symfony\\\\Contracts\\\\EventDispatcher\\\\EventDispatcherInterface\\:\\:dispatch()#"
|
|
||||||
count: 1
|
|
||||||
path: src/Wallabag/UserBundle/Controller/ManageController.php
|
|
||||||
|
@ -462,7 +462,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
|
|
||||||
if (false !== $entry) {
|
if (false !== $entry) {
|
||||||
// entry deleted, dispatch event about it!
|
// entry deleted, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME);
|
||||||
|
|
||||||
$em = $this->get('doctrine')->getManager();
|
$em = $this->get('doctrine')->getManager();
|
||||||
$em->remove($entry);
|
$em->remove($entry);
|
||||||
@ -539,7 +539,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
$results[$key]['entry'] = $entry instanceof Entry ? $entry->getId() : false;
|
$results[$key]['entry'] = $entry instanceof Entry ? $entry->getId() : false;
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->sendResponse($results);
|
return $this->sendResponse($results);
|
||||||
@ -760,7 +760,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
return $this->sendResponse($entry);
|
return $this->sendResponse($entry);
|
||||||
}
|
}
|
||||||
@ -976,7 +976,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
return $this->sendResponse($entry);
|
return $this->sendResponse($entry);
|
||||||
}
|
}
|
||||||
@ -1032,7 +1032,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
return $this->sendResponse($entry);
|
return $this->sendResponse($entry);
|
||||||
}
|
}
|
||||||
@ -1083,7 +1083,7 @@ class EntryRestController extends WallabagRestController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// entry deleted, dispatch event about it!
|
// entry deleted, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME);
|
||||||
|
|
||||||
$em = $this->get('doctrine')->getManager();
|
$em = $this->get('doctrine')->getManager();
|
||||||
$em->remove($entry);
|
$em->remove($entry);
|
||||||
|
@ -11,7 +11,6 @@ use JMS\Serializer\SerializerInterface;
|
|||||||
use Nelmio\ApiDocBundle\Annotation\Operation;
|
use Nelmio\ApiDocBundle\Annotation\Operation;
|
||||||
use Swagger\Annotations as SWG;
|
use Swagger\Annotations as SWG;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
@ -160,7 +159,7 @@ class UserRestController extends WallabagRestController
|
|||||||
|
|
||||||
// dispatch a created event so the associated config will be created
|
// dispatch a created event so the associated config will be created
|
||||||
$event = new UserEvent($user, $request);
|
$event = new UserEvent($user, $request);
|
||||||
LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
|
$this->get(EventDispatcherInterface::class)->dispatch($event, FOSUserEvents::USER_CREATED);
|
||||||
|
|
||||||
return $this->sendUser($user, 'user_api_with_client', JsonResponse::HTTP_CREATED);
|
return $this->sendUser($user, 'user_api_with_client', JsonResponse::HTTP_CREATED);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ use Symfony\Component\Console\Output\OutputInterface;
|
|||||||
use Symfony\Component\Console\Question\Question;
|
use Symfony\Component\Console\Question\Question;
|
||||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
|
||||||
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
|
use Wallabag\CoreBundle\Entity\IgnoreOriginInstanceRule;
|
||||||
use Wallabag\CoreBundle\Entity\InternalSetting;
|
use Wallabag\CoreBundle\Entity\InternalSetting;
|
||||||
use Wallabag\UserBundle\Entity\User;
|
use Wallabag\UserBundle\Entity\User;
|
||||||
@ -282,7 +281,7 @@ class InstallCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
// dispatch a created event so the associated config will be created
|
// dispatch a created event so the associated config will be created
|
||||||
$event = new UserEvent($user);
|
$event = new UserEvent($user);
|
||||||
LegacyEventDispatcherProxy::decorate($this->getContainer()->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
|
$this->getContainer()->get(EventDispatcherInterface::class)->dispatch($event, FOSUserEvents::USER_CREATED);
|
||||||
|
|
||||||
$this->io->text('<info>Administration successfully setup.</info>');
|
$this->io->text('<info>Administration successfully setup.</info>');
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class ReloadEntryCommand extends ContainerAwareCommand
|
|||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$dispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$dispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
$progressBar->advance();
|
$progressBar->advance();
|
||||||
|
|
||||||
$em->detach($entry);
|
$em->detach($entry);
|
||||||
|
@ -102,7 +102,7 @@ class EntryController extends Controller
|
|||||||
$entry->removeTag($tag);
|
$entry->removeTag($tag);
|
||||||
}
|
}
|
||||||
} elseif ('delete' === $action) {
|
} elseif ('delete' === $action) {
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME);
|
||||||
$em->remove($entry);
|
$em->remove($entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +178,7 @@ class EntryController extends Controller
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('homepage'));
|
return $this->redirect($this->generateUrl('homepage'));
|
||||||
}
|
}
|
||||||
@ -206,7 +206,7 @@ class EntryController extends Controller
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('homepage'));
|
return $this->redirect($this->generateUrl('homepage'));
|
||||||
@ -414,7 +414,7 @@ class EntryController extends Controller
|
|||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
|
return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()]));
|
||||||
}
|
}
|
||||||
@ -498,7 +498,7 @@ class EntryController extends Controller
|
|||||||
);
|
);
|
||||||
|
|
||||||
// entry deleted, dispatch event about it!
|
// entry deleted, dispatch event about it!
|
||||||
$this->get(EventDispatcherInterface::class)->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
|
$this->get(EventDispatcherInterface::class)->dispatch(new EntryDeletedEvent($entry), EntryDeletedEvent::NAME);
|
||||||
|
|
||||||
$em = $this->get('doctrine')->getManager();
|
$em = $this->get('doctrine')->getManager();
|
||||||
$em->remove($entry);
|
$em->remove($entry);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Wallabag\CoreBundle\Event;
|
namespace Wallabag\CoreBundle\Event;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +19,7 @@ class EntryDeletedEvent extends Event
|
|||||||
$this->entry = $entry;
|
$this->entry = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntry()
|
public function getEntry(): Entry
|
||||||
{
|
{
|
||||||
return $this->entry;
|
return $this->entry;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace Wallabag\CoreBundle\Event;
|
namespace Wallabag\CoreBundle\Event;
|
||||||
|
|
||||||
use Symfony\Component\EventDispatcher\Event;
|
use Symfony\Contracts\EventDispatcher\Event;
|
||||||
use Wallabag\CoreBundle\Entity\Entry;
|
use Wallabag\CoreBundle\Entity\Entry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,7 +19,7 @@ class EntrySavedEvent extends Event
|
|||||||
$this->entry = $entry;
|
$this->entry = $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getEntry()
|
public function getEntry(): Entry
|
||||||
{
|
{
|
||||||
return $this->entry;
|
return $this->entry;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ abstract class AbstractConsumer
|
|||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
// entry saved, dispatch event about it!
|
// entry saved, dispatch event about it!
|
||||||
$this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
|
|
||||||
// clear only affected entities
|
// clear only affected entities
|
||||||
$this->em->clear(Entry::class);
|
$this->em->clear(Entry::class);
|
||||||
|
@ -171,7 +171,7 @@ abstract class AbstractImport implements ImportInterface
|
|||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
$this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entryToBeFlushed = [];
|
$entryToBeFlushed = [];
|
||||||
@ -187,7 +187,7 @@ abstract class AbstractImport implements ImportInterface
|
|||||||
|
|
||||||
if (!empty($entryToBeFlushed)) {
|
if (!empty($entryToBeFlushed)) {
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
$this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ abstract class BrowserImport extends AbstractImport
|
|||||||
$this->em->flush();
|
$this->em->flush();
|
||||||
|
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
$this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
$entryToBeFlushed = [];
|
$entryToBeFlushed = [];
|
||||||
@ -185,7 +185,7 @@ abstract class BrowserImport extends AbstractImport
|
|||||||
|
|
||||||
if (!empty($entryToBeFlushed)) {
|
if (!empty($entryToBeFlushed)) {
|
||||||
foreach ($entryToBeFlushed as $entry) {
|
foreach ($entryToBeFlushed as $entry) {
|
||||||
$this->eventDispatcher->dispatch(EntrySavedEvent::NAME, new EntrySavedEvent($entry));
|
$this->eventDispatcher->dispatch(new EntrySavedEvent($entry), EntrySavedEvent::NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ use Pagerfanta\Pagerfanta;
|
|||||||
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
|
use Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Google\GoogleAuthenticatorInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
|
||||||
use Symfony\Component\Form\Form;
|
use Symfony\Component\Form\Form;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@ -50,7 +49,7 @@ class ManageController extends Controller
|
|||||||
|
|
||||||
// dispatch a created event so the associated config will be created
|
// dispatch a created event so the associated config will be created
|
||||||
$event = new UserEvent($user, $request);
|
$event = new UserEvent($user, $request);
|
||||||
LegacyEventDispatcherProxy::decorate($this->get(EventDispatcherInterface::class))->dispatch($event, FOSUserEvents::USER_CREATED);
|
$this->get(EventDispatcherInterface::class)->dispatch($event, FOSUserEvents::USER_CREATED);
|
||||||
|
|
||||||
$this->get(SessionInterface::class)->getFlashBag()->add(
|
$this->get(SessionInterface::class)->getFlashBag()->add(
|
||||||
'notice',
|
'notice',
|
||||||
|
@ -69,8 +69,8 @@ class LocaleListenerTest extends TestCase
|
|||||||
$dispatcher->addSubscriber($listener);
|
$dispatcher->addSubscriber($listener);
|
||||||
|
|
||||||
$dispatcher->dispatch(
|
$dispatcher->dispatch(
|
||||||
KernelEvents::REQUEST,
|
$event,
|
||||||
$event
|
KernelEvents::REQUEST
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame('fr', $request->getLocale());
|
$this->assertSame('fr', $request->getLocale());
|
||||||
|
@ -57,8 +57,8 @@ class AuthenticationFailureListenerTest extends TestCase
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->dispatcher->dispatch(
|
$this->dispatcher->dispatch(
|
||||||
AuthenticationEvents::AUTHENTICATION_FAILURE,
|
$event,
|
||||||
$event
|
AuthenticationEvents::AUTHENTICATION_FAILURE
|
||||||
);
|
);
|
||||||
|
|
||||||
$records = $this->logHandler->getRecords();
|
$records = $this->logHandler->getRecords();
|
||||||
|
@ -72,8 +72,8 @@ class CreateConfigListenerTest extends TestCase
|
|||||||
->method('flush');
|
->method('flush');
|
||||||
|
|
||||||
$this->dispatcher->dispatch(
|
$this->dispatcher->dispatch(
|
||||||
FOSUserEvents::REGISTRATION_COMPLETED,
|
$event,
|
||||||
$event
|
FOSUserEvents::REGISTRATION_COMPLETED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user