예제 #1
0
 public function load(ObjectManager $manager)
 {
     $tag = new Tag();
     $tag->setName('name');
     $manager->persist($tag);
     $manager->flush();
     self::$tags[] = $tag;
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $faker = \Faker\Factory::create('pl_PL');
     for ($a = 0; $a < self::SIZE; $a++) {
         $tag = new Tag();
         $tag->setName($faker->word);
         $tag->addPost($this->getReference(sprintf('tag-post-%d', rand(0, LoadCommentPostData::MAX_SIZE - 1))));
         $manager->persist($tag);
     }
     $manager->flush();
 }
예제 #3
0
 /**
  *
  * @param string $string String to transform
  *
  * @return Tag $tag
  *
  */
 public function reverseTransform($string)
 {
     $tags = new \Doctrine\Common\Collections\ArrayCollection();
     $arrayOfTags = explode(",", $string);
     foreach ($arrayOfTags as $nameOfTag) {
         $result = $this->om->getRepository('AcmeBlogBundle:Tag')->findOneByName($nameOfTag);
         if (!$result) {
             //Action when tag don't exist
             $tag = new Tag();
             $tag->setName($nameOfTag);
             $tags->add($tag);
         } else {
             $tags->add($result);
         }
     }
     return $tags;
 }
예제 #4
0
파일: User.php 프로젝트: tarnawski/Blog
 /**
  * Add tags
  *
  * @param \Acme\BlogBundle\Entity\Tag $tags
  * @return User
  */
 public function addTag(\Acme\BlogBundle\Entity\Tag $tags)
 {
     $tags->addUser($this);
     $this->tags[] = $tags;
     return $this;
 }