From 4f6fedf477f909f91f9a0f1400e9b3f25a221776 Mon Sep 17 00:00:00 2001 From: babak alizadeh Date: Mon, 1 Jul 2024 20:23:57 +0330 Subject: [PATCH] some progress --- .../src/Controller/AvatarController.php | 47 +++++++++++++++++++ hesabixCore/src/Entity/Business.php | 15 ++++++ hesabixCore/templates/avatar/index.html.twig | 20 ++++++++ 3 files changed, 82 insertions(+) create mode 100644 hesabixCore/src/Controller/AvatarController.php create mode 100644 hesabixCore/templates/avatar/index.html.twig diff --git a/hesabixCore/src/Controller/AvatarController.php b/hesabixCore/src/Controller/AvatarController.php new file mode 100644 index 0000000..14b326f --- /dev/null +++ b/hesabixCore/src/Controller/AvatarController.php @@ -0,0 +1,47 @@ +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'); + } +} diff --git a/hesabixCore/src/Entity/Business.php b/hesabixCore/src/Entity/Business.php index 5fc47b7..cd93da9 100644 --- a/hesabixCore/src/Entity/Business.php +++ b/hesabixCore/src/Entity/Business.php @@ -222,6 +222,9 @@ class Business #[ORM\OneToMany(mappedBy: 'bid', targetEntity: PrintTemplate::class, orphanRemoval: true)] private Collection $printTemplates; + #[ORM\Column(length: 255, nullable: true)] + private ?string $avatar = null; + public function __construct() { $this->logs = new ArrayCollection(); @@ -1573,4 +1576,16 @@ class Business return $this; } + + public function getAvatar(): ?string + { + return $this->avatar; + } + + public function setAvatar(?string $avatar): static + { + $this->avatar = $avatar; + + return $this; + } } diff --git a/hesabixCore/templates/avatar/index.html.twig b/hesabixCore/templates/avatar/index.html.twig new file mode 100644 index 0000000..9a3a6f9 --- /dev/null +++ b/hesabixCore/templates/avatar/index.html.twig @@ -0,0 +1,20 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello AvatarController!{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+ + This friendly message is coming from: + +
+{% endblock %}