コード例 #1
0
 /**
  * @param string $urlSuffixString
  * @return string
  * @throws GetRedirectUrlException
  */
 public function get($urlSuffixString)
 {
     $shortenedUrlSuffix = $this->shortenedUrlSuffixRepo->findBySuffix($urlSuffixString);
     if (null === $shortenedUrlSuffix) {
         throw new GetRedirectUrlException("Url does not exist");
     }
     $this->registerUrlCallService->register($shortenedUrlSuffix);
     return $this->urlEncoder->decode($shortenedUrlSuffix->getOriginalUrlEncodedLink());
 }
コード例 #2
0
 /**
  * @param string $url
  * @return string
  */
 public function create($url)
 {
     $newUrlSuffix = $this->getShortened($url);
     $originalUrlEntity = $this->getOriginalUrlEntity($this->urlEncoder->encode($url));
     $shortenedUrlSuffixEntity = $this->shortenedUrlSuffixFactory->create($originalUrlEntity, $newUrlSuffix);
     $this->entityManager->persist($shortenedUrlSuffixEntity);
     $this->entityManager->flush();
     $shortenedUrl = $this->getShortenedUrlsService->getBySuffix($shortenedUrlSuffixEntity);
     return $shortenedUrl;
 }
コード例 #3
0
 /**
  * @param ShortenedUrlSuffix $shortenedUrlSuffix
  * @param int                $totalExecutions
  * @param int                $totalRedirectsToSameContent
  * @return ShortenedUrl
  */
 public function create(ShortenedUrlSuffix $shortenedUrlSuffix, $totalExecutions, $totalRedirectsToSameContent)
 {
     $link = $this->localUrlAssembler->assemble($shortenedUrlSuffix->getSuffixString());
     $originalLink = $this->urlEncoder->decode($shortenedUrlSuffix->getOriginalUrlEncodedLink());
     return new ShortenedUrl($link, $originalLink, $shortenedUrlSuffix->getDateCreated(), $totalExecutions, $totalRedirectsToSameContent);
 }