Dispatch events for certain situations

Created on 12 April 2022, almost 3 years ago
Updated 21 August 2024, 7 months ago

Problem/Motivation

One of our customers wanted to be notified when geocoding failed, I couldn't find a way to do this with the default functionality of the module so I wrote a patch that adds:
- A 'GeocoderEvents' class that defines one event so far
- A 'GeocoderLogEvent' class that defines the 'geocoder.log_event' class.
- A dispatch of the above event in the 'log' method in src/Geocoder.php

Proposed resolution + Remaining tasks

Improve patch if necessary, merge patch.

Feature request
Status

Needs review

Version

3.0

Component

Code

Created by

🇧🇪Belgium RandalV

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • First commit to issue fork.
  • Merge request !58Update #3274755 code for 4.x → (Open) created by svendecabooter
  • 🇧🇪Belgium svendecabooter Gent

    Created a new MR for the 4.x branch + adding patch file.

  • Pipeline finished with Success
    7 months ago
    Total: 152s
    #260118
  • Status changed to Needs work 7 months ago
  • 🇮🇹Italy itamair

    Thanks here ... this looks a nice feature / add on and a technically correct implementation, that indeed will dispatch a specific Geocoder Event every time a Geocoding operation is going to fail, but why do you call it GeocoderLogEvent instead of something more properly related to the specific context you want to intercept / catch, and that is strictly dependant from a caught exception message?

    Rather I would define a GeocoderFailExcpetionEvent and trigger it only in the same Geocoder catches exceptions that you pointed.

    GeocoderLogEvent sound more something that might / should be dispatched every time a 'geocoder' log is generated in the system, isn't it?

  • 🇮🇹Italy itamair

    ok ... I better inspected all this and I must say that it doesn't match my agreement.

    First of all the Title of this issue ("Dispatch events for certain situations") trigger a wider use context compared to the specific use case the provided MR / Patch tries to implement ... (that only focus on the Geocoding failing cases).

    Furthermore there is a not so strong and opportune use of the drupal_static function (in my opinion), because of the following:
    - drupal_static() and drupal_static_reset() are going to be soon deprecated ( https://www.drupal.org/node/2260187 );
    - from my test (on the MR !58) passing the whole ContentEntityInterface $entity in drupal_static doesn't work, as the &drupal_static(self::STATIC_ENTITY_KEY) will always return NULL (rather / eventually a string, such as the $entity->label() should be used ... );

    It looks (to me) a much better and more general approach should be implemented, to comply to this title ambitions / goal ...

  • First commit to issue fork.
  • Pipeline finished with Success
    5 days ago
    Total: 150s
    #439549
  • 🇧🇪Belgium dtrdewaele

    Hi,

    Thank you for your feedback! I fixed the MR for now, so we can use it for our clients needs, but we have put this ticket on the community wishlist of the company. If our team agrees on this, we will work out a better implementation for this.

Production build 0.71.5 2024