Skip to content

version 2 idea: property hooks

If version 2 of this bundle requires php 8.4 and doctrine/orm ^3.5, perhaps the JsonTranslate property could replace the get* methods with a more direct access.

I've been modifying my code to use property hooks, and was thinking that

// using ArrayAccess
$post->getTitle()["en"] = "Hello";
$post->getTitle()["fr"] = "Bonjour";
$post->getTitle()["es"] = "Hola";

could be replaced with

// using ArrayAccess
$post->title["en"] = "Hello";
$post->title["fr"] = "Bonjour";
$post->title["es"] = "Hola";

or

$post->title = [
'en' => 'hello',
'es' => 'hola'
];

I'm curious on your thought on this, as translation is just one component of "multi-dimensional" entities, a fascinating idea (though I haven't fully wrapped my head around it).

https://live.symfony.com/account/replay/video/1005

Anyway, this is more a discussion than an issue, but I'm curious if php 8.4 property hooks may change how you think about implementation.

Edited by Tac Tacelosky