Exemplo n.º 1
0
 protected function getTestData()
 {
     $term = new Term();
     $term->setDescription('PHP');
     $term->setName('PHP');
     return $term;
 }
Exemplo n.º 2
0
 /**
  * Turns a comma deleted list into a collection of tags
  *
  * @param mixed $tagList
  * @return array
  */
 public function reverseTransform($tagList)
 {
     $tags = explode(',', $tagList);
     $terms = [];
     foreach ($tags as $tagName) {
         try {
             $tagName = trim($tagName);
             $term = $this->taxonomyService->fetchTerm($this->vocabulary, $tagName);
         } catch (TermNotFoundException $e) {
             $term = new Term();
             $term->setDescription($tagName);
             $term->setName($tagName);
             $term = $this->taxonomyService->saveTerm($term, $this->vocabulary);
         }
         $terms[] = $term;
     }
     return $terms;
 }