use OCP\EventDispatcher\Event over Symfony's deprecated Eventtags/v18.0.0beta1
namespace OCA\DAV\Tests\unit\Comments; | namespace OCA\DAV\Tests\unit\Comments; | ||||
use OC\EventDispatcher\EventDispatcher; | |||||
use OC\EventDispatcher\SymfonyAdapter; | |||||
use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation; | use OCA\DAV\Comments\EntityTypeCollection as EntityTypeCollectionImplementation; | ||||
use OCP\Comments\CommentsEntityEvent; | use OCP\Comments\CommentsEntityEvent; | ||||
use OCP\Comments\ICommentsManager; | use OCP\Comments\ICommentsManager; | ||||
use OCP\IUser; | use OCP\IUser; | ||||
use OCP\IUserManager; | use OCP\IUserManager; | ||||
use OCP\IUserSession; | use OCP\IUserSession; | ||||
use Symfony\Component\EventDispatcher\EventDispatcher; | |||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |||||
class RootCollectionTest extends \Test\TestCase { | class RootCollectionTest extends \Test\TestCase { | ||||
protected $collection; | protected $collection; | ||||
/** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ | /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject */ | ||||
protected $userSession; | protected $userSession; | ||||
/** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface */ | |||||
/** @var EventDispatcherInterface */ | |||||
protected $dispatcher; | protected $dispatcher; | ||||
/** @var \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject */ | /** @var \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject */ | ||||
protected $user; | protected $user; | ||||
$this->userSession = $this->getMockBuilder(IUserSession::class) | $this->userSession = $this->getMockBuilder(IUserSession::class) | ||||
->disableOriginalConstructor() | ->disableOriginalConstructor() | ||||
->getMock(); | ->getMock(); | ||||
$this->dispatcher = new EventDispatcher(); | |||||
$this->logger = $this->getMockBuilder(ILogger::class) | $this->logger = $this->getMockBuilder(ILogger::class) | ||||
->disableOriginalConstructor() | ->disableOriginalConstructor() | ||||
->getMock(); | ->getMock(); | ||||
$this->dispatcher = new SymfonyAdapter( | |||||
new EventDispatcher( | |||||
new \Symfony\Component\EventDispatcher\EventDispatcher(), | |||||
\OC::$server, | |||||
$this->logger | |||||
), | |||||
$this->logger | |||||
); | |||||
$this->collection = new \OCA\DAV\Comments\RootCollection( | $this->collection = new \OCA\DAV\Comments\RootCollection( | ||||
$this->commentsManager, | $this->commentsManager, |
use OCP\Files\Node; | use OCP\Files\Node; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class MoveToTrashEvent | * Class MoveToTrashEvent |
namespace OCA\Files_Versions\Events; | namespace OCA\Files_Versions\Events; | ||||
use OCP\Files\Node; | use OCP\Files\Node; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class CreateVersionEvent | * Class CreateVersionEvent |
namespace OCA\TwoFactorBackupCodes\Tests\Unit\Migration; | namespace OCA\TwoFactorBackupCodes\Tests\Unit\Migration; | ||||
use OCA\TwoFactorBackupCodes\Event\CodesGenerated; | |||||
use OCA\TwoFactorBackupCodes\Listener\RegistryUpdater; | |||||
use OCA\TwoFactorBackupCodes\Migration\CheckBackupCodes; | use OCA\TwoFactorBackupCodes\Migration\CheckBackupCodes; | ||||
use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider; | |||||
use OCP\Authentication\TwoFactorAuth\IRegistry; | |||||
use OCP\BackgroundJob\IJobList; | use OCP\BackgroundJob\IJobList; | ||||
use OCP\IUser; | |||||
use OCP\Migration\IOutput; | use OCP\Migration\IOutput; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use Test\TestCase; | use Test\TestCase; | ||||
class CheckBackupCodeTest extends TestCase { | class CheckBackupCodeTest extends TestCase { |
namespace OC\EventDispatcher; | namespace OC\EventDispatcher; | ||||
use OCP\ILogger; | |||||
use function is_callable; | use function is_callable; | ||||
use OCP\EventDispatcher\Event; | use OCP\EventDispatcher\Event; | ||||
use Symfony\Component\EventDispatcher\Event as SymfonyEvent; | |||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | use Symfony\Component\EventDispatcher\EventDispatcherInterface; | ||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||||
/** @var EventDispatcher */ | /** @var EventDispatcher */ | ||||
private $eventDispatcher; | private $eventDispatcher; | ||||
/** @var ILogger */ | |||||
private $logger; | |||||
public function __construct(EventDispatcher $eventDispatcher) { | |||||
public function __construct(EventDispatcher $eventDispatcher, ILogger $logger) { | |||||
$this->eventDispatcher = $eventDispatcher; | $this->eventDispatcher = $eventDispatcher; | ||||
$this->logger = $logger; | |||||
} | } | ||||
/** | /** | ||||
* @param string $eventName The name of the event to dispatch. The name of | * @param string $eventName The name of the event to dispatch. The name of | ||||
* the event is the name of the method that is | * the event is the name of the method that is | ||||
* invoked on listeners. | * invoked on listeners. | ||||
* @param SymfonyEvent|null $event The event to pass to the event handlers/listeners | |||||
* @param Event|null $event The event to pass to the event handlers/listeners | |||||
* If not supplied, an empty Event instance is created | * If not supplied, an empty Event instance is created | ||||
* | * | ||||
* @return SymfonyEvent | |||||
* @return void | |||||
*/ | */ | ||||
public function dispatch($eventName, SymfonyEvent $event = null) { | |||||
public function dispatch($eventName, $event = null) { | |||||
// type hinting is not possible, due to usage of GenericEvent | |||||
if ($event instanceof Event) { | if ($event instanceof Event) { | ||||
$this->eventDispatcher->dispatch($eventName, $event); | $this->eventDispatcher->dispatch($eventName, $event); | ||||
} else { | } else { | ||||
// Legacy event | // Legacy event | ||||
$this->logger->info( | |||||
'Deprecated event type for {name}: {class}', | |||||
[ 'name' => $eventName, 'class' => is_object($event) ? get_class($event) : 'null' ] | |||||
); | |||||
$this->eventDispatcher->getSymfonyDispatcher()->dispatch($eventName, $event); | $this->eventDispatcher->getSymfonyDispatcher()->dispatch($eventName, $event); | ||||
} | } | ||||
} | } |
use OCP\Files\Cache\ICacheEvent; | use OCP\Files\Cache\ICacheEvent; | ||||
use OCP\Files\Storage\IStorage; | use OCP\Files\Storage\IStorage; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
class AbstractCacheEvent extends Event implements ICacheEvent { | class AbstractCacheEvent extends Event implements ICacheEvent { | ||||
protected $storage; | protected $storage; |
namespace OCP\App; | namespace OCP\App; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class ManagerEvent | * Class ManagerEvent |
namespace OCP\Comments; | namespace OCP\Comments; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class CommentsEntityEvent | * Class CommentsEntityEvent |
namespace OCP\Comments; | namespace OCP\Comments; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class CommentsEvent | * Class CommentsEvent |
namespace OCP\Console; | namespace OCP\Console; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class ConsoleEvent | * Class ConsoleEvent |
use OCP\AppFramework\Http; | use OCP\AppFramework\Http; | ||||
use Sabre\DAV\Server; | use Sabre\DAV\Server; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* @since 8.2.0 | * @since 8.2.0 |
namespace OCP\SystemTag; | namespace OCP\SystemTag; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class ManagerEvent | * Class ManagerEvent |
namespace OCP\SystemTag; | namespace OCP\SystemTag; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class MapperEvent | * Class MapperEvent |
namespace OCP\SystemTag; | namespace OCP\SystemTag; | ||||
use Symfony\Component\EventDispatcher\Event; | |||||
use OCP\EventDispatcher\Event; | |||||
/** | /** | ||||
* Class SystemTagsEntityEvent | * Class SystemTagsEntityEvent |