I might be missing something but in entity_embed/src/Form/EntityEmbedDialog.php on line 763 there's the possibility to hook into the submitEmbedStep function:

// Allow other modules to alter the values before getting submitted to the WYSIWYG.
$this->moduleHandler->alter('entity_embed_values', $values, $entity, $display, $form_state);

This works but the alter function only accepts and uses 2 context variables:

public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL);

So the $form_state variable is never passed to the altering modules, right? Is this intentional?

CommentFileSizeAuthor
#7 2907616-7.patch745 byteswim leers

Comments

sanderjp created an issue. See original summary.

sanderjp’s picture

Issue summary: View changes
sanderjp’s picture

Issue summary: View changes
wim leers’s picture

Title: 'entity_embed_values' alter hook does not pass $form_state » hook_entity_embed_values_alter() does not pass $form_state
Priority: Normal » Critical

I'm shocked this API even exists … it's not documented in entity_embed.api.php. This seems like a very bad idea IMHO…

marcoscano’s picture

wim leers’s picture

Component: Code » Documentation
Priority: Critical » Major

Yep, both are docs bugs. Also, I think I overestimated the priority of this, degrading :)

wim leers’s picture

Status: Active » Needs review
Related issues: +#2688427: Rich HTML Captions
StatusFileSize
new745 bytes

I'm wondering if we can't just remove this API? OTOH, it's already in there, so … better not break this.

#2688427: Rich HTML Captions added this. Specifically, https://github.com/drupal-media/entity_embed/pull/212/commits/c1ea27f98c.... Without any discussion/reasoning in https://github.com/drupal-media/entity_embed/pull/212. So that makes it difficult to figure out whether we can remove this.

Granting access to $form_state on top of what's already being provided to alter hooks would make this even more complex. So, given that only a single person ever noticed this, and nobody can be relying on $form_state, I'm just gonna go ahead and remove $form_state. It's effectively a dead parameter.

wim leers’s picture

Title: hook_entity_embed_values_alter() does not pass $form_state » Follow-up for #2688427: hook_entity_embed_values_alter() does not pass $form_state

  • Wim Leers committed f7e893a on 8.x-1.x
    Issue #2907616 by Wim Leers, SanderJP, marcoscano: Follow-up for #...
wim leers’s picture

Priority: Major » Minor
Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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