1. Go to this page and download the library: Download fpn/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/ */
fpn / tag-bundle example snippets
namespace Acme\TagBundle\Entity;
use FPN\TagBundle\Entity\Tag as BaseTag;
class Tag extends BaseTag
{
}
namespace Acme\TagBundle\Entity;
use \FPN\TagBundle\Entity\Tagging as BaseTagging;
class Tagging extends BaseTagging
{
}
namespace Acme\TagBundle\Entity;
use \FPN\TagBundle\Entity\Tag as BaseTag;
use Doctrine\ORM\Mapping as ORM;
/**
* Acme\TagBundle\Entity\Tag
*
* @ORM\Table()
* @ORM\Entity
*/
class Tag extends BaseTag
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\OneToMany(targetEntity="Tagging", mappedBy="tag", fetch="EAGER")
**/
protected $tagging;
}
namespace Acme\TagBundle\Entity;
use \FPN\TagBundle\Entity\Tagging as BaseTagging;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\UniqueConstraint;
/**
* Acme\TagBundle\Entity\Tagging
*
* @ORM\Table(uniqueConstraints={@UniqueConstraint(name="tagging_idx", columns={"tag_id", "resource_type", "resource_id"})})
* @ORM\Entity
*/
class Tagging extends BaseTagging
{
/**
* @var integer $id
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Tag")
* @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
**/
protected $tag;
}
namespace Acme\BlogBundle\Entity;
use DoctrineExtensions\Taggable\Taggable;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="acme_post")
*/
class Post implements Taggable
{
private $tags;
public function getTags()
{
$this->tags = $this->tags ?: new ArrayCollection();
return $this->tags;
}
public function getTaggableType()
{
return 'acme_tag';
}
public function getTaggableId()
{
return $this->getId();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.