Add Project entity, user routes and clipper controls
This commit is contained in:
18
src/Controller/UserController.php
Normal file
18
src/Controller/UserController.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class UserController extends AbstractController
|
||||
{
|
||||
#[Route('/user', name: 'app_user')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('user/index.html.twig', [
|
||||
'controller_name' => 'UserController',
|
||||
]);
|
||||
}
|
||||
}
|
||||
92
src/Entity/Project.php
Normal file
92
src/Entity/Project.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Repository\ProjectRepository;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity(repositoryClass: ProjectRepository::class)]
|
||||
#[ORM\Table(name: 'progetto')]
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(normalizationContext: ['groups' => 'project:item']),
|
||||
new GetCollection(normalizationContext: ['groups' => 'project:list']),
|
||||
new Post(security: "is_granted('ROLE_USER')"),
|
||||
],
|
||||
order: ['name' => 'DESC'],
|
||||
paginationEnabled: false,
|
||||
)]
|
||||
class Project
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: Types::BIGINT, name: 'id_utente')]
|
||||
#[ORM\OneToOne(User::class, )]
|
||||
private ?string $userid = null;
|
||||
|
||||
#[ORM\Column(type: Types::BIGINT, name: 'id_architettura')]
|
||||
private ?string $buildingid = null;
|
||||
|
||||
#[ORM\Column(length: 255, nullable: true)]
|
||||
/**
|
||||
* @var string $ifc Path to IFC file for this project
|
||||
*/
|
||||
private ?string $ifc = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setId(string $id): static
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getUserid(): ?string
|
||||
{
|
||||
return $this->userid;
|
||||
}
|
||||
|
||||
public function setUserid(string $userid): static
|
||||
{
|
||||
$this->userid = $userid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getBuildingid(): ?string
|
||||
{
|
||||
return $this->buildingid;
|
||||
}
|
||||
|
||||
public function setBuildingid(string $buildingid): static
|
||||
{
|
||||
$this->buildingid = $buildingid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIfc(): ?string
|
||||
{
|
||||
return $this->ifc;
|
||||
}
|
||||
|
||||
public function setIfc(?string $ifc): static
|
||||
{
|
||||
$this->ifc = $ifc;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,15 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
#[ORM\Column]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?string $firstname = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?string $lastname = null;
|
||||
|
||||
#[ORM\Column]
|
||||
private ?string $email = null;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -55,7 +64,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
*/
|
||||
public function getUserIdentifier(): string
|
||||
{
|
||||
return (string) $this->username;
|
||||
return "{$this->firstname} {$this->lastname}";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +106,41 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFirstname(): ?string
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setFirstname(string $firstname): static
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getLastname(): ?string
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLastname(string $lastname): static
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEmail(): ?string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setEmail(string $email): static
|
||||
{
|
||||
$this->email = $email;
|
||||
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* @see UserInterface
|
||||
*/
|
||||
|
||||
43
src/Repository/ProjectRepository.php
Normal file
43
src/Repository/ProjectRepository.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Project;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Project>
|
||||
*/
|
||||
class ProjectRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Project::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Project[] Returns an array of Project objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('p.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Project
|
||||
// {
|
||||
// return $this->createQueryBuilder('p')
|
||||
// ->andWhere('p.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user