some progress
This commit is contained in:
parent
f43208578d
commit
4f6fedf477
47
hesabixCore/src/Controller/AvatarController.php
Normal file
47
hesabixCore/src/Controller/AvatarController.php
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Service\Access;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
|
class AvatarController extends AbstractController
|
||||||
|
{
|
||||||
|
#[Route('/api/avatar/get', name: 'api_avatar_get')]
|
||||||
|
public function api_avatar_get(Access $access): Response
|
||||||
|
{
|
||||||
|
$acc = $access->hasRole('owner');
|
||||||
|
if (!$acc) throw $this->createAccessDeniedException();
|
||||||
|
if ($acc['bid']->getAvatar()) {
|
||||||
|
return new Response($acc['bid']->getAvatar());
|
||||||
|
}
|
||||||
|
return new Response('default.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/avatar/get/file/{id}', name: 'api_avatar_get_file')]
|
||||||
|
public function api_avatar_get_file(string $id): BinaryFileResponse
|
||||||
|
{
|
||||||
|
$fileAdr = __DIR__ . '/../../../hesabixArchive/avatars/' . $id;
|
||||||
|
if(!file_exists($fileAdr))
|
||||||
|
throw $this->createNotFoundException();
|
||||||
|
$response = new BinaryFileResponse($fileAdr);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/api/avatar/post', name: 'api_avatar_post')]
|
||||||
|
public function api_avatar_post(Access $access,EntityManagerInterface $entityManagerInterface): Response
|
||||||
|
{
|
||||||
|
$acc = $access->hasRole('owner');
|
||||||
|
if (!$acc) throw $this->createAccessDeniedException();
|
||||||
|
var_dump($params);
|
||||||
|
if ($acc['bid']->getAvatar()) {
|
||||||
|
return new Response($acc['bid']->getAvatar());
|
||||||
|
}
|
||||||
|
return new Response('default.png');
|
||||||
|
}
|
||||||
|
}
|
|
@ -222,6 +222,9 @@ class Business
|
||||||
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: PrintTemplate::class, orphanRemoval: true)]
|
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: PrintTemplate::class, orphanRemoval: true)]
|
||||||
private Collection $printTemplates;
|
private Collection $printTemplates;
|
||||||
|
|
||||||
|
#[ORM\Column(length: 255, nullable: true)]
|
||||||
|
private ?string $avatar = null;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->logs = new ArrayCollection();
|
$this->logs = new ArrayCollection();
|
||||||
|
@ -1573,4 +1576,16 @@ class Business
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getAvatar(): ?string
|
||||||
|
{
|
||||||
|
return $this->avatar;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setAvatar(?string $avatar): static
|
||||||
|
{
|
||||||
|
$this->avatar = $avatar;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
20
hesabixCore/templates/avatar/index.html.twig
Normal file
20
hesabixCore/templates/avatar/index.html.twig
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
|
{% block title %}Hello AvatarController!{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
<style>
|
||||||
|
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||||
|
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="example-wrapper">
|
||||||
|
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||||
|
|
||||||
|
This friendly message is coming from:
|
||||||
|
<ul>
|
||||||
|
<li>Your controller at <code><a href="{{ 'C:/xampp/htdocs/hesabixCore/src/Controller/AvatarController.php'|file_link(0) }}">src/Controller/AvatarController.php</a></code></li>
|
||||||
|
<li>Your template at <code><a href="{{ 'C:/xampp/htdocs/hesabixCore/templates/avatar/index.html.twig'|file_link(0) }}">templates/avatar/index.html.twig</a></code></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue