-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translatable not working after update #316
Comments
Same issue here. Register: doctrine:
dbal:
#url: '%env(DATABASE_URL)%'
driver: '%database_driver%'
host: '%database_host%'
dbname: '%database_name%'
user: '%database_user%'
password: '%database_password%'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
orm:
auto_generate_proxy_classes: '%kernel.debug%'
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
gedmo_translatable:
type: xml
prefix: Gedmo\Translatable\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
alias: GedmoTranslatable # (optional) it will default to the name set for the mapping
is_bundle: false
gedmo_translator:
type: xml
prefix: Gedmo\Translator\Entity
dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
is_bundle: false Class to be translated Grade.php: <?php
namespace MWS\CustomerBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use MWS\CustomerBundle\Entity\CustomerContact;
use Gedmo\Translatable\Translatable;
/**
* grade
*/
class Grade implements Translatable
{
/**
* Constructor
*/
public function __construct()
{
$this->customerContacts = new ArrayCollection();
}
/**
* @var int
*/
private $id;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $abbrevation;
/**
* @var string
*/
private $locale;
private $customerContacts;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return grade
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set abbrevation
*
* @param string $abbrevation
*
* @return grade
*/
public function setAbbrevation($abbrevation)
{
$this->abbrevation = $abbrevation;
return $this;
}
/**
* Get abbrevation
*
* @return string
*/
public function getAbbrevation()
{
return $this->abbrevation;
}
/**
* Set locale
*
* @param string $locale
*
* @return grade
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* Get locale
*
* @return string
*/
public function getLocale()
{
return $this->locale;
}
/**
* Add customerContacts
*
* @param CustomerContact $customerContacts
* @return Grade
*/
public function addCustomerContact(CustomerContact $customerContacts)
{
$this->customerContacts[] = $customerContacts;
return $this;
}
/**
* Remove customerContacts
*
* @param CustomerContact $customerContacts
*/
public function removeCustomerContact(CustomerContact $customerContacts)
{
$this->customerContacts->removeElement($customerContacts);
}
/**
* Get customerContacts
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getCustomerContacts()
{
return $this->customerContacts;
}
} Corresponding xml File: <?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
>
<entity name="MWS\CustomerBundle\Entity\Grade"
table="mws_customer_grade"
repository-class="MWS\CustomerBundle\Repository\GradeRepository"
>
<gedmo:translation entity="MWS\CustomerBundle\Entity\GradeTranslation" locale="locale"/>
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="name" type="string" column="name" length="255">
<gedmo:translatable/>
</field>
<field name="abbrevation" type="string" column="abbrevation" length="50">
<gedmo:translatable/>
</field>
<field name="locale" type="string" column="locale" length="5"/>
<one-to-many field="customerContacts"
target-entity="MWS\CustomerBundle\Entity\CustomerContact"
mapped-by="grade">
<cascade>
<cascade-persist/>
<cascade-remove/>
</cascade>
</one-to-many>
</entity>
</doctrine-mapping> Translation Class GradeTranslation.php <?php
namespace MWS\CustomerBundle\Entity;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;
class GradeTranslation extends AbstractTranslation
{
} The xml file: <?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
>
<entity name="MWS\CustomerBundle\Entity\GradeTranslation"
table="mws_customer_grade_translation"
repository-class="MWS\CustomerBundle\Repository\GradeTranslationRepository"
>
<unique-constraints>
<unique-constraint columns="locale, object_class, field, foreign_key"
name="mws_customer_grade_translation_idx"/>
</unique-constraints>
</entity>
</doctrine-mapping> The error message: |
Is someone actively solving this? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Composer lock content.
"name": "symfony/symfony",
"version": "v2.8.0",
After update, the translatable is not working anymore. I am not sure if I made a mistake by configuration. Because the bundle is working just fine until composer update.
The translation entity
Doctrine\ORM\Mapping\MappingException
"No identifier/primary key specified for Entity "App\CoreBundle\Entity\CategoryTranslation". Every Entity must have an identifier/primary key."
I have actually more than one translation entities until now. change the value of auto_mapping to false
leads to
" The class 'App\UserBundle\Entity\User' was not found in the chain configured namespaces Gedmo\Translatable\Entity, Gedmo\Translator\Entity, FOS\UserBundle\Model"
It might not be issue, but I found no solutions on stackoverflow.
The text was updated successfully, but these errors were encountered: