deploy to prod
This commit is contained in:
parent
7600af4845
commit
f3247a941c
@ -1,6 +1,6 @@
|
|||||||
How to setup project:
|
How to setup project:
|
||||||
|
|
||||||
- Add database credentials in `.env.local`
|
- Add database credentials and discog key and secret in `.env.local`
|
||||||
- Check requirements: `symfony check:requirements`
|
- Check requirements: `symfony check:requirements`
|
||||||
- Install dependencies: `composer install`
|
- Install dependencies: `composer install`
|
||||||
- Create DB: `php bin/console doctrine:database:create`
|
- Create DB: `php bin/console doctrine:database:create`
|
||||||
|
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use App\Utils;
|
||||||
|
use App\Entity\Album;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use App\Entity\Album;
|
|
||||||
use App\Utils;
|
|
||||||
|
|
||||||
#[Route('/favorite')]
|
#[Route('/favorite')]
|
||||||
class FavoriteController extends AbstractController
|
class FavoriteController extends AbstractController
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
class IndexController extends AbstractController
|
class IndexController extends AbstractController
|
||||||
{
|
{
|
||||||
|
@ -2,25 +2,29 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Album;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
use App\Utils;
|
use App\Utils;
|
||||||
|
use App\Entity\Album;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
|
||||||
class SearchController extends AbstractController
|
class SearchController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
private static function addFruitToAlbums(array $releases, string $fruit, EntityManagerInterface $entityManager): void
|
private static function addFruitToAlbums(array $releases, string $fruit, EntityManagerInterface $entityManager): void
|
||||||
{
|
{
|
||||||
|
$albums = $entityManager->getRepository(Album::class)->findAll();
|
||||||
foreach ($releases as $release) {
|
foreach ($releases as $release) {
|
||||||
|
$album = null;
|
||||||
$id = $release["id"];
|
$id = $release["id"];
|
||||||
$album = $entityManager->getRepository(Album::class)->findBy(
|
foreach($albums as $remote_album){
|
||||||
['album_id' => $id]
|
if ($remote_album->getAlbumId() == $id)
|
||||||
);
|
$album == $remote_album;
|
||||||
if (count($album) == 0) {
|
break;
|
||||||
|
}
|
||||||
|
if ($album == null) {
|
||||||
$album = new Album();
|
$album = new Album();
|
||||||
$album->setAlbumId($id);
|
$album->setAlbumId($id);
|
||||||
//https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database
|
//https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database
|
||||||
@ -33,8 +37,8 @@ class SearchController extends AbstractController
|
|||||||
//https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database
|
//https://symfony.com/doc/current/doctrine.html#persisting-objects-to-the-database
|
||||||
}
|
}
|
||||||
$entityManager->persist($album);
|
$entityManager->persist($album);
|
||||||
$entityManager->flush();
|
|
||||||
}
|
}
|
||||||
|
$entityManager->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getEmojiName(string | null $emoji): string | null
|
private static function getEmojiName(string | null $emoji): string | null
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
|
||||||
|
|
||||||
class SecurityController extends AbstractController
|
|
||||||
{
|
|
||||||
#[Route(path: '/login', name: 'app_login')]
|
|
||||||
public function login(AuthenticationUtils $authenticationUtils): Response
|
|
||||||
{
|
|
||||||
// get the login error if there is one
|
|
||||||
$error = $authenticationUtils->getLastAuthenticationError();
|
|
||||||
|
|
||||||
// last username entered by the user
|
|
||||||
$lastUsername = $authenticationUtils->getLastUsername();
|
|
||||||
|
|
||||||
return $this->render('security/login.html.twig', [
|
|
||||||
'last_username' => $lastUsername,
|
|
||||||
'error' => $error,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/logout', name: 'app_logout')]
|
|
||||||
public function logout(): void
|
|
||||||
{
|
|
||||||
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
|
|
||||||
class TestController extends AbstractController
|
|
||||||
{
|
|
||||||
|
|
||||||
#[Route('/test', name: 'app_test')]
|
|
||||||
public function index(): Response
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,18 +3,21 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Form\RegistrationFormType;
|
|
||||||
use App\Security\Authenticator;
|
use App\Security\Authenticator;
|
||||||
|
use App\Form\RegistrationFormType;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
|
||||||
|
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
|
||||||
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
|
use Symfony\Component\Security\Http\Authentication\UserAuthenticatorInterface;
|
||||||
|
|
||||||
class RegistrationController extends AbstractController
|
|
||||||
|
class UserController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
#[Route('/register', name: 'app_register')]
|
#[Route('/register', name: 'app_register')]
|
||||||
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, UserAuthenticatorInterface $userAuthenticator, Authenticator $authenticator, EntityManagerInterface $entityManager): Response
|
public function register(Request $request, UserPasswordHasherInterface $userPasswordHasher, UserAuthenticatorInterface $userAuthenticator, Authenticator $authenticator, EntityManagerInterface $entityManager): Response
|
||||||
{
|
{
|
||||||
@ -46,4 +49,26 @@ class RegistrationController extends AbstractController
|
|||||||
'registrationForm' => $form->createView(),
|
'registrationForm' => $form->createView(),
|
||||||
], new Response(null, 422));
|
], new Response(null, 422));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[Route(path: '/login', name: 'app_login')]
|
||||||
|
public function login(AuthenticationUtils $authenticationUtils): Response
|
||||||
|
{
|
||||||
|
// get the login error if there is one
|
||||||
|
$error = $authenticationUtils->getLastAuthenticationError();
|
||||||
|
|
||||||
|
// last username entered by the user
|
||||||
|
$lastUsername = $authenticationUtils->getLastUsername();
|
||||||
|
|
||||||
|
return $this->render('security/login.html.twig', [
|
||||||
|
'last_username' => $lastUsername,
|
||||||
|
'error' => $error,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route(path: '/logout', name: 'app_logout')]
|
||||||
|
public function logout(): void
|
||||||
|
{
|
||||||
|
throw new \LogicException('This method can be blank - it will be intercepted by the logout key on your firewall.');
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\ApiDiscogRepository;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: ApiDiscogRepository::class)]
|
|
||||||
class ApiDiscog
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repository;
|
|
||||||
|
|
||||||
use App\Entity\ApiDiscog;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends ServiceEntityRepository<ApiDiscog>
|
|
||||||
*
|
|
||||||
* @method ApiDiscog|null find($id, $lockMode = null, $lockVersion = null)
|
|
||||||
* @method ApiDiscog|null findOneBy(array $criteria, array $orderBy = null)
|
|
||||||
* @method ApiDiscog[] findAll()
|
|
||||||
* @method ApiDiscog[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
|
||||||
*/
|
|
||||||
class ApiDiscogRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, ApiDiscog::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return ApiDiscog[] Returns an array of ApiDiscog objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('a')
|
|
||||||
// ->andWhere('a.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->orderBy('a.id', 'ASC')
|
|
||||||
// ->setMaxResults(10)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?ApiDiscog
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('a')
|
|
||||||
// ->andWhere('a.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getOneOrNullResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user