Please add an event in ElementQuery::afterPopulate #11262
-
I often have custom field values that should be eager loaded that are no elements. Most of the time I extend your Element classes as well as your ElementQuery classes in order to access the afterPopulate function so I can do custom eager loading like Commerce Orders do, It would be awesome if there was an event for this so I could do custom eager loading via behavior instead of extending the class. So basically just /**
* @inheritdoc
*/
public function afterPopulate(array $elements): array
{
$event = new SomeElementEventName(['elements' => $elements]);
if($this->hasEventHandlers(self::EVENT_AFTER_POPULATE_ELEMENTS)){
$this->trigger(self::EVENT_AFTER_POPULATE_ELEMENTS, $event);
}
return $event->elements;
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Added for 4.1 🎉 (41ba108) You can move to the |
Beta Was this translation helpful? Give feedback.
Added for 4.1 🎉 (41ba108)
You can move to the
4.1
branch by changing yourcraftcms/cms
requirement to4.1.x-dev
in composer.json.