Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
ef543d3
test
duchnoun Jun 2, 2022
c96e4b4
test
davidnurdin Jun 2, 2022
20f276f
test
davidnurdin Jun 2, 2022
3515b56
test
davidnurdin Jun 2, 2022
337493f
test
davidnurdin Jun 2, 2022
d841d8c
test
davidnurdin Jun 2, 2022
13fb557
test
davidnurdin Jun 2, 2022
9c95726
update composer
davidnurdin Jun 2, 2022
7b0dcc7
test
davidnurdin Jun 2, 2022
921bd32
test
davidnurdin Jun 2, 2022
497d0a9
test
davidnurdin Jun 2, 2022
4b5e421
test
davidnurdin Jun 2, 2022
c6e0e34
test
davidnurdin Jun 2, 2022
db9b26a
test
davidnurdin Jun 2, 2022
3bc3b15
update configuration tree builder
davidnurdin Jun 2, 2022
64809c6
test
davidnurdin Jun 2, 2022
670a01b
test
davidnurdin Jun 2, 2022
ed4dc82
update routing
davidnurdin Jun 2, 2022
5e3a083
update routing
davidnurdin Jun 2, 2022
3f70c83
update routing
davidnurdin Jun 2, 2022
3dbe339
add autowiring
davidnurdin Jun 2, 2022
6df6926
update routing
davidnurdin Jun 2, 2022
939ee1a
update routing
davidnurdin Jun 2, 2022
8b25abc
update routing
davidnurdin Jun 2, 2022
e2ec153
update routing
davidnurdin Jun 2, 2022
49d5495
update routing
davidnurdin Jun 2, 2022
a11fee3
update routing
davidnurdin Jun 3, 2022
3353fda
update routing
davidnurdin Jun 3, 2022
8bf1614
update routing
davidnurdin Jun 3, 2022
036db54
update routing
davidnurdin Jun 3, 2022
eecf487
update routing
davidnurdin Jun 3, 2022
c5d7815
update routing
davidnurdin Jun 3, 2022
a4426bf
update routing
davidnurdin Jun 3, 2022
1c56117
update routing
davidnurdin Jun 3, 2022
6b2d128
update routing
davidnurdin Jun 3, 2022
2423adb
update routing
davidnurdin Jun 3, 2022
197037e
update routing
davidnurdin Jun 3, 2022
dcdc1ec
update routing
davidnurdin Jun 3, 2022
b9ec5a4
update routing
davidnurdin Jun 3, 2022
d5ec978
update routing
davidnurdin Jun 3, 2022
f9a3de8
update routing
davidnurdin Jun 3, 2022
0aae999
update routing
davidnurdin Jun 3, 2022
f00050a
update routing
davidnurdin Jun 3, 2022
4992a67
update routing
davidnurdin Jun 3, 2022
806f3b7
update routing
davidnurdin Jun 3, 2022
3f940fd
update routing
davidnurdin Jun 3, 2022
f4c9f3c
update routing
davidnurdin Jun 3, 2022
126a677
update routing
davidnurdin Jun 3, 2022
1ba4957
update routing
davidnurdin Jun 3, 2022
90e3cc7
update routing
davidnurdin Jun 3, 2022
08d75c2
update routing
davidnurdin Jun 3, 2022
7c28bbd
update routing
davidnurdin Jun 3, 2022
61b6bed
update routing
davidnurdin Jun 3, 2022
b36f814
update routing
davidnurdin Jun 3, 2022
6cac26b
update routing
davidnurdin Jun 3, 2022
995463a
update routing
davidnurdin Jun 3, 2022
d30e6eb
update routing
davidnurdin Jun 3, 2022
feaaa94
update routing
davidnurdin Jun 3, 2022
1882de8
update services
davidnurdin Jun 3, 2022
5b6118f
update routing
davidnurdin Jun 3, 2022
eca4b32
update routing
davidnurdin Jun 3, 2022
4821d5f
update routing
davidnurdin Jun 3, 2022
832b27c
update composer
davidnurdin Jun 3, 2022
84d7ef0
update routing
davidnurdin Jun 3, 2022
d23f635
Missing file
davidnurdin Jun 3, 2022
8f70bf0
Missing file
davidnurdin Jun 3, 2022
27fcd82
Missing file
davidnurdin Jun 3, 2022
b086f2f
Missing file
davidnurdin Jun 3, 2022
ad5bfff
Missing file
davidnurdin Jun 3, 2022
e6cc359
Missing file
davidnurdin Jun 3, 2022
bc43654
Missing file
davidnurdin Jun 3, 2022
2986677
Missing file
davidnurdin Jun 3, 2022
720b74b
update length url (2000 max in rfc)
davidnurdin Jun 3, 2022
58643bd
fix url length index
davidnurdin Jun 3, 2022
66af8eb
fix url length index
davidnurdin Jun 3, 2022
b63e4be
fix url length index
davidnurdin Jun 3, 2022
87a90e9
fix url length index
davidnurdin Jun 7, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .gitignore

