Giter Site home page Giter Site logo

Comments (4)

stof avatar stof commented on May 21, 2024

First the namespace of the repository is wrong: it is now Gedmo\Translatable\Entity\Repository\TranslationRepository.

Which version of Doctrine are you using ? The EntityGenerator did not handled the inheritance at the time of the 2.0.0 release (which produced exactly the error you get). This is now fixed but I don't remember if it was before the 2.0.1 release or after. It will work with 2.0.2 anyway (which will be released at the end of the month).

Using YAML for your own entities should work. The YAML mapping is described on the blog of the extension integrated by my bundle.

Btw most of the work is done by l3pp4rd which provides the extension. the bundle is easy comparing to the extension :)

Regards.

from stofdoctrineextensionsbundle.

justfortier avatar justfortier commented on May 21, 2024

I'm using Doctrine version 2.0.1-DEV

I'm trying to use your mapped super class, but I'm having some difficulties. Do you have any usage examples? I seem to be able to create object, and it puts the default locale into the i18n table. Once I grab the object, change the locale (verified that it does indeed change the locale), and save it it does not seem to saving the translation, or anything for that matter. Not sure what I'm doing wrong.

Here's how it's setup:

##### PERMISSIONS #####
MRX\Backend\AuthBundle\Entity\Permissions:
  type: entity
  table: permissions
  gedmo:
    translation:
      entity: MRX\Backend\AuthBundle\Entity\PermissionsI18n
      
  fields:
    id:
      id: true
      type: bigint
      nullable: false
    
    token:
      type: string
      length: 25
      fixed: false
      nullable: false
    
    name:
      type: string
      length: 25
      fixed: false
      nullable: false
      gedmo:
        - translatable
    
    description:
      type: string
      length: 255
      fixed: false
      nullable: false
      gedmo:
        - translatable
      
    inheritable:
      type: boolean
      
  lifecycleCallbacks: {  }
##### PERMISSSIONS I18N #####

MRX\Backend\AuthBundle\Entity\PermissionsI18n:
  type: entity
  table: permissions_i18n
  repositoryClass: Gedmo\Translatable\Entity\Repository\TranslationRepository
  
  indexes:
    translations_lookup_idx:
      columns: [locale, object_class, foreign_key]
    
  uniqueConstraints:
    lookup_unique_idx:
      columns: [locale, object_class, foreign_key, field]
              
  fields:
    #id:
      #id: true
      #type: bigint
      #nullable: true
        
  lifecycleCallbacks: {  }
### CONTROLLER ###

        $this->getSession()->setLocale("fr_CA");
        $perm = $em->find( 'MRX\Backend\AuthBundle\Entity\Permissions', 79 );
        
        $perm->setName("Hamilton");
        $perm->setAccess(1);
        $perm->setDescription("Ma description");
        $perm->setGrant(1);
        $perm->setInheritable(0);
        $perm->setToken("HAM");
        $perm->setEm($em);
        $perm->save(); //just does a persist and flush on the object.

Once again, your help is greatly appreciated!

from stofdoctrineextensionsbundle.

stof avatar stof commented on May 21, 2024

You need to add an unpersisted property in your entity to store the locale and map it for the extension. Look at the official blog to see the YAML mapping example.

from stofdoctrineextensionsbundle.

justfortier avatar justfortier commented on May 21, 2024

Ah, that's what I was missing! Thank you so much, it works perfectly now! I really have to stop working so much, I'm really starting to overlook important and simple things.

Can't wait for that doctrine problem to be gone, it's really making it a pain to use the super-mapped class.

from stofdoctrineextensionsbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.