Skip to content
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

Recognize "translatable" in "attribute-overrides" #1631

Merged
merged 1 commit into from Jul 14, 2016
Merged

Recognize "translatable" in "attribute-overrides" #1631

merged 1 commit into from Jul 14, 2016

Conversation

vbartusevicius
Copy link
Contributor

Recognizes added translatable element to a predefined field in doctrine's mapped-superclass.

@vbartusevicius
Copy link
Contributor Author

vbartusevicius commented Jul 14, 2016

Stuck exactly on same problem as here: http://stackoverflow.com/questions/15948330/override-a-property-and-make-it-translatable-in-doctrine-translatable-symfony2

For me such situation happened in SonataClassificationBundle: the BaseCategory has a predefined field "name" in mapped-superclass, which, in my task, needs to be translatable. With this implementation this is became possible:

BaseCategory.orm.xml:

<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
                  xsi="http://www.w3.org/2001/XMLSchema-instance"
                  schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
    <mapped-superclass name="Sonata\ClassificationBundle\Entity\BaseCategory">
        <field name="name" type="string" column="name"/>
        ...
    </mapped-superclass>
</doctrine-mapping>

Category.orm.xml:

<?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="Application\Sonata\ClassificationBundle\Entity\Category"
            table="classification__category"
            repository-class="SomeBundle\Repository\CategoryRepository">
        <id name="id" type="integer" column="id">
            <generator strategy="AUTO"/>
        </id>
        <attribute-overrides>
            <attribute-override name="name">
                <field type="string" column="name" length="255" nullable="false">
                    <gedmo:translatable/>
                </field>
            </attribute-override>
        </attribute-overrides>
        <gedmo:translation entity="SomeBundle\Entity\Translation" locale="locale"/>
    </entity>
</doctrine-mapping>

@vbartusevicius vbartusevicius changed the title Recognize gedmo:translatable in attribute-overrides Recognize "translatable" in "attribute-overrides" Jul 14, 2016
@l3pp4rd l3pp4rd merged commit bbfd0af into doctrine-extensions:master Jul 14, 2016
@l3pp4rd
Copy link
Contributor

l3pp4rd commented Jul 14, 2016

dekui ;)

@vbartusevicius
Copy link
Contributor Author

Could You please bump a new tag? Looks like packagist did'nt found out about changes

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Jul 15, 2016

master 3.0.0 is not compatible with 2.4.x versions, so you would have to make another PR to 2.4.x branch or use dev-master

@vbartusevicius
Copy link
Contributor Author

Sorry, forgot that master is on 3.0 - just added PR: #1632

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Jul 18, 2016

@vbartusevicius could you resolve the following issue #1634 ?

@vbartusevicius
Copy link
Contributor Author

Yes, will look on it.

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Jul 19, 2016

thanks ;)

@vbartusevicius
Copy link
Contributor Author

no problem :)

@broncha
Copy link

broncha commented Jan 11, 2019

How would you do this for annotation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants