-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
Problem together with SonataTranslationBundle #235
Comments
You need also switch to annotation to overide config.yml doctrine:
orm:
entity_managers:
default:
mappings:
SonataClassificationBundle: ~
ApplicationSonataClassificationBundle: # AppSonataClassificationBundle in your case?
type: annotation As you override xml you need to implement callbacks again. src/App/Sonata/ClassificationBundle/Entity/Category.php /**
* ...
* @ORM\HasLifecycleCallbacks()
*/
class Category extends BaseCategory implements TranslatableInterface
{
/**
* @ORM\PrePersist
*/
public function prePersist()
{
parent::prePersist();
}
/**
* @ORM\PreUpdate
*/
public function preUpdate()
{
parent::preUpdate();
}
... Also to make this fully work you need to switch to dev versions of SonataClassificationBundle and SonataTranslationBundle with fixes: |
Still doesn't work My doctrine config looks like this: # Doctrine Configuration
doctrine:
dbal:
types:
json: Sonata\Doctrine\Types\JsonType
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
SonataClassificationBundle: ~
AppSonataClassificationBundle:
type: annotation
gedmo_translatable:
type: annotation
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 I also updated the dependencies. I was unable to use the dev versions of sonata-project/classification-bundle since sonata-project/media-bundle requires a stable version... $ composer show | grep sonata-project
sonata-project/admin-bundle 3.7.1 The missing Symfony Admin Generator
sonata-project/block-bundle 3.1.1 Symfony SonataBlockBundle
sonata-project/cache 1.0.7 Cache library
sonata-project/classification-bundle 3.1.0 Symfony SonataClassificationBundle
sonata-project/core-bundle 3.1.1 Symfony SonataCoreBundle
sonata-project/datagrid-bundle 2.2 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.0.2 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.1.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle 2.1.10 Symfony SonataEasyExtendsBundle
sonata-project/exporter 1.7.0 Lightweight Exporter library
sonata-project/google-authenticator 1.0.2 Library to integrate Google Authenticator into a PHP project
sonata-project/intl-bundle 2.2.4 Symfony SonataIntlBundle
sonata-project/media-bundle 3.x-dev fabd14b Symfony SonataMediaBundle
sonata-project/notification-bundle 3.0.0 Symfony SonataNotificationBundle
sonata-project/translation-bundle dev-master 67b2808 SonataTranslationBundle
sonata-project/user-bundle 3.0.1 Symfony SonataUserBundle I also added the lifecycle callbacks to my class that seem to run since the updatedAt columns gets updated in the database once I update a record.. Any suggestions? |
I also tried now so my Category class does not extend the BaseCategory but only implements the CategoryInterface and move all code into my class with the same result.. |
ClassificationBundle 3.2.0 was released, so I made a simple demo just to proof that integration is possible and works as expected https://github.com/dmarkowicz/sonata-translatable-classification-demo. |
if it is proven, then closing. Ping me if this issue is relevant. |
Environment
php 7
CentOS 6
nginx
mysql
Sonata packages
$ composer show sonata-project/* sonata-project/admin-bundle 3.7.1 The missing Symfony Admin Generator sonata-project/block-bundle 3.1.1 Symfony SonataBlockBundle sonata-project/cache 1.0.7 Cache library sonata-project/classification-bundle 3.1.0 Symfony SonataClassificationBundle sonata-project/core-bundle 3.1.1 Symfony SonataCoreBundle sonata-project/datagrid-bundle 2.2 Symfony SonataDatagridBundle sonata-project/doctrine-extensions 1.0.2 Doctrine2 behavioral extensions sonata-project/doctrine-orm-admin-bundle 3.1.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle sonata-project/easy-extends-bundle 2.1.10 Symfony SonataEasyExtendsBundle sonata-project/exporter 1.7.0 Lightweight Exporter library sonata-project/google-authenticator 1.0.2 Library to integrate Google Authenticator into a PHP project sonata-project/intl-bundle 2.2.4 Symfony SonataIntlBundle sonata-project/media-bundle 3.x-dev fabd14b Symfony SonataMediaBundle sonata-project/notification-bundle 3.0.0 Symfony SonataNotificationBundle sonata-project/translation-bundle 2.0.2 SonataTranslationBundle sonata-project/user-bundle 3.0.1 Symfony SonataUserBundle
Symfony packages
PHP version
Subject
I'm having an issue when trying to integrate this bundle with SonataTranslationBundle. When trying to make the category entity translatable it doesn't store the translation for me. It works for other entites when doing the exactly same thing.
Steps to reproduce
Setup the bundle like this:
config.yml
src/App/Sonata/ClassificationBundle/Entity/Category.php
src/App/Sonata/ClassificationBundle/Entity/CategoryTranslation.php
Edit
Expected results
The translations should be inserted to the category_translations table and when toggling between English and Swedish the name should change between the translations.
Actual results
The new name of the category gets written directly to the categories.
The text was updated successfully, but these errors were encountered: