/** * @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; }