feat: using QRCode form
feat: using QRCode form QROptionsDefaultProvider
This commit is contained in:
		
							parent
							
								
									cb24d39930
								
							
						
					
					
						commit
						08a7d28065
					
				@ -2,16 +2,37 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
namespace App\Controller;
 | 
					namespace App\Controller;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					use App\Entity\QRCode\QRCode;
 | 
				
			||||||
 | 
					use App\Form\Type\QRCodeType;
 | 
				
			||||||
 | 
					use App\Service\QRCodeQROptionsProviderInterface;
 | 
				
			||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
					use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
 | 
				
			||||||
 | 
					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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class IndexController extends AbstractController {
 | 
					class IndexController extends AbstractController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    #[Route('/', name: 'homepage')]
 | 
					    #[Route('/', name: 'homepage')]
 | 
				
			||||||
    public function indexAction(): Response
 | 
					    public function indexAction(Request $request, QRCodeQROptionsProviderInterface $qrCodeQROptionsFactory): Response
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $result = $this->render('index/homepage.html.twig');
 | 
					        $qrCode = new QRCode(
 | 
				
			||||||
        return $result;
 | 
					            codeQROptions: $qrCodeQROptionsFactory->getDefault()
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $form = $this->createForm(QRCodeType::class, $qrCode);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($request->isMethod('POST')) {
 | 
				
			||||||
 | 
					            $form->submit($request->request->all($form->getName()));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($form->isSubmitted() && $form->isValid()) {
 | 
				
			||||||
 | 
					                // TODO: call service to generate
 | 
				
			||||||
 | 
					                print_r($qrCode);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return $this->render('index/homepage.html.twig', [
 | 
				
			||||||
 | 
					            'form' => $form
 | 
				
			||||||
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -5,8 +5,8 @@ namespace App\Service;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
use App\Entity\QRCode\QRCodeQROptions;
 | 
					use App\Entity\QRCode\QRCodeQROptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
readonly class QRCodeQROptionsDefaultProvider implements QRCodeQROptionsProviderInterface {
 | 
					readonly final class QRCodeQROptionsDefaultProvider implements QRCodeQROptionsProviderInterface {
 | 
				
			||||||
    private readonly QRCodeQROptions $qrCodeDefaultOptions;
 | 
					    private QRCodeQROptions $qrCodeDefaultOptions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct() {
 | 
					    public function __construct() {
 | 
				
			||||||
        $this->qrCodeDefaultOptions = new QRCodeQROptions(
 | 
					        $this->qrCodeDefaultOptions = new QRCodeQROptions(
 | 
				
			||||||
 | 
				
			|||||||
@ -2,4 +2,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% block body %}
 | 
					{% block body %}
 | 
				
			||||||
Homepage
 | 
					Homepage
 | 
				
			||||||
{% endblock %}
 | 
					{{ form(form) }}
 | 
				
			||||||
 | 
					{% endblock %}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user