- 🇫🇷France Grimreaper France 🇫🇷
-
+++ b/modules/entity_share_notifier/src/Form/EntityShareSubscriberForm.php @@ -0,0 +1,153 @@ + $form['basic_auth'] = [
If this is an auth method like in the remote config entity, this shouls use the same mecanism now that authentication is pluggable.
-
+++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php @@ -0,0 +1,228 @@ + ->getStorage('channel')
Filter the channels based on the langcode, entity type and bundle before loading the channels if possible to avoid loading hundreds of entities depending on the websites.
-
+++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php @@ -0,0 +1,228 @@ + // TODO. Will require to add a new field on channel to store the user to
Or this will require to have an array of channel_id, user_id in the subscriber config entity instead of an array of channel IDS.
-
+++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php @@ -0,0 +1,228 @@ + ->loadMultiple();
Possible to add a condition on the channels based on $channels_to_notify? To avoid loading unnecessary entities.
-
+++ b/modules/entity_share_notifier/src/HookHandler/EntityHookHandler.php @@ -0,0 +1,228 @@ + $http_client = $this->clientFactory->fromOptions([
Should we require that a subscriber should reference a remote to benefit from the authentication system? And so we can use the remote manager service to get the HTTP client.
-
- 🇧🇪Belgium beerendlauwers
I wrote some code a long while ago for the channel filtering. This goes before
$channels_to_notify[] = $channel->id();
:$filters = $channel->get('channel_filters'); $passedFilters = true; foreach ($filters as $filter) { $directField = $filter['path']; if ($entity->hasField($directField)) { // Only checks first value right now. $firstValueFromFilter = trim((string)$filter['value'][0]); if ($filter['operator'] === '=') { $fieldValue = trim($entity->get($directField)->getString()); if ($fieldValue !== $firstValueFromFilter) { $passedFilters = false; } } elseif ($filter['operator'] === 'CONTAINS') { if (!Arrays::any($entity->get($directField)->getValue(), function ( $element ) use ($firstValueFromFilter) { if (isset($element['value'])) { $fieldValue = $element['value']; } return $fieldValue === $firstValueFromFilter; })) { $passedFilters = false; } } } } if (!$passedFilters) { continue; }
- 🇧🇪Belgium beerendlauwers
For number 5, we could load it from the
remote_id
:$remote_id = $subscriber->get('remote_id'); $remote_config_id = $subscriber->get('remote_config_id'); $remote = $this->entityTypeManager->getStorage('remote')->load($remote_id); if (!($remote instanceof RemoteInterface)) { throw new \LogicException("Could not load remote with ID $remote_id"); } $http_client = $remote->getHttpClient(true);
This could also be done in the constructor if you feel that's cleaner.