diff --git a/src/Controller/CategoryController.php b/src/Controller/CategoryController.php deleted file mode 100644 index 735542b7..00000000 --- a/src/Controller/CategoryController.php +++ /dev/null @@ -1,81 +0,0 @@ -render('category/index.html.twig', [ - 'categories' => $categoryRepository->findAll(), - ]); - } - - #[Route('/new', name: 'app_category_new', methods: ['GET', 'POST'])] - public function new(Request $request, EntityManagerInterface $entityManager): Response - { - $category = new Category(); - $form = $this->createForm(CategoryType::class, $category); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $entityManager->persist($category); - $entityManager->flush(); - - return $this->redirectToRoute('app_category_index', [], Response::HTTP_SEE_OTHER); - } - - return $this->render('category/new.html.twig', [ - 'category' => $category, - 'form' => $form, - ]); - } - - #[Route('/{id}', name: 'app_category_show', methods: ['GET'])] - public function show(Category $category): Response - { - return $this->render('category/show.html.twig', [ - 'category' => $category, - ]); - } - - #[Route('/{id}/edit', name: 'app_category_edit', methods: ['GET', 'POST'])] - public function edit(Request $request, Category $category, EntityManagerInterface $entityManager): Response - { - $form = $this->createForm(CategoryType::class, $category); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $entityManager->flush(); - - return $this->redirectToRoute('app_category_index', [], Response::HTTP_SEE_OTHER); - } - - return $this->render('category/edit.html.twig', [ - 'category' => $category, - 'form' => $form, - ]); - } - - #[Route('/{id}', name: 'app_category_delete', methods: ['POST'])] - public function delete(Request $request, Category $category, EntityManagerInterface $entityManager): Response - { - if ($this->isCsrfTokenValid('delete'.$category->getId(), $request->getPayload()->getString('_token'))) { - $entityManager->remove($category); - $entityManager->flush(); - } - - return $this->redirectToRoute('app_category_index', [], Response::HTTP_SEE_OTHER); - } -} diff --git a/src/Entity/Category.php b/src/Entity/Category.php deleted file mode 100644 index 1aa31a13..00000000 --- a/src/Entity/Category.php +++ /dev/null @@ -1,50 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getUser(): ?User - { - return $this->user; - } - - public function setUser(?User $user): static - { - $this->user = $user; - - return $this; - } -} diff --git a/src/Entity/Expense.php b/src/Entity/Expense.php index 560a89f2..44fee725 100644 --- a/src/Entity/Expense.php +++ b/src/Entity/Expense.php @@ -4,7 +4,9 @@ namespace App\Entity; use App\Repository\ExpenseRepository; use Doctrine\ORM\Mapping as ORM; +use ApiPlatform\Metadata\ApiResource; +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: ExpenseRepository::class)] class Expense { diff --git a/src/Entity/Festvial.php b/src/Entity/Festvial.php deleted file mode 100644 index 7c3b0b11..00000000 --- a/src/Entity/Festvial.php +++ /dev/null @@ -1,96 +0,0 @@ -id; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(string $name): static - { - $this->name = $name; - - return $this; - } - - public function getDateCreation(): ?\DateTimeInterface - { - return $this->dateCreation; - } - - public function setDateCreation(?\DateTimeInterface $dateCreation): static - { - $this->dateCreation = $dateCreation; - - return $this; - } - - public function getChiffreAffaire(): ?float - { - return $this->chiffreAffaire; - } - - public function setChiffreAffaire(?float $chiffreAffaire): static - { - $this->chiffreAffaire = $chiffreAffaire; - - return $this; - } - - public function getClientsCount(): ?int - { - return $this->clientsCount; - } - - public function setClientsCount(?int $clientsCount): static - { - $this->clientsCount = $clientsCount; - - return $this; - } - - public function getCommentaire(): ?string - { - return $this->commentaire; - } - - public function setCommentaire(?string $commentaire): static - { - $this->commentaire = $commentaire; - - return $this; - } -} diff --git a/src/Entity/GroupOfProducts.php b/src/Entity/GroupOfProducts.php index 0ba278a7..ac103d35 100644 --- a/src/Entity/GroupOfProducts.php +++ b/src/Entity/GroupOfProducts.php @@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use ApiPlatform\Metadata\ApiResource; +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: GroupOfProductsRepository::class)] class GroupOfProducts { diff --git a/src/Entity/Product.php b/src/Entity/Product.php index 651a072d..adbf6e37 100644 --- a/src/Entity/Product.php +++ b/src/Entity/Product.php @@ -2,11 +2,13 @@ namespace App\Entity; +use ApiPlatform\Metadata\ApiResource; + use App\Repository\ProductRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; - +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: ProductRepository::class)] class Product { diff --git a/src/Entity/Selling.php b/src/Entity/Selling.php index 3b7f5bbc..54c1b744 100644 --- a/src/Entity/Selling.php +++ b/src/Entity/Selling.php @@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use ApiPlatform\Metadata\ApiResource; +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: SellingRepository::class)] class Selling { diff --git a/src/Entity/SerieFestival.php b/src/Entity/SerieFestival.php index 00de936b..ff3efa3f 100644 --- a/src/Entity/SerieFestival.php +++ b/src/Entity/SerieFestival.php @@ -7,7 +7,9 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; +use ApiPlatform\Metadata\ApiResource; +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: SerieFestivalRepository::class)] class SerieFestival { diff --git a/src/Entity/User.php b/src/Entity/User.php index d60c20fc..f68030fe 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -10,7 +10,9 @@ use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface; use Symfony\Component\Security\Core\User\UserInterface; +use ApiPlatform\Metadata\ApiResource; +#[ApiResource(paginationEnabled: false)] #[ORM\Entity(repositoryClass: UserRepository::class)] #[ORM\UniqueConstraint(name: 'UNIQ_IDENTIFIER_EMAIL', fields: ['email'])] #[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')] @@ -75,12 +77,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\OneToMany(targetEntity: Festival::class, mappedBy: 'user')] private Collection $festivals; - /** - * @var Collection - */ - #[ORM\OneToMany(targetEntity: Category::class, mappedBy: 'user')] - private Collection $categories; - /** * @var Collection */ @@ -94,7 +90,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->products = new ArrayCollection(); $this->groupOfProducts = new ArrayCollection(); $this->festivals = new ArrayCollection(); - $this->categories = new ArrayCollection(); $this->seriesFestival = new ArrayCollection(); } @@ -173,18 +168,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface // $this->plainPassword = null; } - public function getOwner(): ?object - { - return $this->owner; - } - - public function setOwner(object $owner): static - { - $this->owner = $owner; - - return $this; - } - public function getExpenses(): ?object { return $this->expenses; @@ -333,35 +316,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface return $this; } - /** - * @return Collection - */ - public function getCategories(): Collection - { - return $this->categories; - } - - public function addCategory(Category $category): static - { - if (!$this->categories->contains($category)) { - $this->categories->add($category); - $category->setUser($this); - } - - return $this; - } - - public function removeCategory(Category $category): static - { - if ($this->categories->removeElement($category)) { - // set the owning side to null (unless already changed) - if ($category->getUser() === $this) { - $category->setUser(null); - } - } - - return $this; - } /** * @return Collection diff --git a/templates/category/_delete_form.html.twig b/templates/category/_delete_form.html.twig deleted file mode 100644 index 535a698e..00000000 --- a/templates/category/_delete_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -
- - -
diff --git a/templates/category/_form.html.twig b/templates/category/_form.html.twig deleted file mode 100644 index bf20b98f..00000000 --- a/templates/category/_form.html.twig +++ /dev/null @@ -1,4 +0,0 @@ -{{ form_start(form) }} - {{ form_widget(form) }} - -{{ form_end(form) }} diff --git a/templates/category/edit.html.twig b/templates/category/edit.html.twig deleted file mode 100644 index 2be34898..00000000 --- a/templates/category/edit.html.twig +++ /dev/null @@ -1,13 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Edit Category{% endblock %} - -{% block body %} -

Edit Category

- - {{ include('category/_form.html.twig', {'button_label': 'Update'}) }} - - back to list - - {{ include('category/_delete_form.html.twig') }} -{% endblock %} diff --git a/templates/category/index.html.twig b/templates/category/index.html.twig deleted file mode 100644 index d361559e..00000000 --- a/templates/category/index.html.twig +++ /dev/null @@ -1,35 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Category index{% endblock %} - -{% block body %} -

Category index

- - - - - - - - - - - {% for category in categories %} - - - - - - {% else %} - - - - {% endfor %} - -
IdNameactions
{{ category.id }}{{ category.name }} - show - edit -
no records found
- - Create new -{% endblock %} diff --git a/templates/category/new.html.twig b/templates/category/new.html.twig deleted file mode 100644 index bab5f3c9..00000000 --- a/templates/category/new.html.twig +++ /dev/null @@ -1,11 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}New Category{% endblock %} - -{% block body %} -

Create new Category

- - {{ include('category/_form.html.twig') }} - - back to list -{% endblock %} diff --git a/templates/category/show.html.twig b/templates/category/show.html.twig deleted file mode 100644 index d86f086b..00000000 --- a/templates/category/show.html.twig +++ /dev/null @@ -1,26 +0,0 @@ -{% extends 'base.html.twig' %} - -{% block title %}Category{% endblock %} - -{% block body %} -

Category

- - - - - - - - - - - - -
Id{{ category.id }}
Name{{ category.name }}
- - back to list - - edit - - {{ include('category/_delete_form.html.twig') }} -{% endblock %}