Home > Software engineering >  How to access a the database data for Lexik Translation Bundle?
How to access a the database data for Lexik Translation Bundle?

Time:09-17

I am using the Lexik Trnaslation Bundle.

After I ran

./bin/console doctrine:schema:update --force

It added some tables to my database. These tables however don't have any Entities or Repository Classes.

How can I fetch the Data from these tables? Is this even possible with doctrine?

CodePudding user response:

There are entity classes and repository classes mapped to these new tables, or course. Otherwise doctrine:schema:update wouldn't create any tables at all.

If you take a look at the source code of the plugin, you'll see the corresponding classes here.

The repositories are:

  • FileRepository
  • TransUnitRepository
  • TranslationRepository

These repositories are not declared as services, so you won't be able to inject them directly. But you can inject the ManagerRegistryInterface and get the repository like this:

// example to get the FileRepository, assuming that $this->manager
// holds the EntityManager

$fileRepository = $this
            ->manager
            ->getRepository(Lexik\Bundle\TranslationBundle\Entity\File::class);
  • Related