示例#1
0
 /**
  * Converts string of tags to an object
  * @param string $tags
  * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
  */
 public function initTags($tags)
 {
     /* @var \Mittwald\Typo3Forum\Domain\Model\Forum\Tag */
     $objTags = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
     $tagArray = array_unique(explode(',', $tags));
     foreach ($tagArray as $tagName) {
         $tagName = ucfirst(trim($tagName));
         if ($tagName == "") {
             continue;
         }
         $searchResult = $this->tagRepository->findTagWithSpecificName($tagName);
         if ($searchResult[0] != false) {
             $searchResult[0]->increaseTopicCount();
             $objTags->attach($searchResult[0]);
         } else {
             /* @var \Mittwald\Typo3Forum\Domain\Model\Forum\Tag $tag */
             $tag = $this->objectManager->get('Mittwald\\Typo3Forum\\Domain\\Model\\Forum\\Tag');
             $tag->setName($tagName);
             $tag->setCrdate(new \DateTime());
             $tag->increaseTopicCount();
             $objTags->attach($tag);
         }
     }
     return $objTags;
 }
示例#2
0
 /**
  * Check if $value is valid. If it is not valid, needs to add an error
  * to Result.
  *
  * @param string $name
  * @return bool
  */
 protected function isValid($name = "")
 {
     $result = TRUE;
     if (trim($name) === '') {
         $this->addError('The name can\'t be empty!.', 1373871955);
         $result = FALSE;
     }
     $name = ucfirst($name);
     $res = $this->tagRepository->findTagWithSpecificName($name);
     if ($res[0] != false) {
         $this->addError('The tag already exists!.', 1373871960);
         $result = FALSE;
     }
     return $result;
 }