|
40 | 40 |
|
41 | 41 | use OC\AppConfig; |
42 | 42 | use OCP\App\AppPathNotFoundException; |
| 43 | +use OCP\App\Events\AppDisableEvent; |
| 44 | +use OCP\App\Events\AppEnableEvent; |
43 | 45 | use OCP\App\IAppManager; |
44 | 46 | use OCP\App\ManagerEvent; |
| 47 | +use OCP\EventDispatcher\IEventDispatcher; |
45 | 48 | use OCP\ICacheFactory; |
46 | 49 | use OCP\IConfig; |
47 | 50 | use OCP\IGroup; |
@@ -81,7 +84,9 @@ class AppManager implements IAppManager { |
81 | 84 | private $memCacheFactory; |
82 | 85 |
|
83 | 86 | /** @var EventDispatcherInterface */ |
84 | | - private $dispatcher; |
| 87 | + private $legacyDispatcher; |
| 88 | + |
| 89 | + private IEventDispatcher $dispatcher; |
85 | 90 |
|
86 | 91 | /** @var LoggerInterface */ |
87 | 92 | private $logger; |
@@ -109,13 +114,15 @@ public function __construct(IUserSession $userSession, |
109 | 114 | AppConfig $appConfig, |
110 | 115 | IGroupManager $groupManager, |
111 | 116 | ICacheFactory $memCacheFactory, |
112 | | - EventDispatcherInterface $dispatcher, |
| 117 | + EventDispatcherInterface $legacyDispatcher, |
| 118 | + IEventDispatcher $dispatcher, |
113 | 119 | LoggerInterface $logger) { |
114 | 120 | $this->userSession = $userSession; |
115 | 121 | $this->config = $config; |
116 | 122 | $this->appConfig = $appConfig; |
117 | 123 | $this->groupManager = $groupManager; |
118 | 124 | $this->memCacheFactory = $memCacheFactory; |
| 125 | + $this->legacyDispatcher = $legacyDispatcher; |
119 | 126 | $this->dispatcher = $dispatcher; |
120 | 127 | $this->logger = $logger; |
121 | 128 | } |
@@ -321,7 +328,8 @@ public function enableApp(string $appId, bool $forceEnable = false): void { |
321 | 328 |
|
322 | 329 | $this->installedAppsCache[$appId] = 'yes'; |
323 | 330 | $this->appConfig->setValue($appId, 'enabled', 'yes'); |
324 | | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( |
| 331 | + $this->dispatcher->dispatchTyped(new AppEnableEvent($appId)); |
| 332 | + $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE, new ManagerEvent( |
325 | 333 | ManagerEvent::EVENT_APP_ENABLE, $appId |
326 | 334 | )); |
327 | 335 | $this->clearAppsCache(); |
@@ -373,7 +381,8 @@ public function enableAppForGroups(string $appId, array $groups, bool $forceEnab |
373 | 381 |
|
374 | 382 | $this->installedAppsCache[$appId] = json_encode($groupIds); |
375 | 383 | $this->appConfig->setValue($appId, 'enabled', json_encode($groupIds)); |
376 | | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( |
| 384 | + $this->dispatcher->dispatchTyped(new AppEnableEvent($appId, $groupIds)); |
| 385 | + $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, new ManagerEvent( |
377 | 386 | ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, $appId, $groups |
378 | 387 | )); |
379 | 388 | $this->clearAppsCache(); |
@@ -408,7 +417,8 @@ public function disableApp($appId, $automaticDisabled = false) { |
408 | 417 | \OC_App::executeRepairSteps($appId, $appData['repair-steps']['uninstall']); |
409 | 418 | } |
410 | 419 |
|
411 | | - $this->dispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( |
| 420 | + $this->dispatcher->dispatchTyped(new AppDisableEvent($appId)); |
| 421 | + $this->legacyDispatcher->dispatch(ManagerEvent::EVENT_APP_DISABLE, new ManagerEvent( |
412 | 422 | ManagerEvent::EVENT_APP_DISABLE, $appId |
413 | 423 | )); |
414 | 424 | $this->clearAppsCache(); |
|
0 commit comments