protected function getTestData() { $term = new Term(); $term->setDescription('PHP'); $term->setName('PHP'); return $term; }
public function saveTerm(Term $term, $vocabulary) { if (is_string($vocabulary)) { $vocabulary = $this->fetchVocabularyByName($vocabulary); } $term->setVocabulary($vocabulary); $data = $this->termHydrator->extract($term); if (empty($data['id'])) { $this->dbal->insert('taxonomyTerms', $data); $term->setId($this->dbal->lastInsertId()); } else { $response = $this->dbal->update('taxonomyTerms', $data, ['id' => $data['id']]); } return $term; }
/** * 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; }
public function addMentorTag(Term $term) { $this->mentorTags[$term->getId()] = $term; }