Problem/Motivation

Recently, a hook to the D7 version of Feeds was added to be invoked before validation happens. See #3046592: Add a hook to invoke before validation. It would be useful to do something similar for the D8 version, but being an event instead.

The event can be used to fix validation issues that are preventing some items from being imported.

Proposed resolution

Add an event called "feeds.process_entity_prevalidate" and dispatch it just before validation.

Remaining tasks

  • Review.
  • Commit.

User interface changes

None.

API changes

A new event called "feeds.process_entity_prevalidate" is added.

Data model changes

None.

Patch will follow.

Comments

MegaChriz created an issue. See original summary.

megachriz’s picture

Status: Active » Needs review
StatusFileSize
new10.27 KB
megachriz’s picture

StatusFileSize
new11.39 KB
new1.12 KB

Forgot to document the method Feed::dispatchEntityEvent() in FeedInterface.

megachriz’s picture

StatusFileSize
new11.07 KB
new2.12 KB

Coding standards fixes.

danielveza’s picture

Status: Needs review » Reviewed & tested by the community

This is awesome. Nice job mate. The Paragraphs integration with feeds wasn't enough for me. I was trying to figure out what the best class to override was to do the work I needed.

Instead I was able to subscribe to the prevalidate event.

This is much cleaner. Big thumbs up.

RTBC for the functionality. Haven't done a code style review.

megachriz’s picture

StatusFileSize
new9.88 KB
new2.14 KB

@DanielVeza
Thanks for testing! I had this feature lying around for at least a year (developed for a client) but it was tangled with a few other uncompleted - but related - features (one of the features will come in a follow-up by the way). Finally found some time to untangle it and complement it with tests.

When I intially developed this feature Feed::eventDispatcher() did not exist yet, so that's why dispatches the entity event happened in FeedImportHandler. I think we can now skip that and dispatch the event directly in the Feed class, as the IMPORT_FINISHED event is also dispatched in that class.

I commit the patch if it still passes tests.

  • MegaChriz committed bf3f6e4 on 8.x-3.x
    Issue #3054851 by MegaChriz: Added an event to before validation:...
megachriz’s picture

Status: Reviewed & tested by the community » Fixed

Comitted #6.

megachriz’s picture

The follow-up patch is in #2991955-6: Dispatch events before and after saving an entity during processing, where events are added for presaving and postsaving an entity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.