/** * Adds new tags to global tag list. * Returns tag dto for every provided tag label. * If tag has * * @param array<string> $tagList * @return array<BOL_Tag> */ public function updateTagList($tagList) { $tagList = $tagList; // TODO add bad words filter foreach ($tagList as $key => $value) { // TODO badwords filter + add to construction below if (trim($value) === '' || false) { unset($tagList[$key]); continue; } $tagList[$key] = $value; //TODO add process (remove html tags and not allowed symbols) } $tagList = array_unique($tagList); $tagsInDb = empty($tagList) ? array() : $this->tagDao->findTagsByLabel($tagList); $tagsInDbLabels = array(); /* @var $value BOL_Tag */ foreach ($tagsInDb as $value) { $tagsInDbLabels[] = $value->getLabel(); } if (sizeof($tagList) !== sizeof($tagsInDb)) { foreach ($tagList as $value) { if (!in_array($value, $tagsInDbLabels)) { $newTag = new BOL_Tag(); $newTag->setLabel($value); $this->tagDao->save($newTag); $tagsInDb[] = $newTag; } } } return $tagsInDb; }