示例#1
0
 public function load(ObjectManager $manager)
 {
     // Liste des noms de catégorie à ajouter
     $names = array('Console', 'Marque', 'Biscuit', 'Voiture', 'Espace');
     foreach ($names as $name) {
         $tag = new Tag();
         $tag->setName($name);
         $manager->persist($tag);
     }
     $manager->flush();
 }
示例#2
0
 public function load(ObjectManager $em)
 {
     $html = new Tag();
     $html->setName('HTML 5');
     $html->setDescription('Description HTML 5');
     $css = new Tag();
     $css->setName('CSS 3');
     $css->setDescription('Description CSS 3');
     $jquery = new Tag();
     $jquery->setName('jQuery');
     $jquery->setDescription('Description jQuery');
     $php = new Tag();
     $php->setName('PHP');
     $php->setDescription('Description PHP');
     $ajax = new Tag();
     $ajax->setName('AJAX');
     $ajax->setDescription('Description AJAX');
     $symfony = new Tag();
     $symfony->setName('Symfony 2');
     $symfony->setDescription('Description Symfony 2');
     $bootstrap = new Tag();
     $bootstrap->setName('Bootstrap');
     $bootstrap->setDescription('Description Bootstrap');
     $em->persist($html);
     $em->persist($css);
     $em->persist($jquery);
     $em->persist($php);
     $em->persist($ajax);
     $em->persist($symfony);
     $em->persist($bootstrap);
     $em->flush();
     $this->addReference('tag-html', $html);
     $this->addReference('tag-css', $css);
     $this->addReference('tag-jquery', $jquery);
     $this->addReference('tag-php', $php);
     $this->addReference('tag-ajax', $ajax);
     $this->addReference('tag-symfony', $symfony);
     $this->addReference('tag-bootstrap', $bootstrap);
 }
示例#3
0
 /**
  * Add tag
  *
  * @param \BlogBundle\Entity\Tag $tag
  *
  * @return Article
  */
 public function addTag(\BlogBundle\Entity\Tag $tag)
 {
     $tag->addArticle($this);
     $this->tags[] = $tag;
     return $this;
 }
示例#4
0
 /**
  * Creates a form to delete a Tag entity.
  *
  * @param Tag $tag The Tag entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createDeleteForm(Tag $tag)
 {
     return $this->createFormBuilder()->setAction($this->generateUrl('blog_tag_delete', array('id' => $tag->getId())))->setMethod('DELETE')->getForm();
 }