FabienPennequin / FPNTagBundle

This bundle allows to tag your Doctrine entities easily
http://knpbundles.com/FabienPennequin/FPNTagBundle
76 stars 50 forks source link

Exception when "Tag" and "Tagging" entities have new table name specified in annotation @ORM\Table(name="new_name"). #24

Open yanickj opened 11 years ago

yanickj commented 11 years ago

Thank you for the great bundle! I followed the instructions for installation using annotations and everything worked perfectly until I tried to change the table names for the tag and tagging entities.

After the database was updated for the new table names I attempted to load fixtures and an exception was thrown with a message indicating the "Tag" table did not exist.

To make a long story short, I was able to resolve this problem by adding a leading "\" to the model: definitions in config.yml


fpn_tag:
    model:
        tag_class:     \Acme\TagBundle\Entity\Tag
        tagging_class: \Acme\TagBundle\Entity\Tagging

Alternatively, l think that the leading "\" could be added in FPNTagBundle/Reources/config/orm.xml

<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <parameters>
        <parameter key="fpn_tag.tag_manager.class">FPN\TagBundle\Entity\TagManager</parameter>
        <parameter key="fpn_tag.entity.tag.class">FPN\TagBundle\Entity\Tag</parameter>
        <parameter key="fpn_tag.entity.tagging.class">FPN\TagBundle\Entity\Tagging</parameter>
    </parameters>

    <services>
        <service id="fpn_tag.tag_manager" class="%fpn_tag.tag_manager.class%">
            <argument type="service" id="doctrine.orm.entity_manager" />
            <argument>\%fpn_tag.entity.tag.class%</argument>
            <argument>\%fpn_tag.entity.tagging.class%</argument>
            <argument type="service" id="fpn_tag.slugifier" />
        </service>
    </services>

</container>

I'd be happy to submit a PR for either.

succinct commented 11 years ago

This seems to be the same issue as described in https://github.com/FabienPennequin/FPNTagBundle/issues/21

yanickj commented 11 years ago

The two issues that I experienced were separate. When I experienced the missing "resource_type" error as described in #21 it was due to an error in specifying the namespace of the class that the custom tagging entities were extending. The namespace typo effectively omitted the entity metadata/annotations that Doctrine needed to create the missing columns.

The issue described here is one in which changing the table name in annotations properly creates the tables, but the tagging bundle is not able to locate the model classes defined in config.yml when saving the tags. Instead the bundle defaults to the parent entity objects which specify "Tag" and "Tagging" as the tables.

succinct commented 11 years ago

My mistake, @yanickj. I'm unable to create the tables at all even after applying this fix and your fix in #21, unfortunately.

daikiridev commented 9 years ago

Hello,

any solution ? I am encountering exactly the same issue.

DDev

EDITED: Things are now ok by removing the "FogsTaggingBundle" line in the config.yml:

doctrine: ... orm: default: mappings: # to be declared for each entity in MySQL DB ApplicationSonataUserBundle: ~ ...

FogsTaggingBundle: ~