PHP code example of icap-lyon1 / simple-tag-bundle
1. Go to this page and download the library: Download icap-lyon1/simple-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/ */
icap-lyon1 / simple-tag-bundle example snippets
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new ICAPLyon1\Bundle\SimpleTagBundle\ICAPLyon1SimpleTagBundle(),
);
}
// Acme/Bundle/AcmeBundle/Entity/TaggableEntity.php
namespace Acme\Bundle\AcmeBundle\Entity;
use ICAPLyon1\Bundle\SimpleTagBundle\Entity\TaggableInterface;
class TaggableEntity implements TaggableInterface
{
// Your code here
}
// Instead of standard form creation
// $form = $this->createForm(new MyObjectType(), $myObject);
// Do this:
$form = $this->get('icaplyon1_simpletag.manager')->createForm(
new TaggableEntityType(),
$entity);
if ($form->isValid()) {
$myObject = $this->get('icaplyon1_simpletag.manager')->processForm($form);
return $this->redirect($this->generateUrl(...));
}
// ...
//Associate tags with your entity
$this->get("icaplyon1_simpletag.manager")->addTag($tag, $entity);
// ...
// ...
//Associate tags with your entity
$this->get("icaplyon1_simpletag.manager")->addTags($tags, $entity);
// ...