Update accounting api resource ownership settings
This commit is contained in:
@@ -4,8 +4,13 @@ namespace App\ApiResource\Accounting;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\State\Options;
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\ApiResource\Project\ProjectApiResource;
|
||||
use App\ApiResource\User\UserApiResource;
|
||||
use App\Entity\Accounting\Accounting;
|
||||
use App\Entity\Money;
|
||||
use App\Entity\Project\Project;
|
||||
use App\Entity\Tipjar;
|
||||
use App\Entity\User\User;
|
||||
use App\State\Accounting\AccountingStateProcessor;
|
||||
use App\State\Accounting\AccountingStateProvider;
|
||||
|
||||
@@ -36,10 +41,34 @@ class AccountingApiResource
|
||||
*/
|
||||
public string $currency;
|
||||
|
||||
#[API\ApiProperty(readable: false, writable: false)]
|
||||
public string $ownerClass;
|
||||
|
||||
#[API\ApiProperty(readable: false, writable: false)]
|
||||
public ?UserApiResource $user = null;
|
||||
|
||||
#[API\ApiProperty(readable: false, writable: false)]
|
||||
public ?ProjectApiResource $project = null;
|
||||
|
||||
#[API\ApiProperty(readable: false, writable: false)]
|
||||
public ?Tipjar $tipjar = null;
|
||||
|
||||
/**
|
||||
* The resource owning this Accounting.\.
|
||||
* The resource owning this Accounting.
|
||||
*
|
||||
* @return UserApiResource|ProjectApiResource|Tipjar
|
||||
*/
|
||||
public mixed $owner;
|
||||
public function getOwner(): object
|
||||
{
|
||||
switch ($this->ownerClass) {
|
||||
case User::class:
|
||||
return $this->user;
|
||||
case Project::class:
|
||||
return $this->project;
|
||||
case Tipjar::class:
|
||||
return $this->tipjar;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The money currently held by the Accounting.
|
||||
|
||||
Reference in New Issue
Block a user