Expose categories on the API
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\ApiResource;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\State\Options;
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\Entity\Category;
|
||||
use App\State\ApiResourceStateProvider;
|
||||
|
||||
#[API\ApiResource(
|
||||
shortName: 'Category',
|
||||
stateOptions: new Options(entityClass: Category::class)
|
||||
)]
|
||||
#[API\GetCollection(provider: ApiResourceStateProvider::class)]
|
||||
#[API\Get(provider: ApiResourceStateProvider::class)]
|
||||
class CategoryApiResource
|
||||
{
|
||||
#[API\ApiProperty(identifier: true)]
|
||||
public string $id;
|
||||
}
|
||||
@@ -6,6 +6,7 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Doctrine\Orm\State\Options;
|
||||
use ApiPlatform\Metadata as API;
|
||||
use App\ApiResource\Accounting\AccountingApiResource;
|
||||
use App\ApiResource\CategoryApiResource;
|
||||
use App\ApiResource\LocalizedApiResourceTrait;
|
||||
use App\ApiResource\Matchfunding\MatchCallSubmissionApiResource;
|
||||
use App\ApiResource\User\UserApiResource;
|
||||
@@ -109,6 +110,8 @@ class ProjectApiResource
|
||||
|
||||
/**
|
||||
* A list of the available categories most relevant to this Project.
|
||||
*
|
||||
* @var array<int, CategoryApiResource>
|
||||
*/
|
||||
#[Assert\NotBlank()]
|
||||
#[API\ApiFilter(filterClass: SearchFilter::class, strategy: 'exact')]
|
||||
|
||||
@@ -37,6 +37,7 @@ trait RedocExtensionsTrait
|
||||
'ProjectBudgetItem',
|
||||
'ProjectUpdate',
|
||||
'ProjectSupport',
|
||||
'Category',
|
||||
],
|
||||
],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user