Example #1
0
 /**
  * Actually convert from $source to $targetType
  *
  * @param string $source
  * @param string $targetType
  * @param array $convertedChildProperties
  * @param PropertyMappingConfigurationInterface $configuration
  * @throws \Exception
  * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
  * @return Vote
  * @api
  */
 public function convertFrom($source, $targetType, array $convertedChildProperties = array(), PropertyMappingConfigurationInterface $configuration = NULL)
 {
     /** @var Vote $vote */
     $vote = $this->objectManager->get(Vote::class);
     $vote->setUser($this->getUserService()->getUserIdentifier());
     $vote->setIp(GeneralUtility::getIndpEnv('REMOTE_ADDR'));
     $vote->setTime(time());
     $vote->setValue((int) GeneralUtility::_GP('value'));
     $vote->setPid($this->getContentElementPid());
     /** @var VotedObject $votedObject */
     $votedObject = $this->objectManager->get(VotedObject::class);
     $votedObject->setIdentifier((int) $source);
     $votedObject->setContentType($this->getContentType());
     $vote->setVotedObject($votedObject);
     // Retrieve uid
     $voteData = $this->voteRepository->getVoteData($vote);
     if (array_key_exists('uid', $voteData)) {
         $vote->_setProperty('uid', (int) $voteData['uid']);
     }
     return $vote;
 }