PHP code example of edumedia / tag-bundle

1. Go to this page and download the library: Download edumedia/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/ */

    

edumedia / tag-bundle example snippets



// src/Entity/Tag.php

namespace App\Entity;

use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use eduMedia\TagBundle\Entity\TagInterface;
use eduMedia\TagBundle\Entity\TagTrait;

#[ORM\Entity]
#[ORM\Table(name: 'tag')]
class Tag implements TagInterface
{

    use TagTrait;

    #[ORM\OneToMany(mappedBy: 'tag', targetEntity: 'App\Entity\Tagging', fetch: 'EAGER')]
    protected ?Collection $tagging = null;

}


// src/Entity/Tagging.php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use eduMedia\TagBundle\Entity\TaggingInterface;
use eduMedia\TagBundle\Entity\TaggingTrait;
use eduMedia\TagBundle\Entity\TagInterface;

#[ORM\Entity]
#[ORM\Table(name: 'tagging')]
class Tagging implements TaggingInterface
{

    use TaggingTrait;

    #[ORM\Id]
    #[ORM\ManyToOne(targetEntity: 'App\Entity\Tag', inversedBy: 'tagging')]
    protected TagInterface $tag;

}


// src/Entity/User

namespace App\Entity;

use eduMedia\TagBundle\Entity\TaggableInterface;
use eduMedia\TagBundle\Entity\TaggableTrait;

class User implements /* (...) */ TaggableInterface
{

    use TaggableTrait;
    
    // (...)
}