3737use OCA \WorkflowEngine \Service \RuleMatcher ;
3838use OCP \AppFramework \QueryException ;
3939use OCP \DB \QueryBuilder \IQueryBuilder ;
40+ use OCP \EventDispatcher \IEventDispatcher ;
4041use OCP \Files \Storage \IStorage ;
4142use OCP \IDBConnection ;
4243use OCP \IL10N ;
4344use OCP \ILogger ;
4445use OCP \IServerContainer ;
4546use OCP \IUserSession ;
47+ use OCP \WorkflowEngine \Events \RegisterChecksEvent ;
48+ use OCP \WorkflowEngine \Events \RegisterEntitiesEvent ;
49+ use OCP \WorkflowEngine \Events \RegisterOperationsEvent ;
4650use OCP \WorkflowEngine \ICheck ;
4751use OCP \WorkflowEngine \IComplexOperation ;
4852use OCP \WorkflowEngine \IEntity ;
4953use OCP \WorkflowEngine \IEntityEvent ;
5054use OCP \WorkflowEngine \IManager ;
5155use OCP \WorkflowEngine \IOperation ;
5256use OCP \WorkflowEngine \IRuleMatcher ;
53- use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
57+ use Symfony \Component \EventDispatcher \EventDispatcherInterface as LegacyDispatcher ;
5458use Symfony \Component \EventDispatcher \GenericEvent ;
5559
5660class Manager implements IManager {
@@ -79,8 +83,8 @@ class Manager implements IManager {
7983 /** @var IL10N */
8084 protected $ l ;
8185
82- /** @var EventDispatcherInterface */
83- protected $ eventDispatcher ;
86+ /** @var LegacyDispatcher */
87+ protected $ legacyEventDispatcher ;
8488
8589 /** @var IEntity[] */
8690 protected $ registeredEntities = [];
@@ -100,26 +104,26 @@ class Manager implements IManager {
100104 /** @var IUserSession */
101105 protected $ session ;
102106
103- /**
104- * @param IDBConnection $connection
105- * @param IServerContainer $container
106- * @param IL10N $l
107- */
107+ /** @var IEventDispatcher */
108+ private $ dispatcher ;
109+
108110 public function __construct (
109111 IDBConnection $ connection ,
110112 IServerContainer $ container ,
111113 IL10N $ l ,
112- EventDispatcherInterface $ eventDispatcher ,
114+ LegacyDispatcher $ eventDispatcher ,
113115 ILogger $ logger ,
114- IUserSession $ session
116+ IUserSession $ session ,
117+ IEventDispatcher $ dispatcher
115118 ) {
116119 $ this ->connection = $ connection ;
117120 $ this ->container = $ container ;
118121 $ this ->l = $ l ;
119- $ this ->eventDispatcher = $ eventDispatcher ;
122+ $ this ->legacyEventDispatcher = $ eventDispatcher ;
120123 $ this ->logger = $ logger ;
121124 $ this ->operationsByScope = new CappedMemoryCache (64 );
122125 $ this ->session = $ session ;
126+ $ this ->dispatcher = $ dispatcher ;
123127 }
124128
125129 public function getRuleMatcher (): IRuleMatcher {
@@ -599,7 +603,8 @@ public function formatOperation(array $operation): array {
599603 * @return IEntity[]
600604 */
601605 public function getEntitiesList (): array {
602- $ this ->eventDispatcher ->dispatch (IManager::EVENT_NAME_REG_ENTITY , new GenericEvent ($ this ));
606+ $ this ->dispatcher ->dispatchTyped (new RegisterEntitiesEvent ($ this ));
607+ $ this ->legacyEventDispatcher ->dispatch (IManager::EVENT_NAME_REG_ENTITY , new GenericEvent ($ this ));
603608
604609 return array_merge ($ this ->getBuildInEntities (), $ this ->registeredEntities );
605610 }
@@ -608,7 +613,8 @@ public function getEntitiesList(): array {
608613 * @return IOperation[]
609614 */
610615 public function getOperatorList (): array {
611- $ this ->eventDispatcher ->dispatch (IManager::EVENT_NAME_REG_OPERATION , new GenericEvent ($ this ));
616+ $ this ->dispatcher ->dispatchTyped (new RegisterOperationsEvent ($ this ));
617+ $ this ->legacyEventDispatcher ->dispatch (IManager::EVENT_NAME_REG_OPERATION , new GenericEvent ($ this ));
612618
613619 return array_merge ($ this ->getBuildInOperators (), $ this ->registeredOperators );
614620 }
@@ -617,7 +623,8 @@ public function getOperatorList(): array {
617623 * @return ICheck[]
618624 */
619625 public function getCheckList (): array {
620- $ this ->eventDispatcher ->dispatch (IManager::EVENT_NAME_REG_CHECK , new GenericEvent ($ this ));
626+ $ this ->dispatcher ->dispatchTyped (new RegisterChecksEvent ($ this ));
627+ $ this ->legacyEventDispatcher ->dispatch (IManager::EVENT_NAME_REG_CHECK , new GenericEvent ($ this ));
621628
622629 return array_merge ($ this ->getBuildInChecks (), $ this ->registeredChecks );
623630 }
0 commit comments