From f54f663fb069cc8d9f606b6146675021277c3bdd Mon Sep 17 00:00:00 2001 From: thisfro Date: Wed, 19 Jan 2022 19:59:35 +0100 Subject: [PATCH] Rename offering to offer --- assets/app.js | 2 +- migrations/Version20220119172053.php | 31 +++++++++++++++++++ src/Controller/Admin/DashboardController.php | 4 +-- ...Controller.php => OfferCrudController.php} | 6 ++-- src/Controller/OfferController.php | 24 +++++++------- src/Controller/TradeController.php | 6 ++-- src/Controller/UserController.php | 12 +++---- src/Entity/{Offering.php => Offer.php} | 8 ++--- src/Entity/User.php | 28 ++++++++--------- ...OfferingFormType.php => OfferFormType.php} | 6 ++-- ...ringRepository.php => OfferRepository.php} | 18 +++++------ src/Service/OfferPhotoHelper.php | 4 +-- 12 files changed, 90 insertions(+), 59 deletions(-) create mode 100644 migrations/Version20220119172053.php rename src/Controller/Admin/{OfferingCrudController.php => OfferCrudController.php} (88%) rename src/Entity/{Offering.php => Offer.php} (96%) rename src/Form/{OfferingFormType.php => OfferFormType.php} (92%) rename src/Repository/{OfferingRepository.php => OfferRepository.php} (65%) diff --git a/assets/app.js b/assets/app.js index a680695..7c5a082 100644 --- a/assets/app.js +++ b/assets/app.js @@ -35,7 +35,7 @@ widget.start() // Dsiplay Filename when uploading document.querySelector('.custom-file-input').addEventListener('change', function (e) { - var fileName = document.getElementById('offering_form_photo').files[0].name; + var fileName = document.getElementById('offer_form_photo').files[0].name; var nextSibling = e.target.nextElementSibling nextSibling.innerText = fileName }) diff --git a/migrations/Version20220119172053.php b/migrations/Version20220119172053.php new file mode 100644 index 0000000..6ba4735 --- /dev/null +++ b/migrations/Version20220119172053.php @@ -0,0 +1,31 @@ +addSql('RENAME TABLE offering TO offer'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('RENAME TABLE offer TO offering'); + } +} diff --git a/src/Controller/Admin/DashboardController.php b/src/Controller/Admin/DashboardController.php index 9e5ad4c..bc0c442 100644 --- a/src/Controller/Admin/DashboardController.php +++ b/src/Controller/Admin/DashboardController.php @@ -3,7 +3,7 @@ namespace App\Controller\Admin; use App\Entity\User; -use App\Entity\Offering; +use App\Entity\Offer; use App\Entity\Wish; use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard; use EasyCorp\Bundle\EasyAdminBundle\Config\MenuItem; @@ -36,7 +36,7 @@ class DashboardController extends AbstractDashboardController yield MenuItem::linktoRoute('Back to the website', 'fas fa-arrow-left', 'offers'); yield MenuItem::linktoDashboard('Dashboard', 'fa fa-home'); yield MenuItem::linkToCrud('User', 'fas fa-user', User::class); - yield MenuItem::linkToCrud('Offering', 'fas fa-seedling', Offering::class); + yield MenuItem::linkToCrud('Offer', 'fas fa-seedling', Offer::class); yield MenuItem::linkToCrud('Wish', 'fas fa-star', Wish::class); } } diff --git a/src/Controller/Admin/OfferingCrudController.php b/src/Controller/Admin/OfferCrudController.php similarity index 88% rename from src/Controller/Admin/OfferingCrudController.php rename to src/Controller/Admin/OfferCrudController.php index 38c8cc7..b52b012 100644 --- a/src/Controller/Admin/OfferingCrudController.php +++ b/src/Controller/Admin/OfferCrudController.php @@ -2,7 +2,7 @@ namespace App\Controller\Admin; -use App\Entity\Offering; +use App\Entity\Offer; use App\Entity\User; use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController; @@ -13,11 +13,11 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; -class OfferingCrudController extends AbstractCrudController +class OfferCrudController extends AbstractCrudController { public static function getEntityFqcn(): string { - return Offering::class; + return Offer::class; } public function configureFields(string $pageName): iterable diff --git a/src/Controller/OfferController.php b/src/Controller/OfferController.php index e7aab0a..5468814 100644 --- a/src/Controller/OfferController.php +++ b/src/Controller/OfferController.php @@ -2,11 +2,11 @@ namespace App\Controller; -use App\Entity\Offering; -use App\Form\OfferingFormType; +use App\Entity\Offer; +use App\Form\OfferFormType; use App\Form\OfferFilterFormType; -use App\Repository\OfferingRepository; +use App\Repository\OfferRepository; use App\Repository\WishRepository; use App\Service\PlzToCoordinate; @@ -33,7 +33,7 @@ class OfferController extends AbstractController } #[Route('/offers', name: 'offers', options: ["sitemap" => true])] - public function showAll(Environment $twig, Request $request, OfferingRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response + public function showAll(Environment $twig, Request $request, OfferRepository $offerRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response { $form = $this->createForm(OfferFilterFormType::class); $form->handleRequest($request); @@ -74,8 +74,8 @@ class OfferController extends AbstractController #[Route('/new', name: 'new_offer')] public function newOffer(Request $request, PlzToCoordinate $plzconverter, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response { - $offer = new Offering(); - $form = $this->createForm(OfferingFormType::class, $offer); + $offer = new Offer(); + $form = $this->createForm(OfferFormType::class, $offer); $user = $this->getUser(); $form->handleRequest($request); @@ -110,7 +110,7 @@ class OfferController extends AbstractController } #[Route('/offer/{urlId}', name: 'show_offer')] - public function showOffer(Offering $offer, WishRepository $wishRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response + public function showOffer(Offer $offer, WishRepository $wishRepository, PlzToCoordinate $plzconverter, DistanceCalculator $distanceCalculator): Response { $distance = null; $user = $this->getUser(); @@ -144,9 +144,9 @@ class OfferController extends AbstractController } #[Route('/offer/edit/{urlId}', name: 'edit_offer')] - public function editOffer(Offering $offer, OfferingRepository $offerRepository, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response + public function editOffer(Offer $offer, OfferRepository $offerRepository, Request $request, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response { - $form = $this->createForm(OfferingFormType::class, $offer); + $form = $this->createForm(OfferFormType::class, $offer); $user = $this->getUser(); if ($offer->getByUser() === $user) { @@ -177,7 +177,7 @@ class OfferController extends AbstractController } #[Route('/offer/delete/{urlId}', name: 'delete_offer')] - public function deleteOffer(Offering $offer, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response + public function deleteOffer(Offer $offer, string $photoDir, OfferPhotoHelper $offerPhotoHelper): Response { $user = $this->getUser(); @@ -200,13 +200,13 @@ class OfferController extends AbstractController } #[Route('/myoffers', name: 'own_offers')] - public function ownOffers(OfferingRepository $offeringRepository): Response + public function ownOffers(OfferRepository $offerRepository): Response { $user = $this->getUser(); return $this->render('user/offers.html.twig', [ 'user' => $user, - 'offers' => $offeringRepository->findByUser($user), + 'offers' => $offerRepository->findByUser($user), ]); } } diff --git a/src/Controller/TradeController.php b/src/Controller/TradeController.php index 31f798f..848511e 100644 --- a/src/Controller/TradeController.php +++ b/src/Controller/TradeController.php @@ -3,9 +3,9 @@ namespace App\Controller; use App\Entity\User; -use App\Entity\Offering; +use App\Entity\Offer; -use App\Repository\OfferingRepository; +use App\Repository\OfferRepository; use App\Repository\WishRepository; use Symfony\Bridge\Twig\Mime\TemplatedEmail; @@ -20,7 +20,7 @@ use Symfony\Component\Routing\Annotation\Route; class TradeController extends AbstractController { #[Route('/trade/{urlId}', name: 'trade')] - public function sendEmail(MailerInterface $mailer, Offering $offer, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response + public function sendEmail(MailerInterface $mailer, Offer $offer, OfferRepository $offerRepository, WishRepository $wishRepository): Response { $user = $this->getUser(); diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index f5e1fc2..688e480 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -7,7 +7,7 @@ use App\Entity\User; use App\Form\WishFormType; use App\Form\ChangePasswordFormType; -use App\Repository\OfferingRepository; +use App\Repository\OfferRepository; use App\Repository\WishRepository; use Doctrine\ORM\EntityManagerInterface; @@ -30,7 +30,7 @@ class UserController extends AbstractController } #[Route('/user', name: 'user_page')] - public function user(OfferingRepository $offeringRepository, Request $request, UserPasswordHasherInterface $passwordEncoder): Response + public function user(OfferRepository $offerRepository, Request $request, UserPasswordHasherInterface $passwordEncoder): Response { $user = $this->getUser(); @@ -64,23 +64,23 @@ class UserController extends AbstractController } #[Route('/user/offers', name: 'user_offers')] - public function userOffers(OfferingRepository $offeringRepository): Response + public function userOffers(OfferRepository $offerRepository): Response { $user = $this->getUser(); return $this->render('user/public.html.twig', [ 'user' => $user, - 'offers' => $offeringRepository->findByUser($user), + 'offers' => $offerRepository->findByUser($user), ]); } #[Route('/user/{urlId}', name: 'user_public')] - public function show_user(User $user, OfferingRepository $offeringRepository, WishRepository $wishRepository): Response + public function show_user(User $user, OfferRepository $offerRepository, WishRepository $wishRepository): Response { return $this->render('user/public.html.twig', [ 'username' => $user->getUsername(), 'wishes' => $wishRepository->findByUser($user), - 'offers' => $offeringRepository->findByUser($user), + 'offers' => $offerRepository->findByUser($user), ]); } diff --git a/src/Entity/Offering.php b/src/Entity/Offer.php similarity index 96% rename from src/Entity/Offering.php rename to src/Entity/Offer.php index eca0e07..bf72d26 100644 --- a/src/Entity/Offering.php +++ b/src/Entity/Offer.php @@ -2,15 +2,15 @@ namespace App\Entity; -use App\Repository\OfferingRepository; +use App\Repository\OfferRepository; use Doctrine\ORM\Mapping as ORM; use Location\Coordinate; use Symfony\Component\Validator\Constraints as Assert; /** - * @ORM\Entity(repositoryClass=OfferingRepository::class) + * @ORM\Entity(repositoryClass=OfferRepository::class) */ -class Offering +class Offer { /** * @ORM\Id @@ -20,7 +20,7 @@ class Offering private $id; /** - * @ORM\ManyToOne(targetEntity=User::class, inversedBy="offerings") + * @ORM\ManyToOne(targetEntity=User::class, inversedBy="offers") * @ORM\JoinColumn(nullable=false) */ private $byUser; diff --git a/src/Entity/User.php b/src/Entity/User.php index 6ced665..0371322 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -51,9 +51,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private $username; /** - * @ORM\OneToMany(targetEntity=Offering::class, mappedBy="byUser", orphanRemoval=true) + * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="byUser", orphanRemoval=true) */ - private $offerings; + private $offers; /** * @ORM\OneToMany(targetEntity=Wish::class, mappedBy="byUser") @@ -72,7 +72,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface public function __construct() { - $this->offerings = new ArrayCollection(); + $this->offers = new ArrayCollection(); $this->wishes = new ArrayCollection(); } @@ -185,29 +185,29 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface } /** - * @return Collection|Offering[] + * @return Collection|Offer[] */ - public function getOfferings(): Collection + public function getOffers(): Collection { - return $this->offerings; + return $this->offers; } - public function addOffering(Offering $offering): self + public function addOffer(Offer $offer): self { - if (!$this->offerings->contains($offering)) { - $this->offerings[] = $offering; - $offering->setByUser($this); + if (!$this->offers->contains($offer)) { + $this->offers[] = $offer; + $offer->setByUser($this); } return $this; } - public function removeOffering(Offering $offering): self + public function removeOffer(Offer $offer): self { - if ($this->offerings->removeElement($offering)) { + if ($this->offers->removeElement($offer)) { // set the owning side to null (unless already changed) - if ($offering->getByUser() === $this) { - $offering->setByUser(null); + if ($offer->getByUser() === $this) { + $offer->setByUser(null); } } diff --git a/src/Form/OfferingFormType.php b/src/Form/OfferFormType.php similarity index 92% rename from src/Form/OfferingFormType.php rename to src/Form/OfferFormType.php index c262b4f..5d322e0 100644 --- a/src/Form/OfferingFormType.php +++ b/src/Form/OfferFormType.php @@ -2,7 +2,7 @@ namespace App\Form; -use App\Entity\Offering; +use App\Entity\Offer; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\FileType; use Symfony\Component\Form\Extension\Core\Type\TextType; @@ -12,7 +12,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\Image; use Symfony\Component\Validator\Constraints\NotBlank; -class OfferingFormType extends AbstractType +class OfferFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { @@ -43,7 +43,7 @@ class OfferingFormType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'data_class' => Offering::class, + 'data_class' => Offer::class, ]); } } diff --git a/src/Repository/OfferingRepository.php b/src/Repository/OfferRepository.php similarity index 65% rename from src/Repository/OfferingRepository.php rename to src/Repository/OfferRepository.php index cf5c531..b2dbdf7 100644 --- a/src/Repository/OfferingRepository.php +++ b/src/Repository/OfferRepository.php @@ -2,25 +2,25 @@ namespace App\Repository; -use App\Entity\Offering; +use App\Entity\Offer; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Persistence\ManagerRegistry; /** - * @method Offering|null find($id, $lockMode = null, $lockVersion = null) - * @method Offering|null findOneBy(array $criteria, array $orderBy = null) - * @method Offering[] findAll() - * @method Offering[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) + * @method Offer|null find($id, $lockMode = null, $lockVersion = null) + * @method Offer|null findOneBy(array $criteria, array $orderBy = null) + * @method Offer[] findAll() + * @method Offer[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) */ -class OfferingRepository extends ServiceEntityRepository +class OfferRepository extends ServiceEntityRepository { public function __construct(ManagerRegistry $registry) { - parent::__construct($registry, Offering::class); + parent::__construct($registry, Offer::class); } // /** - // * @return Offering[] Returns an array of Offering objects + // * @return Offer[] Returns an array of Offer objects // */ public function findByUser($user) { @@ -45,7 +45,7 @@ class OfferingRepository extends ServiceEntityRepository } /* - public function findOneBySomeField($value): ?Offering + public function findOneBySomeField($value): ?Offer { return $this->createQueryBuilder('o') ->andWhere('o.exampleField = :val') diff --git a/src/Service/OfferPhotoHelper.php b/src/Service/OfferPhotoHelper.php index 9646288..06c52e0 100644 --- a/src/Service/OfferPhotoHelper.php +++ b/src/Service/OfferPhotoHelper.php @@ -2,7 +2,7 @@ namespace App\Service; -use App\Entity\Offering; +use App\Entity\Offer; use Psr\Log\LoggerInterface; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; @@ -18,7 +18,7 @@ class OfferPhotoHelper $this->filesystem = new Filesystem(); } - public function uploadOfferPhoto(string $photoDir, UploadedFile $photo, Offering $offer) + public function uploadOfferPhoto(string $photoDir, UploadedFile $photo, Offer $offer) { $filename = uniqid().'.'.$photo->guessExtension(); try {