Fix config
This commit is contained in:
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<int, Project>
|
||||
*/
|
||||
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<int, Comment>
|
||||
*/
|
||||
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<int, Folder>
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user