Skip to main content
13 events
when toggle format what by license comment
Jul 9, 2019 at 15:29 history edited user72672
edited tags
Jul 8, 2019 at 7:24 vote accept CommunityBot
Jul 5, 2019 at 19:49 history edited avpaderno
edited tags
Jul 5, 2019 at 19:04 comment added user72672 Thanks, @Clive. You saved my day.
Jul 5, 2019 at 19:04 answer added user72672 timeline score: 2
Jul 5, 2019 at 18:24 comment added Clive You still don't - that stuff is queryable. $node->getFieldDefinitions() will get you a list of fields attach to the node, you can loop through that and check for any with a type of entity_reference_revisions (or whatever it is), with a target type of paragraph, and get the paragraph entity from it. Then loop through $paragraph->getFieldDefinitions() and look for a media reference fields. If you find one that you're interested in, set its value to the desired value from the node and you're done
Jul 5, 2019 at 18:16 comment added user72672 @Clive, my thoughts was. I need to update all media entities even though they are refenced in a paragraph e.g. and there might be different field names for the different entity reference fields. So I thought if I somehow could get the node in a media presave I didn't have to know every single field and its location.
Jul 5, 2019 at 18:13 comment added Clive The reason you won't find that method is that it wouldn't really make sense for it to be there - a media entity being saved has no reliance on the action having been taken through an entity reference field on an entity form. Is there a reason you decided to go bottom to top rather than top to bottom, though? In hook_node_presave you'll have access to both the pieces of information you need, that's where I'd do it
Jul 5, 2019 at 17:56 comment added seroton Sounds like a form issue. At that point, the changes may not be there on the node. Maybe if you do your logic in a custom submit callback and get what you need from form_state?
Jul 5, 2019 at 17:39 history edited user72672 CC BY-SA 4.0
added 179 characters in body
Jul 5, 2019 at 17:37 comment added user72672 The media entity is a reference field on the node.
Jul 5, 2019 at 17:35 comment added seroton How is the referring node linked to the media entity? What is the user journey?
Jul 5, 2019 at 16:36 history asked user72672 CC BY-SA 4.0