add hooks to hesabix core

This commit is contained in:
Hesabix 2024-01-11 11:38:26 +00:00
parent 61b0a6fc79
commit a2df340d79
5 changed files with 207 additions and 0 deletions

View file

@ -543,4 +543,12 @@ class BusinessController extends AbstractController
];
return $this->json($response);
}
#[Route('v2/api/settings/chack-api', name: 'api_business_check_api')]
public function api_business_check_api(Access $access,Log $log,Request $request,EntityManagerInterface $entityManager): Response
{
return $this->json([
'Success'=>true
]);
}
}

View file

@ -199,6 +199,9 @@ class Business
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: Shareholder::class, orphanRemoval: true)]
private Collection $shareholders;
#[ORM\OneToMany(mappedBy: 'bid', targetEntity: Hook::class, orphanRemoval: true)]
private Collection $hooks;
public function __construct()
{
$this->logs = new ArrayCollection();
@ -223,6 +226,7 @@ class Business
$this->archiveFiles = new ArrayCollection();
$this->archiveOrders = new ArrayCollection();
$this->shareholders = new ArrayCollection();
$this->hooks = new ArrayCollection();
}
public function getId(): ?int
@ -1321,4 +1325,34 @@ class Business
return $this;
}
/**
* @return Collection<int, Hook>
*/
public function getHooks(): Collection
{
return $this->hooks;
}
public function addHook(Hook $hook): static
{
if (!$this->hooks->contains($hook)) {
$this->hooks->add($hook);
$hook->setBid($this);
}
return $this;
}
public function removeHook(Hook $hook): static
{
if ($this->hooks->removeElement($hook)) {
// set the owning side to null (unless already changed)
if ($hook->getBid() === $this) {
$hook->setBid(null);
}
}
return $this;
}
}

View file

@ -0,0 +1,83 @@
<?php
namespace App\Entity;
use App\Repository\HookRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: HookRepository::class)]
class Hook
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'hooks')]
#[ORM\JoinColumn(nullable: false)]
private ?Business $bid = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $url = null;
#[ORM\Column(length: 255)]
private ?string $password = null;
#[ORM\ManyToOne(inversedBy: 'hooks')]
#[ORM\JoinColumn(nullable: false)]
private ?User $submitter = null;
public function getId(): ?int
{
return $this->id;
}
public function getBid(): ?Business
{
return $this->bid;
}
public function setBid(?Business $bid): static
{
$this->bid = $bid;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): static
{
$this->url = $url;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): static
{
$this->password = $password;
return $this;
}
public function getSubmitter(): ?User
{
return $this->submitter;
}
public function setSubmitter(?User $submitter): static
{
$this->submitter = $submitter;
return $this;
}
}

View file

@ -98,6 +98,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[ORM\OneToMany(mappedBy: 'submitter', targetEntity: ArchiveOrders::class, orphanRemoval: true)]
private Collection $archiveOrders;
#[ORM\OneToMany(mappedBy: 'submitter', targetEntity: Hook::class, orphanRemoval: true)]
private Collection $hooks;
public function __construct()
{
$this->userTokens = new ArrayCollection();
@ -117,6 +120,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
$this->storeroomTickets = new ArrayCollection();
$this->archiveFiles = new ArrayCollection();
$this->archiveOrders = new ArrayCollection();
$this->hooks = new ArrayCollection();
}
public function getId(): ?int
@ -770,4 +774,34 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
return $this;
}
/**
* @return Collection<int, Hook>
*/
public function getHooks(): Collection
{
return $this->hooks;
}
public function addHook(Hook $hook): static
{
if (!$this->hooks->contains($hook)) {
$this->hooks->add($hook);
$hook->setSubmitter($this);
}
return $this;
}
public function removeHook(Hook $hook): static
{
if ($this->hooks->removeElement($hook)) {
// set the owning side to null (unless already changed)
if ($hook->getSubmitter() === $this) {
$hook->setSubmitter(null);
}
}
return $this;
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace App\Repository;
use App\Entity\Hook;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<Hook>
*
* @method Hook|null find($id, $lockMode = null, $lockVersion = null)
* @method Hook|null findOneBy(array $criteria, array $orderBy = null)
* @method Hook[] findAll()
* @method Hook[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class HookRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Hook::class);
}
// /**
// * @return Hook[] Returns an array of Hook objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('h')
// ->andWhere('h.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('h.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Hook
// {
// return $this->createQueryBuilder('h')
// ->andWhere('h.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}