Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signature of EventDispatcherInterface::dispatch() has changed #732

Merged
merged 2 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/apigee_edge_actions/apigee_edge_actions.module
Original file line number Diff line number Diff line change
Expand Up @@ -116,5 +116,5 @@ function _apigee_edge_actions_dispatch_entity_event(EntityInterface $entity, str

/** @var \Drupal\apigee_edge\Entity\EdgeEntityInterface $entity */
Drupal::service('event_dispatcher')
->dispatch($dispatched_event_name, new EdgeEntityEventEdge($entity, $arguments));
->dispatch(new EdgeEntityEventEdge($entity, $arguments), $dispatched_event_name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ protected function dispatchRulesEvent(string $rules_event_name, Event $event, ar
$api_product = $this->entityTypeManger
->getStorage('api_product')
->load($product);
$this->eventDispatcher->dispatch($rules_event_name, new EdgeEntityEventEdge($app, [
$this->eventDispatcher->dispatch(new EdgeEntityEventEdge($app, [
$app_type => $app,
'developer' => $developer,
'api_product_name' => $api_product->getName(),
'api_product_display_name' => $api_product->getDisplayName(),
]));
]), $rules_event_name);
}
}
catch (PluginException $exception) {
Expand Down
4 changes: 2 additions & 2 deletions modules/apigee_edge_actions/src/TeamMembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ protected function dispatchEvent(string $event, string $team, array $developers)

// Dispatch an event for each developer.
foreach ($developers as $developer) {
$this->eventDispatcher->dispatch($event, new EdgeEntityEventEdge($team, [
$this->eventDispatcher->dispatch(new EdgeEntityEventEdge($team, [
'team' => $team,
'member' => $users_by_mail[$developer],
]));
]), $event);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ protected function invokeHook($hook, EntityInterface $entity) {
switch ($hook) {
case 'insert':
if ($entity->isAccepted()) {
$this->eventDispatcher->dispatch(TeamInvitationEvents::ACCEPTED, new TeamInvitationEvent($entity));
$this->eventDispatcher->dispatch(new TeamInvitationEvent($entity), TeamInvitationEvents::ACCEPTED);
}
else {
$this->eventDispatcher->dispatch(TeamInvitationEvents::CREATED, new TeamInvitationEvent($entity));
$this->eventDispatcher->dispatch(new TeamInvitationEvent($entity), TeamInvitationEvents::CREATED);
}
break;

Expand All @@ -133,11 +133,11 @@ protected function invokeHook($hook, EntityInterface $entity) {
unset($entity->original);

if (!$original->isDeclined() && $entity->isDeclined()) {
$this->eventDispatcher->dispatch(TeamInvitationEvents::DECLINED, new TeamInvitationEvent($entity));
$this->eventDispatcher->dispatch(new TeamInvitationEvent($entity), TeamInvitationEvents::DECLINED);
}

if (!$original->isAccepted() && $entity->isAccepted()) {
$this->eventDispatcher->dispatch(TeamInvitationEvents::ACCEPTED, new TeamInvitationEvent($entity));
$this->eventDispatcher->dispatch(new TeamInvitationEvent($entity), TeamInvitationEvents::ACCEPTED);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/EdgeEntityFieldConfigListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function create(ContainerInterface $container) {
public function listing($entity_type_id = NULL, $bundle = NULL, RouteMatchInterface $route_match = NULL) {
$page = parent::listing($entity_type_id, $bundle, $route_match);
$event = new EdgeEntityFieldConfigListAlterEvent($entity_type_id, $page);
$this->eventDispatcher->dispatch(EdgeEntityFieldConfigListAlterEvent::EVENT_NAME, $event);
$this->eventDispatcher->dispatch($event, EdgeEntityFieldConfigListAlterEvent::EVENT_NAME);
return $event->getPage();
}

Expand Down
25 changes: 20 additions & 5 deletions src/Entity/Controller/AppCredentialControllerBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ public function __construct(string $owner, string $app_name, SDKConnectorInterfa
*/
public function addProducts(string $consumer_key, array $api_products): AppCredentialInterface {
$credential = $this->decorated()->addProducts($consumer_key, $api_products);
$this->eventDispatcher->dispatch(AppCredentialAddApiProductEvent::EVENT_NAME, new AppCredentialAddApiProductEvent($this->getAppType(), $this->owner, $this->appName, $credential, $api_products));
$this->eventDispatcher->dispatch(
new AppCredentialAddApiProductEvent($this->getAppType(), $this->owner, $this->appName, $credential, $api_products),
AppCredentialAddApiProductEvent::EVENT_NAME
);
// By removing app from cache we force reload the credentials as well.
$this->appCacheByOwner->removeEntities([$this->appName]);
return $credential;
Expand All @@ -128,7 +131,10 @@ public function addProducts(string $consumer_key, array $api_products): AppCrede
*/
public function create(string $consumer_key, string $consumer_secret): AppCredentialInterface {
$credential = $this->decorated()->create($consumer_key, $consumer_secret);
$this->eventDispatcher->dispatch(AppCredentialCreateEvent::EVENT_NAME, new AppCredentialCreateEvent($this->getAppType(), $this->owner, $this->appName, $credential));
$this->eventDispatcher->dispatch(
new AppCredentialCreateEvent($this->getAppType(), $this->owner, $this->appName, $credential),
AppCredentialCreateEvent::EVENT_NAME
);
// By removing app from cache we force reload the credentials as well.
$this->appCacheByOwner->removeEntities([$this->appName]);
return $credential;
Expand All @@ -147,7 +153,10 @@ abstract protected function decorated() : EdgeAppCredentialController;
*/
public function delete(string $consumer_key): AppCredentialInterface {
$credential = $this->decorated()->delete($consumer_key);
$this->eventDispatcher->dispatch(AppCredentialDeleteEvent::EVENT_NAME, new AppCredentialDeleteEvent($this->getAppType(), $this->owner, $this->appName, $credential));
$this->eventDispatcher->dispatch(
new AppCredentialDeleteEvent($this->getAppType(), $this->owner, $this->appName, $credential),
AppCredentialDeleteEvent::EVENT_NAME
);
// By removing app from cache we force reload the credentials as well.
$this->appCacheByOwner->removeEntities([$this->appName]);
return $credential;
Expand All @@ -158,7 +167,10 @@ public function delete(string $consumer_key): AppCredentialInterface {
*/
public function deleteApiProduct(string $consumer_key, string $api_product): AppCredentialInterface {
$credential = $this->decorated()->deleteApiProduct($consumer_key, $api_product);
$this->eventDispatcher->dispatch(AppCredentialDeleteApiProductEvent::EVENT_NAME, new AppCredentialDeleteApiProductEvent($this->getAppType(), $this->owner, $this->appName, $credential, $api_product));
$this->eventDispatcher->dispatch(
new AppCredentialDeleteApiProductEvent($this->getAppType(), $this->owner, $this->appName, $credential, $api_product),
AppCredentialDeleteApiProductEvent::EVENT_NAME
);
// By removing app from cache we force reload the credentials as well.
$this->appCacheByOwner->removeEntities([$this->appName]);
return $credential;
Expand All @@ -178,7 +190,10 @@ public function deleteAttribute(string $entity_id, string $name): void {
*/
public function generate(array $api_products, AttributesProperty $app_attributes, string $callback_url, array $scopes = [], string $key_expires_in = '-1'): AppCredentialInterface {
$credential = $this->decorated()->generate($api_products, $app_attributes, $callback_url, $scopes, $key_expires_in);
$this->eventDispatcher->dispatch(AppCredentialGenerateEvent::EVENT_NAME, new AppCredentialGenerateEvent($this->getAppType(), $this->owner, $this->appName, $credential));
$this->eventDispatcher->dispatch(
new AppCredentialGenerateEvent($this->getAppType(), $this->owner, $this->appName, $credential),
AppCredentialGenerateEvent::EVENT_NAME
);
// By removing app from cache we force reload the credentials as well.
$this->appCacheByOwner->removeEntities([$this->appName]);
return $credential;
Expand Down