Repository URL to install this package:
|
Version:
6.2.0 ▾
|
| Entity |
| DependencyInjection |
| Model |
| EventSubscriber |
| DigitalAsceticTagsBundle.php |
| .htaccess |
| CHANGELOG.md |
| README.md |
| composer.json |
composer require digitalascetic/tags
Add this bundle to your AppKernel:
public function registerBundles()
{
return array(
...
new \DigitalAscetic\TagsBundle\DigitalAsceticTagsBundle(),
);
}
This bundle is disabled by default. You need to enable explicitly:
digital_ascetic_tags:
enabled: true
default_tag: DigitalAscetic\TagsBundle\Test\Entity\Tag
To improve performance, this bundle exclude ManyToMany relation between entities. Instead ITaggable only store a json string with an array of Tag id's, and ITagRelationship stores the relation between entities.
Wit this logic, we improve the performance queries and reduce a lot of n+1 queries to database.
This bundle is based on 3 interfaces:
If you need to work wit multiple ITag entities, you must implements this two interfaces:
Also we've implemented two Traits to simplify your code:
So you can simply add/remove tags to an entity like this:
$taggable = new TaggableEntity();
$taggable->addTag($tag1);
$taggable->removeTag($tag2);
To find which entities has one or more tags related, you only need to query to your ITagRelationship entity, or maybe do a join between your ITaggable and ITaggableRelationship entities.
To get more information about it, you can see Testing section.
Run:
./vendor/bin/simple-phpunit