This file was deleted.

20 changes: 10 additions & 10 deletions Controller/EncodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,41 @@

namespace Leopardd\Bundle\UrlShortenerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Leopardd\Bundle\UrlShortenerBundle\Factory\ShortUrlFactory;
use Leopardd\Bundle\UrlShortenerBundle\Service\EncodeService;
use Leopardd\Bundle\UrlShortenerBundle\Exception\InvalidUrlException;

class EncodeController extends Controller
class EncodeController extends AbstractController
{

public function __construct(private ShortUrlFactory $shortUrlFactory,private EncodeService $encodeService)
{

}
/**
* @param Request $request
* @throws InvalidUrlException
* @return JsonResponse
*/
public function indexAction(Request $request)
{
/** @var ShortUrlFactory $shortUrlFactory */
$shortUrlFactory = $this->get('leopardd_url_shortener.factory.short_url');

/** @var EncodeService $encodeService */
$encodeService = $this->get('leopardd_url_shortener.service.encode');

$url = $request->request->get('url');

// validate and sanitize
if (filter_var($url, FILTER_VALIDATE_URL) === false) throw new InvalidUrlException();
$url = rtrim($url, '/');

$shortUrl = $shortUrlFactory->create($url);
$shortUrl = $encodeService->process($shortUrl);
$shortUrl = $this->shortUrlFactory->create($url);
$shortUrl = $this->encodeService->process($shortUrl);

return new JsonResponse([
'url' => $shortUrl->getUrl(),
'code' => $shortUrl->getCode()
]);
}
}
}
15 changes: 9 additions & 6 deletions Controller/RedirectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,29 @@

namespace Leopardd\Bundle\UrlShortenerBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Leopardd\Bundle\UrlShortenerBundle\Service\RedirectService;
use Leopardd\Bundle\UrlShortenerBundle\Exception\InvalidCodeException;

class RedirectController extends Controller
class RedirectController extends AbstractController
{

public function __construct(private RedirectService $redirectService)
{

}
/**
* @param string $code
* @throws InvalidCodeException
* @return RedirectResponse
*/
public function indexAction($code)
{
/** @var RedirectService $redirectService */
$redirectService = $this->get('leopardd_url_shortener.service.redirect');

$response = $redirectService->getRedirectResponse($code);
$response = $this->redirectService->getRedirectResponse($code);
if ($response === null) throw new InvalidCodeException();

return $response;
}
}
}
10 changes: 5 additions & 5 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('leopardd_url_shortener');

$builder = new TreeBuilder('leopardd_url_shortener');
$rootNode = $builder->getRootNode();
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
Expand All @@ -34,6 +33,7 @@ public function getConfigTreeBuilder()
->end()
->end();

return $treeBuilder;

return $builder;
}
}
}
46 changes: 23 additions & 23 deletions DependencyInjection/LeoparddUrlShortenerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,30 @@
*/
class LeoparddUrlShortenerExtension extends Extension
{
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
/**
* {@inheritdoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
$loader->load('services.yml');

// Hashids Config
if (isset($config['hashids'])) {
if (isset($config['hashids']['salt'])) {
$container->setParameter('leopardd_url_shortener.hashids.salt', $config['hashids']['salt']);
}
// Hashids Config
if (isset($config['hashids'])) {
if (isset($config['hashids']['salt'])) {
$container->setParameter('leopardd_url_shortener.hashids.salt', $config['hashids']['salt']);
}

if (isset($config['hashids']['min_length'])) {
$container->setParameter('leopardd_url_shortener.hashids.min_length', $config['hashids']['min_length']);
}
if (isset($config['hashids']['min_length'])) {
$container->setParameter('leopardd_url_shortener.hashids.min_length', $config['hashids']['min_length']);
}

if (isset($config['hashids']['alphabet'])) {
$container->setParameter('leopardd_url_shortener.hashids.alphabet', $config['hashids']['alphabet']);
}
}
}
}
if (isset($config['hashids']['alphabet'])) {
$container->setParameter('leopardd_url_shortener.hashids.alphabet', $config['hashids']['alphabet']);
}
}
}
}
Loading