From 41a1a8c44caa95ad7256d97f258640812d6b0a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Guillot?= Date: Mon, 3 Jun 2024 18:09:16 +0200 Subject: [PATCH] Fix config --- composer.json | 1 + composer.lock | 2 +- config/services.yaml | 4 -- src/DataFixtures/AppFixtures.php | 70 ------------------ src/Entity/User.php | 120 ------------------------------- 5 files changed, 2 insertions(+), 195 deletions(-) diff --git a/composer.json b/composer.json index 385dbbc..a1307d0 100644 --- a/composer.json +++ b/composer.json @@ -11,6 +11,7 @@ "ext-curl": "*", "ext-iconv": "*", "api-platform/core": "^3.2", + "doctrine/dbal": "^3", "doctrine/doctrine-bundle": "^2.11", "doctrine/doctrine-migrations-bundle": "^3.3", "doctrine/orm": "^2.17", diff --git a/composer.lock b/composer.lock index f447f97..c82aab1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "46418bba7f81de1bb030e3321a5fb4c9", + "content-hash": "7f30c3ed2e16470ab82ad4fd0ca8b987", "packages": [ { "name": "api-platform/core", diff --git a/config/services.yaml b/config/services.yaml index e5c4bf8..7f37ba9 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -26,10 +26,6 @@ services: App\EventListener\ExceptionListener: tags: - { name: kernel.event_listener, event: kernel.exception, method: onKernelException } - - App\Service\DataLakeClient: - arguments: - $baseUrl: '%env(DATA_LAKE_BASE_URL)%' GuzzleHttp\Client: class: GuzzleHttp\Client diff --git a/src/DataFixtures/AppFixtures.php b/src/DataFixtures/AppFixtures.php index 9bdff13..88fa117 100644 --- a/src/DataFixtures/AppFixtures.php +++ b/src/DataFixtures/AppFixtures.php @@ -3,12 +3,6 @@ namespace App\DataFixtures; use App\Factory\ApiTokenFactory; -use App\Factory\CommentFactory; -use App\Factory\CompanyFactory; -use App\Factory\DocumentFactory; -use App\Factory\FolderFactory; -use App\Factory\ProjectDocumentFactory; -use App\Factory\ProjectFactory; use App\Factory\UserFactory; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Persistence\ObjectManager; @@ -17,70 +11,6 @@ class AppFixtures extends Fixture { public function load(ObjectManager $manager): void { - CompanyFactory::createMany(5); - UserFactory::createMany(20, function () { - return [ - 'company' => CompanyFactory::random() - ]; - }); - ApiTokenFactory::createMany(60, function () { - return [ - 'ownedBy' => UserFactory::random() - ]; - }); - $projects = ProjectFactory::createMany(100, function () { - return [ - 'ownedBy' => UserFactory::random() - ]; - }); - $documents = DocumentFactory::createMany(100); - - foreach ($documents as $document) { - ProjectDocumentFactory::createMany(3, function () use ($document) { - return [ - 'document' => $document, - 'project' => ProjectFactory::random() - ]; - }); - - CommentFactory::createMany(1, function () use ($document) { - return [ - 'projectDocument' => ProjectDocumentFactory::random(), - 'postedBy' => UserFactory::random() - ]; - }); - } - - foreach ($projects as $project) { - $projectFolder = FolderFactory::createOne([ - 'label' => 'Root Folder Project ' . $project->getId(), - 'slug' => 'root-folder-project-' . $project->getId(), - 'project' => $project, - 'createdBy' => $project->getOwnedBy() - ]); - $child = FolderFactory::createOne([ - 'label' => 'Subfolder - Parent Folder: ' . $projectFolder->getId(), - 'slug' => 'subfolder-parent-folder-' . $projectFolder->getId(), - 'createdBy' => $project->getOwnedBy() - ]); - $grandChild = FolderFactory::createOne([ - 'label' => 'Subfolder - Parent Folder: ' . $child->getId(), - 'slug' => 'subfolder-parent-folder-' . $child->getId(), - 'createdBy' => $project->getOwnedBy() - ]); - - $grandChild->addDocument(DocumentFactory::createOne()->object()); - $grandChild->addDocument(DocumentFactory::createOne()->object()); - $grandChild->addDocument(DocumentFactory::createOne()->object()); - - $child->addChild( - $grandChild->object() - ); - - $projectFolder->addChild( - $child->object() - ); - } } } diff --git a/src/Entity/User.php b/src/Entity/User.php index 4a21f0d..0cd837e 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -75,32 +75,14 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface private ?array $accessTokenScopes = null; - #[ORM\ManyToOne(inversedBy: 'employees')] - #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] - #[Groups(['user:read'])] - private ?Company $company = null; - #[Groups(['user:write'])] #[SerializedName('password')] #[Assert\NotBlank(groups: ['postValidation'])] private ?string $plainPassword = null; - #[ORM\OneToMany(mappedBy: 'ownedBy', targetEntity: Project::class)] - #[Groups(['user:read'])] - private Collection $projects; - - #[ORM\OneToMany(mappedBy: 'postedBy', targetEntity: Comment::class)] - private Collection $comments; - - #[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Folder::class)] - private Collection $folders; - public function __construct() { $this->apiTokens = new ArrayCollection(); - $this->projects = new ArrayCollection(); - $this->comments = new ArrayCollection(); - $this->folders = new ArrayCollection(); } public function getId(): ?int @@ -250,18 +232,6 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface $this->accessTokenScopes = $scopes; } - public function getCompany(): ?Company - { - return $this->company; - } - - public function setCompany(?Company $company): static - { - $this->company = $company; - - return $this; - } - public function getPlainPassword(): ?string { return $this->plainPassword; @@ -271,94 +241,4 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface { $this->plainPassword = $plainPassword; } - - /** - * @return Collection - */ - public function getProjects(): Collection - { - return $this->projects; - } - - public function addProject(Project $project): static - { - if (!$this->projects->contains($project)) { - $this->projects->add($project); - $project->setOwnedBy($this); - } - - return $this; - } - - public function removeProject(Project $project): static - { - if ($this->projects->removeElement($project)) { - // set the owning side to null (unless already changed) - if ($project->getOwnedBy() === $this) { - $project->setOwnedBy(null); - } - } - - return $this; - } - - /** - * @return Collection - */ - public function getComments(): Collection - { - return $this->comments; - } - - public function addComment(Comment $comment): static - { - if (!$this->comments->contains($comment)) { - $this->comments->add($comment); - $comment->setPostedBy($this); - } - - return $this; - } - - public function removeComment(Comment $comment): static - { - if ($this->comments->removeElement($comment)) { - // set the owning side to null (unless already changed) - if ($comment->getPostedBy() === $this) { - $comment->setPostedBy(null); - } - } - - return $this; - } - - /** - * @return Collection - */ - public function getFolders(): Collection - { - return $this->folders; - } - - public function addFolder(Folder $folder): static - { - if (!$this->folders->contains($folder)) { - $this->folders->add($folder); - $folder->setCreatedBy($this); - } - - return $this; - } - - public function removeFolder(Folder $folder): static - { - if ($this->folders->removeElement($folder)) { - // set the owning side to null (unless already changed) - if ($folder->getCreatedBy() === $this) { - $folder->setCreatedBy(null); - } - } - - return $this; - } }