Base du projet 'application ticketing'

This commit is contained in:
2020-02-17 22:28:57 +01:00
parent 2a72ac97ac
commit afa734f96d
64 changed files with 1798 additions and 685 deletions

View File

@ -1,33 +0,0 @@
<?php
namespace App\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
class ApiController
{
public function login()
{
return new JsonResponse([
]);
}
public function logout()
{
return new JsonResponse([
]);
}
public function showVersionInfo()
{
return new JsonResponse([
'version' => '1',
]);
}
public function listUsers()
{
return new JsonResponse([]);
}
}

View File

@ -0,0 +1,20 @@
<?php
namespace App\Controller;
use App\Http\DataResponse;
use Symfony\Component\Routing\Annotation\Route;
class IndexController
{
/**
* @Route("/api/v1", name="api_v1_index")
*/
public function showAPIV1Index()
{
return new DataResponse([
'version' => '1',
]);
}
}

View File

@ -0,0 +1,18 @@
<?php
namespace App\Controller;
use App\Http\DataResponse;
use Symfony\Component\Routing\Annotation\Route;
class RequestController
{
/**
* @Route("/api/v1/request", name="api_v1_list_requests")
*/
public function listRequests()
{
return new DataResponse([]);
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Controller;
use App\Http\DataResponse;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class SecurityController extends Controller
{
/**
* @Route("/api/v1/login", name="api_v1_login", methods={"POST"})
*/
public function login(Request $request)
{
$user = $this->getUser();
return new DataResponse([
'username' => $user->getUsername(),
'roles' => $user->getRoles(),
]);
}
}

View File

@ -0,0 +1,72 @@
<?php
namespace App\Controller;
use App\Entity\User;
use App\Http\DataResponse;
use App\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
class UserController extends Controller
{
/**
* @Route("/api/v1/me", name="api_v1_users_me", methods={"GET"})
* @IsGranted("ROLE_USER")
*/
public function showCurrentUser()
{
/** @var User */
$user = $this->getUser();
return new DataResponse([
'username' => $user->getUsername(),
'roles' => $user->getRoles(),
]);
}
/**
* @Route("/api/v1/users", name="api_v1_list_users", methods={"GET"})
* @IsGranted("ROLE_DEVELOPER")
*/
public function listUsers()
{
/** @var array */
$users = $this->getDoctrine()
->getRepository(User::class)
->findAll()
;
$results = [];
foreach($users as $u) {
$results[] = [
'id' => $u->getId(),
'username' => $u->getUsername(),
];
}
return new DataResponse([
'users' => $results,
]);
}
/**
* @Route("/api/v1/users/{userId}", name="api_v1_get_user", methods={"GET"}, requirements={"userId"="\d+"})
* @IsGranted("ROLE_DEVELOPER")
*/
public function showUser($userId)
{
/** @var User */
$user = $this->getDoctrine()
->getRepository(User::class)
->find($userId)
;
return new DataResponse([
'user' => [
'id' => $user->getId(),
'username' => $user->getUsername(),
]
]);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\DataFixtures;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
// $product = new Product();
// $manager->persist($product);
$manager->flush();
}
}

View File

@ -0,0 +1,29 @@
<?php
namespace App\DataFixtures;
use App\Entity\RequestStatus;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
class RequestStatusFixtures extends Fixture
{
public function load(ObjectManager $manager)
{
$statuses = [
'En attente',
'Pris en compte',
'En cours de traitement',
'Traité',
'Clos',
];
foreach($statuses as $statusLabel) {
$status = new RequestStatus();
$status->setLabel($statusLabel);
$manager->persist($status);
}
$manager->flush();
}
}

View File

@ -0,0 +1,55 @@
<?php
namespace App\DataFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
class UserFixtures extends Fixture
{
private $passwordEncoder;
public function __construct(UserPasswordEncoderInterface $passwordEncoder)
{
$this->passwordEncoder = $passwordEncoder;
}
public function load(ObjectManager $manager)
{
// On créait l'utilisateur client1 et client2
$client1 = new User();
$client1->setUsername('client1');
$client1->setPassword($this->passwordEncoder->encodePassword(
$client1,
'client1'
));
$client1->setRoles(['ROLE_CLIENT']);
$manager->persist($client1);
$client2 = new User();
$client2->setUsername('client2');
$client2->setPassword($this->passwordEncoder->encodePassword(
$client2,
'client2'
));
$client2->setRoles(['ROLE_CLIENT']);
$manager->persist($client2);
// On créait l'utilisateur dev1
$dev1 = new User();
$dev1->setUsername('dev1');
$dev1->setPassword($this->passwordEncoder->encodePassword(
$dev1,
'dev1'
));
$dev1->setRoles(['ROLE_DEVELOPER']);
$manager->persist($dev1);
$manager->flush();
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommentRepository")
*/
class Comment
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Request", inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $request;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="comments")
* @ORM\JoinColumn(nullable=false)
*/
private $author;
/**
* @ORM\Column(type="text")
*/
private $text;
public function getId(): ?int
{
return $this->id;
}
public function getRequest(): ?Request
{
return $this->request;
}
public function setRequest(?Request $request): self
{
$this->request = $request;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getText(): ?string
{
return $this->text;
}
public function setText(string $text): self
{
$this->text = $text;
return $this;
}
}

View File

@ -0,0 +1,115 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProjectRepository")
*/
class Project
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Request", mappedBy="project", orphanRemoval=true)
*/
private $request;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="projects")
*/
private $users;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
public function __construct()
{
$this->request = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection|Request[]
*/
public function getRequest(): Collection
{
return $this->request;
}
public function addRequest(Request $request): self
{
if (!$this->request->contains($request)) {
$this->request[] = $request;
$request->setProject($this);
}
return $this;
}
public function removeRequest(Request $request): self
{
if ($this->request->contains($request)) {
$this->request->removeElement($request);
// set the owning side to null (unless already changed)
if ($request->getProject() === $this) {
$request->setProject(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
}
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
}

View File

@ -0,0 +1,154 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\RequestRepository")
*/
class Request
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="requests")
* @ORM\JoinColumn(nullable=false)
*/
private $author;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Project", inversedBy="request")
* @ORM\JoinColumn(nullable=false)
*/
private $project;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="request", orphanRemoval=true)
*/
private $comments;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\RequestStatus", inversedBy="requests")
* @ORM\JoinColumn(nullable=true)
*/
private $status;
public function __construct()
{
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): self
{
$this->author = $author;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getProject(): ?Project
{
return $this->project;
}
public function setProject(?Project $project): self
{
$this->project = $project;
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setRequest($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
if ($comment->getRequest() === $this) {
$comment->setRequest(null);
}
}
return $this;
}
public function getStatus(): ?RequestStatus
{
return $this->status;
}
public function setStatus(?RequestStatus $status): self
{
$this->status = $status;
return $this;
}
}

View File

@ -0,0 +1,83 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\RequestStatusRepository")
*/
class RequestStatus
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=64)
*/
private $label;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Request", mappedBy="status")
*/
private $requests;
public function __construct()
{
$this->requests = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|Request[]
*/
public function getRequests(): Collection
{
return $this->requests;
}
public function addRequest(Request $request): self
{
if (!$this->requests->contains($request)) {
$this->requests[] = $request;
$request->setStatus($this);
}
return $this;
}
public function removeRequest(Request $request): self
{
if ($this->requests->contains($request)) {
$this->requests->removeElement($request);
// set the owning side to null (unless already changed)
if ($request->getStatus() === $this) {
$request->setStatus(null);
}
}
return $this;
}
}

222
backend/src/Entity/User.php Normal file
View File

@ -0,0 +1,222 @@
<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $username;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Request", mappedBy="author", orphanRemoval=true)
*/
private $requests;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Project", mappedBy="users")
*/
private $projects;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Comment", mappedBy="author", orphanRemoval=true)
*/
private $comments;
public function __construct()
{
$this->requests = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->comments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->username;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
/**
* @return Collection|Request[]
*/
public function getRequests(): Collection
{
return $this->requests;
}
public function addRequest(Request $request): self
{
if (!$this->requests->contains($request)) {
$this->requests[] = $request;
$request->setAuthor($this);
}
return $this;
}
public function removeRequest(Request $request): self
{
if ($this->requests->contains($request)) {
$this->requests->removeElement($request);
// set the owning side to null (unless already changed)
if ($request->getAuthor() === $this) {
$request->setAuthor(null);
}
}
return $this;
}
/**
* @return Collection|Project[]
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Project $project): self
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->addUser($this);
}
return $this;
}
public function removeProject(Project $project): self
{
if ($this->projects->contains($project)) {
$this->projects->removeElement($project);
$project->removeUser($this);
}
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setAuthor($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->contains($comment)) {
$this->comments->removeElement($comment);
// set the owning side to null (unless already changed)
if ($comment->getAuthor() === $this) {
$comment->setAuthor(null);
}
}
return $this;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Http;
use Symfony\Component\HttpFoundation\JsonResponse;
class DataResponse extends JsonResponse {
public function __construct($data = null, $status = 200, $headers = [], $json = false) {
parent::__construct(
['data' => $data],
$status,
$headers,
$json,
);
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Http;
use Symfony\Component\HttpFoundation\JsonResponse;
class ErrorResponse extends JsonResponse {
public function __construct($code, $message, $data = null, $status = 400, $headers = [], $json = false) {
parent::__construct(
[
'error' => [
'code' => $code,
'message' => $message,
'data' => $data,
],
],
$status,
$headers,
$json,
);
}
}

View File

@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200217203938 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, username VARCHAR(180) NOT NULL, roles LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', password VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_8D93D649F85E0677 (username), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE request_status (id INT AUTO_INCREMENT NOT NULL, label VARCHAR(64) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE comment (id INT AUTO_INCREMENT NOT NULL, request_id INT NOT NULL, author_id INT NOT NULL, created_at DATETIME NOT NULL, text LONGTEXT NOT NULL, INDEX IDX_9474526C427EB8A5 (request_id), INDEX IDX_9474526CF675F31B (author_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE project (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE project_user (project_id INT NOT NULL, user_id INT NOT NULL, INDEX IDX_B4021E51166D1F9C (project_id), INDEX IDX_B4021E51A76ED395 (user_id), PRIMARY KEY(project_id, user_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE request (id INT AUTO_INCREMENT NOT NULL, author_id INT NOT NULL, project_id INT NOT NULL, title VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_3B978F9FF675F31B (author_id), INDEX IDX_3B978F9F166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526C427EB8A5 FOREIGN KEY (request_id) REFERENCES request (id)');
$this->addSql('ALTER TABLE comment ADD CONSTRAINT FK_9474526CF675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE project_user ADD CONSTRAINT FK_B4021E51166D1F9C FOREIGN KEY (project_id) REFERENCES project (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE project_user ADD CONSTRAINT FK_B4021E51A76ED395 FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE request ADD CONSTRAINT FK_3B978F9FF675F31B FOREIGN KEY (author_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE request ADD CONSTRAINT FK_3B978F9F166D1F9C FOREIGN KEY (project_id) REFERENCES project (id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526CF675F31B');
$this->addSql('ALTER TABLE project_user DROP FOREIGN KEY FK_B4021E51A76ED395');
$this->addSql('ALTER TABLE request DROP FOREIGN KEY FK_3B978F9FF675F31B');
$this->addSql('ALTER TABLE project_user DROP FOREIGN KEY FK_B4021E51166D1F9C');
$this->addSql('ALTER TABLE request DROP FOREIGN KEY FK_3B978F9F166D1F9C');
$this->addSql('ALTER TABLE comment DROP FOREIGN KEY FK_9474526C427EB8A5');
$this->addSql('DROP TABLE user');
$this->addSql('DROP TABLE request_status');
$this->addSql('DROP TABLE comment');
$this->addSql('DROP TABLE project');
$this->addSql('DROP TABLE project_user');
$this->addSql('DROP TABLE request');
}
}

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200217211954 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}
public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE request ADD status_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE request ADD CONSTRAINT FK_3B978F9F6BF700BD FOREIGN KEY (status_id) REFERENCES request_status (id)');
$this->addSql('CREATE INDEX IDX_3B978F9F6BF700BD ON request (status_id)');
}
public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql('ALTER TABLE request DROP FOREIGN KEY FK_3B978F9F6BF700BD');
$this->addSql('DROP INDEX IDX_3B978F9F6BF700BD ON request');
$this->addSql('ALTER TABLE request DROP status_id');
}
}

View File

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

View File

@ -0,0 +1,50 @@
<?php
namespace App\Repository;
use App\Entity\Project;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
/**
* @method Project|null find($id, $lockMode = null, $lockVersion = null)
* @method Project|null findOneBy(array $criteria, array $orderBy = null)
* @method Project[] findAll()
* @method Project[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
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)
{
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()
;
}
*/
}

View File

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

View File

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

View File

@ -0,0 +1,39 @@
<?php
namespace App\Repository;
use App\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @method User|null find($id, $lockMode = null, $lockVersion = null)
* @method User|null findOneBy(array $criteria, array $orderBy = null)
* @method User[] findAll()
* @method User[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserRepository extends ServiceEntityRepository implements PasswordUpgraderInterface
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, User::class);
}
/**
* Used to upgrade (rehash) the user's password automatically over time.
*/
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
}
$user->setPassword($newEncodedPassword);
$this->_em->persist($user);
$this->_em->flush();
}
}