Skip to content

Commit

Permalink
Move Project entities inside own namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
subiabre committed Nov 28, 2024
1 parent d3e4519 commit efa17f6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
15 changes: 8 additions & 7 deletions src/Entity/Project.php → src/Entity/Project/Project.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php

namespace App\Entity;
namespace App\Entity\Project;

use App\Entity\Accounting\Accounting;
use App\Entity\Interface\AccountingOwnerInterface;
use App\Entity\Trait\MigratedEntity;
use App\Entity\Trait\TimestampedCreationEntity;
use App\Entity\Trait\TimestampedUpdationEntity;
use App\Repository\ProjectRepository;
use App\Entity\User;
use App\Repository\Project\ProjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
Expand Down Expand Up @@ -52,9 +53,9 @@ class Project implements AccountingOwnerInterface
private ProjectStatus $status;

/**
* @var Collection<int, ProjectReward>
* @var Collection<int, Reward>
*/
#[ORM\OneToMany(mappedBy: 'project', targetEntity: ProjectReward::class)]
#[ORM\OneToMany(mappedBy: 'project', targetEntity: Reward::class)]
private Collection $rewards;

public function __construct()
Expand Down Expand Up @@ -120,14 +121,14 @@ public function setStatus(ProjectStatus $status): static
}

/**
* @return Collection<int, ProjectReward>
* @return Collection<int, Reward>
*/
public function getRewards(): Collection
{
return $this->rewards;
}

public function addReward(ProjectReward $reward): static
public function addReward(Reward $reward): static
{
if (!$this->rewards->contains($reward)) {
$this->rewards->add($reward);
Expand All @@ -137,7 +138,7 @@ public function addReward(ProjectReward $reward): static
return $this;
}

public function removeReward(ProjectReward $reward): static
public function removeReward(Reward $reward): static
{
if ($this->rewards->removeElement($reward)) {
// set the owning side to null (unless already changed)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Entity;
namespace App\Entity\Project;

/**
* Projects have a start and an end, and in the meantime they go through different phases represented under this status.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php

namespace App\Entity;
namespace App\Entity\Project;

use App\Repository\ProjectRewardRepository;
use App\Entity\Money;
use App\Repository\Project\RewardRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
* A ProjectReward is something the Project owner wishes to give in exchange for contributions to their Project.
*/
#[ORM\Entity(repositoryClass: ProjectRewardRepository::class)]
class ProjectReward
#[ORM\Entity(repositoryClass: RewardRepository::class)]
class Reward
{
#[ORM\Id]
#[ORM\GeneratedValue]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;
namespace App\Repository\Project;

use App\Entity\Accounting\Accounting;
use App\Entity\Project;
use App\Entity\Project\Project;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php

namespace App\Repository;
namespace App\Repository\Project;

use App\Entity\ProjectReward;
use App\Entity\Project\Reward;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;

/**
* @extends ServiceEntityRepository<ProjectReward>
* @extends ServiceEntityRepository<Reward>
*/
class ProjectRewardRepository extends ServiceEntityRepository
class RewardRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ProjectReward::class);
parent::__construct($registry, Reward::class);
}

// /**
// * @return ProjectReward[] Returns an array of ProjectReward objects
// * @return Reward[] Returns an array of Reward objects
// */
// public function findByExampleField($value): array
// {
Expand All @@ -31,7 +31,7 @@ public function __construct(ManagerRegistry $registry)
// ;
// }

// public function findOneBySomeField($value): ?ProjectReward
// public function findOneBySomeField($value): ?Reward
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
Expand Down

0 comments on commit efa17f6

Please sign in to comment.