I am trying to configure translatable extension in my own project. The problem is that I have a whole bundle configured using yaml for mapping entities, so each entity have its own .orm.yml file. Now, I am trying to add the translatable extension but when I run the schema update command I get:
No identifier/primary key specified for Entity "Ruck\SportsBundle\Entity\Tr anslation\SportTranslation" sub class of "Sonata\TranslationBundle\Model\Ge dmo\AbstractPersonalTranslation". Every Entity must have an identifier/prim ary key.
In other bundle where I have used annotations it works fine... So my question is if translatable extension is incompatible with yaml files.
I have reading about this issue
https://github.com/Atlantic18/DoctrineExtensions/issues/671
https://github.com/Atlantic18/DoctrineExtensions/issues/989
but I think is too strange that I can't use yml files with translatable extension...
Thanks
Related
I actually trying to create my own reusable bundle. I created a Demo project that include my custom bundle as dependency using symlink composer config.
Actually, I tried to extract some translation keys from my custom bundle into the demo project.
But when I launch the command bin/console translation:update fr --dump-messages there is no entry from my bundle.
What I want to extract is some constant keys that I want to translate.
For example, in MyCustomClass there is some status in an array. So I don't know if there is an Interface that I can implement to auto extract my translation keys.
I'm using:
Symfony Framework 5.3.8
Symfony Translation 5.3.9
Thanks
With Symfony 3 and its console, we can generate entities from an already existing database via the command "php bin/console doctrine:mapping:import" (very usefull !).
From symfony 4, the command "./bin/console doctrine:mapping:import" needs a bundle name but symfony 4 doesn't work with bundle now.
With the new version of symfony, is there a way I didn't see for generate entities from an existing Database (mysql by example) ? Or must I wait a new version of doctrine for have a "doctrine:mapping:import" compatible with Symfony 4 ?
I found a(n) (ugly) solution yet. I deploy a disposable symfony 3, I link the symfony 3 to my database and I generate entities in a bundle. Then I copy generates files to symfony 4.
It's ugly but it works haha
You can use
php bin/console doctrine:mapping:convert --from-database annotation ./src/Entity
which should create the entities based on the database setting. Don’t forget to add the namespaces, and you will still need to add the getters and setters, but the bulk of the properties, including annotations and some of the relationships are already included. (Source)
Please also note, that Doctrine will not support this anymore in the next Doctrine version. As written in the Symfony docs
Moreover, this feature to generate entities from existing databases will be completely removed in the next Doctrine version.
is it possible to use in a Symfony project Gedmo Doctrine Extension Translatable with YAML configuration and to generate the entities with php bin/console doctrine:generate:entities ?
I tried the StofDoctrineExtensionsBundle, I tried Gedmo on its own. But I didn't get it working.
When I write the entities by hand and use annotations everything works fine. But in my project every entity is defined by YAML.
I create project from Symfony 2, but I have a problem:
In project have multi-bundles(ex: AdminBundle and FontEndBundle)
Case 1: Doctrine orm and Entities generate on FrontEndBundle, then from AdminBundle, I will call Entity via FrontEndBundle:Object it work OK.
Case 2: I want to config structure folow
src/Project/
Model/Entity
OrmYml/doctrine/orm
Bundles(contains FontEndBundle & AdminBundle)
Extensions
In case 2, How do I config Entity mapping to generate Entities to src/Model/Entity directory ? Because when I using Command: doctrine:generate:entities Project/Model/Entity,
error : Namespace "Project\Model\Entity" does not contain any mapped
entities.
How do you declare your entities ?You should put your entities within a bundle. You cant have them outside a bundle .
Usually, Symfony developpers create a third bundle called "CoreBundle" (for example) where you place all the shared resource between your three bundles, namely the entities, some services (like twig extensions), config (with service.xml/yml), ... Also, you can delete the controller and views directories in this bundles, which are useless (don't forget to clean the app/config/routing.yml file by removing the CoreBundle controller injection) !
Then just call your entities in the right bundle with:
use MyName\Bundle\CoreBundle\Entity\MyEntity;
Never create a model repertory not in a bundle, this is not the Symfony philosophy and you are really wrong !
Does anyone know how to configure xml mapping for http://gediminasm.org/article/tree-nestedset-behavior-extension-for-doctrine-2? There is the example only with annotations
It is simple as using annotations. In symfony2 in same xml files where you define the mapping add extra mapping information for extensions, all examples are located in the documentation: on github or my blog