We don't really provide any hooks yet. We should have hooks in various places... For example state changes, etc.

Comments

berdir’s picture

The question is what kind of hooks we need.

State changes are relatively easy to detect using the default insert/update hooks. I'm not sure if we need specific hooks for that. Another story would be a hook *before* a state change is done which could be implemented to prevent such a change. I've thought about this before, but I have no idea how to that in a generic way. I have a feeling that we will need more specific hooks like those that I added to the ui checkout function.

swentel’s picture

Component: Code » Core

A hook on tmgmt_field_populate_entity would be useful. There's no way (besides extending TMGMTNodeSourcePluginController to take over the saveTranslation() method and adding additional custom calls) to act on saving field api fields. I have a really special use case where the value of the column is a reference to a panel display. hook_tmgmt_source_translation_structure is good because I could implement it for my field type, but I need something like hook_tmgmt_field_import (or whatever you want to call it).

Unless I'm missing something completely.

swentel’s picture

Status: Active » Needs review
StatusFileSize
new3.42 KB

Here's a patch which allows me to modify the entity when a module who owns the field type implements a hook/function. Or use use the module name of course, doesn't really matter.

berdir’s picture

Yes, this looks useful.

#1863600: Untranslated safe_value causes wrong pathauto to be assigned to translated node is a nice example why the text field also needs to do some post-processing of those values, can we additionally add an alter callback that's invoked for the field module? Or should it be a normal drupal_alter() or is there maybe even something that we can call? (I don't think calling hook_field_load() makes sense?)

berdir’s picture

Wondering if we want to unify, as far as it makes sense, the arguments for this hook with the new arguments to the structure hook/callback. Which means "$entity_type, $entity, $field, $instance, $langcode, $items". Instead of items, it would be $data.

berdir’s picture

Something like this.

berdir’s picture

StatusFileSize
new5.5 KB

Forgot a file.

berdir’s picture

Title: Provide hooks » Provide a hook for field types when populating translations.
Status: Needs review » Fixed

Ok, commited.

I'll mark this issue as fixed. We'll open more specific issues if the need for other hooks occur.

Status: Fixed » Closed (fixed)

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