stof / StofDoctrineExtensionsBundle

Integration bundle for DoctrineExtensions by l3pp4rd in Symfony
https://symfony.com/bundles/StofDoctrineExtensionsBundle/current/index.html
MIT License
1.89k stars 379 forks source link

How can I use Gedmo Translatable and Gedmo Loggable together? #479

Open creator81 opened 8 months ago

creator81 commented 8 months ago

I use Smyfony 6.4 with Doctrine and stof/doctrine-extensions-bundle

<?php

namespace App\Entity;

use App\Repository\TestRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Loggable\Loggable;
use Gedmo\Translatable\Translatable;
use Gedmo\Mapping\Annotation as Gedmo;

#[Gedmo\Loggable]
#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test implements Translatable, Loggable
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[Gedmo\Versioned]
    #[Gedmo\Translatable]
    #[ORM\Column(length: 255)]
    private ?string $name = null;

}

Versioning does not take place once Translatable is activated. The instruction is simply ignored. There are no log entries that indicate an error.

If I use Gedmo\Versioned, it works. If I use Gedmo\Translatable, it works. If I use both, only Gedmo\Translatable works.

Is that what you want?

I also posted the question here https://stackoverflow.com/questions/77988068/how-can-i-use-gedmo-translatable-and-gedmo-loggable-together

Chris53897 commented 8 months ago

Maybe related to https://github.com/stof/StofDoctrineExtensionsBundle/pull/384 ? But translatable should be called first https://github.com/stof/StofDoctrineExtensionsBundle/blob/main/src/DependencyInjection/StofDoctrineExtensionsExtension.php#L183

creator81 commented 8 months ago

This is from 2018, so I ignored that. Sorry! I don't want a priority for this, but rather need both functionalities on the same property.

I suspect that it is not intended to use both functions on one property?

The logic is similar, but as I understand it is not feasible because the translations would then have to refer to the table with the versions.

stof commented 2 months ago

You should ask on the repository of the extensions themselves to know whether both extensions can be used on the same field or no. This repository is for the Symfony bundle providing the wiring of the extensions, not for the extensions themselves (and I'm not the maintainer of the extensions)