This branch contains the code to make models GameAware by making use of doctrine's postLoad event. It combines an interface (GameAwareInterface) with a trait (GameAware). Models implementing GameAwareInterface automatically get access to the public method setGame and getGame, both potentially needed for raising events within properties.
Furthermore, by combining a lotgd.yml configuration and annotations, this patch allows the easy runtime-modification of models by using the __call magic function. Example:
/**
* @Extension(of="LotGD\Core\Tests\FakeModule\Models\UserEntity")
*/
class UserTestExtension
{
/**
* @ExtensionMethod(as="getNameAsArray")
*/
public static function returnNameAsArrayForUser(UserEntity $user): array
{
$g = $user->getGame();
if ($g !== null) {
return [$user->getName()];
} else {
return [];
}
}
}
This allows me to write $userEntity->getNameAsArray();. Extentable models must implement the ExtendableModelInterface and are advised to use the ExtendableModel trait.
This branch contains the code to make models GameAware by making use of doctrine's postLoad event. It combines an interface (GameAwareInterface) with a trait (GameAware). Models implementing GameAwareInterface automatically get access to the public method
setGame
andgetGame
, both potentially needed for raising events within properties.Furthermore, by combining a lotgd.yml configuration and annotations, this patch allows the easy runtime-modification of models by using the __call magic function. Example:
lotgd.yml:
UserTestExtension:
This allows me to write
$userEntity->getNameAsArray();
. Extentable models must implement the ExtendableModelInterface and are advised to use the ExtendableModel trait.