fabienpennequin / doctrineextensions-taggable Goto Github PK
View Code? Open in Web Editor NEWTaggable Behavior for Doctrine2
License: MIT License
Taggable Behavior for Doctrine2
License: MIT License
Hi!
I'm trying to add a discriminator to my Tag entity,
because I don't want project wise Tag but only "Client" specific tags (a group of user own their tags, the others groups can't use them). So I have my TagManager service, extending the one from FPNTagBundle and everything is working fine,
except one thing.
I can't set the "name" property of the Tag object not unique (metadata/DoctrineExtensions.Taggable.Entity.Tag.dcm.xml
).
This is a deal breaker and I will not be able to use this extension unless the constraint is made optional (I don't know how) as :
$name
property (Doctrine throw a mapping exception: Duplicate definition of column 'name' on entity 'My\Bundle\AwesomeBundle\Entity\Tag' in a field or discriminator column mapping.
)I don't know if discriminator is something that should be made possible with this extension,
at the moment my only alternative if to fork the project and edit the metadata/DoctrineExtensions.Taggable.Entity.Tag.dcm.xml
file to remove the constrain, maybe there is something that can be done in a more clever way?
saveTagging function manipulates taggable resource property tags ($newTags = $resource->getTags()), which is an ArrayCollection, leaving the taggable resource stale tag-wise.
I guess it should be using '$newTags = new ArrayCollection($resource->getTags()->toArray())' if it's always an ArrayCollection.
Meanwhile I have to reload tags after saving them :(
Hi! I think you should provide a starndard trait implementing the Taggable Interface.
Then usage would be easier.
DoctrineExtensions
is also used by @beberlei / DoctrineExtensions. This will potentially cause naming conflicts when used in the same project.
You should tag a stable release, to use in FPNTagBundle.
Otherwise, simply requiring "fpn/tag-bundle": "dev-master" wouldn't work, since in last releases Symfony enforces an higher minimum stability
Can I overwrite the way the tag object gets serialized? Currently everything is returned, I'd like to exclude the id, created_at, updated_at and tagging.
This is my setup, I'm thinking setting the parent of the Tag Bundle to FPN when the namespace of the Entity is actually DoctrineExtensions could be the issue.
# app/config/config.yml
# ...
jms_serializer:
metadata:
auto_detection: true
directories:
TagBundle:
namespace_prefix: "DoctrineExtensions\\Taggable"
path: "@MYTagBundle/Resources/config/serializer/fpn"
# MY\TagBundle\Resources\config\serializer\fpn\Entity.Tag.yml
DoctrineExtensions\Taggable\Entity\Tag:
exclusion_policy: ALL
properties:
id:
expose: false
name:
expose: true
created_at:
expose: false
updated_at:
expose: false
tagging:
expose: false
# src/MY/TagBundle/MYTagBundle.php
<?php
namespace MY\TagBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class MYTagBundle extends Bundle
{
public function getParent()
{
return 'FPNTagBundle';
}
}
Sorry but in your readme.md file you say "Finally, you need to setup doctrine for register metadata directory and register TagListener." Ok. But where I have to put this code? How can I configure doctrine for this stuff?
Thank you in advance.
When i get repository for class Tag in controller:
'''
$tagRepo = $this->getDoctrine()->getManager()->getRepository(mybundle:Tag);
'''
and then call the method "getResourceIdsForTag" :
'''
$tagRepo->getResourceIdsForTag('my_resource', 'my_tag);
'''
Return the error ###ndefined method 'getResourceIdsForTag'. The method name must start with either findBy or findOneBy!###
The problem is that my entity (It is extending the BaseTag entity, as it is written in the documentation) not view the entityRepository located in the doctrine-extension-taggable.
Actually I solved my problem by creating my EntityRepository copying the code from TagRepository located inside doctrine-extension-taggable.
Maybe I wrong something ?
Thanks a lot
Hello,
Nice work on this bundle.
I've some trouble to figure out why the tag queries use the name attributes instead of the slug.
As the slug guarantees the unicity of a tag, asking for a tag which does correspond to the slug but the name should return the given tag.
This behavior should also be working when getting ressources from a tag.
Considering the tag "This is a tag", and its slug "this-is-a-tag", then
$tagRepo->getResourceIdsForTag('article_tag', 'this-is-a-tag'));
should return all the ressources linked to "This is a tag". In this case, nothing will be returned as the tag corresponds to nothing existing in name colum of tag table.
Since all instances implementing DoctrineExtensions\Taggable\Taggable
must share the same taggable type, the Taggable::getTaggableType()
should be declared static, in order to do this:
$em->getRepository('Tag')
->getResourceIdsForTag(MyEntity::getTaggableType(), 'my-tag');
instead of:
$em->getRepository('Tag')
->getResourceIdsForTag('hard_coded_type_string', 'my-tag');
Hello,
Not necessarily a big bug, but if you have tag names that get truncated on the database level (50 characters in length), you will get an integrity constraint violation when adding the tag again.
Uncertain if this should be fixed on the TagManager level or in user-land..
Depending on what you decide, I can provide a Pull Request..
Best Regards,
Khez
Hi,
I'm intending to use the tags bundle for an app that will need to handle taggable entities for different organizations, I don't want Tags defined by Organization A to be visible by Organization B, e.g. lets say I have both Ford and Chevrolet as clients, in the same App, I need to handle tags separately.
I thought Tag groups'd handle that situation. By extending the API with an optional $group attribute that defaults to 'default'.
I'm trying to implement that, might be sending a pull request. :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.