PHP code example of vivait / tag-bundle

1. Go to this page and download the library: Download vivait/tag-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

vivait / tag-bundle example snippets



    public function getTags()
    {
        $this->tags = $this->tags ?: new ArrayCollection();
        return $this->tags;
    }

    public function getTaggableType()
    {
        return 'finance_tag';
    }

    public function getTaggableId()
    {
        return $this->getId();
    }


$tagManager = $this->get('fpn_tag.tag_manager');
$tagManager->loadTagging($entity);

        $tag = $tm->loadOrCreateTag($this->tag);

        if(!$finance->getTags()->contains($tag)) {
            $tm->addTag($tag,$finance);
        }

        $em->persist($finance);
        $em->flush();

        $tm->saveTagging($finance);

    $tm = $this->tag_manager;
    $em = $this->em;

        $tm->loadTagging($finance);
        $tag = $tm->loadOrCreateTag($this->tag);

        $tm->removeTag($tag, $finance);
        $em->persist($finance);
        $em->flush();

        $tm->saveTagging($finance);