|
@@ -4,16 +4,29 @@ declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace App\ApiResources\Freemium;
|
|
namespace App\ApiResources\Freemium;
|
|
|
|
|
|
|
|
-use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
|
|
|
|
|
|
+use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
|
|
|
|
|
+use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
|
|
|
use ApiPlatform\Metadata\ApiFilter;
|
|
use ApiPlatform\Metadata\ApiFilter;
|
|
|
use ApiPlatform\Metadata\ApiProperty;
|
|
use ApiPlatform\Metadata\ApiProperty;
|
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
use ApiPlatform\Metadata\ApiResource;
|
|
|
|
|
+use ApiPlatform\Metadata\Delete;
|
|
|
use ApiPlatform\Metadata\Get;
|
|
use ApiPlatform\Metadata\Get;
|
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
use ApiPlatform\Metadata\GetCollection;
|
|
|
|
|
+use ApiPlatform\Metadata\Patch;
|
|
|
|
|
+use ApiPlatform\Metadata\Post;
|
|
|
use App\ApiResources\ApiResourcesInterface;
|
|
use App\ApiResources\ApiResourcesInterface;
|
|
|
|
|
+use App\Attribute\OrganizationDefaultValue;
|
|
|
use App\Entity\Booking\Event;
|
|
use App\Entity\Booking\Event;
|
|
|
|
|
+use App\Entity\Core\Country;
|
|
|
|
|
+use App\Entity\Core\File;
|
|
|
|
|
+use App\Entity\Organization\Organization;
|
|
|
|
|
+use App\Entity\Place\Place;
|
|
|
|
|
+use App\Enum\Booking\PricingEventEnum;
|
|
|
|
|
+use App\State\Processor\Freemium\FreemiumEventProcessor;
|
|
|
use App\State\Provider\Freemium\FreemiumEventProvider;
|
|
use App\State\Provider\Freemium\FreemiumEventProvider;
|
|
|
|
|
+use Doctrine\Common\Collections\Collection;
|
|
|
use Symfony\Component\ObjectMapper\Attribute\Map;
|
|
use Symfony\Component\ObjectMapper\Attribute\Map;
|
|
|
|
|
+use App\Validator\Constraints as OpentalentAssert;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Classe resource contient tous les champs pour la gestion d'un événement pour un profile Freemium.
|
|
* Classe resource contient tous les champs pour la gestion d'un événement pour un profile Freemium.
|
|
@@ -23,22 +36,88 @@ use Symfony\Component\ObjectMapper\Attribute\Map;
|
|
|
new GetCollection(
|
|
new GetCollection(
|
|
|
uriTemplate: '/freemium/events',
|
|
uriTemplate: '/freemium/events',
|
|
|
security: 'is_granted("ROLE_USER_FREEMIUM")',
|
|
security: 'is_granted("ROLE_USER_FREEMIUM")',
|
|
|
- provider: FreemiumEventProvider::class
|
|
|
|
|
|
|
+ ),
|
|
|
|
|
+ new Post(
|
|
|
|
|
+ uriTemplate: '/freemium/events',
|
|
|
|
|
+ security: 'is_granted("ROLE_USER_FREEMIUM")',
|
|
|
),
|
|
),
|
|
|
new Get(
|
|
new Get(
|
|
|
uriTemplate: '/freemium/events/{id}',
|
|
uriTemplate: '/freemium/events/{id}',
|
|
|
- security: '(is_granted("ROLE_USER_FREEMIUM") and (object.organizationId == user.getOrganization().getId()))',
|
|
|
|
|
- provider: FreemiumEventProvider::class
|
|
|
|
|
|
|
+ security: '(is_granted("ROLE_USER_FREEMIUM") and (object.organization == user.getOrganization()))',
|
|
|
|
|
+ ),
|
|
|
|
|
+ new Patch(
|
|
|
|
|
+ uriTemplate: '/freemium/events/{id}',
|
|
|
|
|
+ security: '(is_granted("ROLE_USER_FREEMIUM") and (object.organization == user.getOrganization()))',
|
|
|
|
|
+ ),
|
|
|
|
|
+ new Delete(
|
|
|
|
|
+ uriTemplate: '/freemium/events/{id}',
|
|
|
|
|
+ security: '(is_granted("ROLE_USER_FREEMIUM") and (object.organization == user.getOrganization()))',
|
|
|
),
|
|
),
|
|
|
- ]
|
|
|
|
|
|
|
+ ],
|
|
|
|
|
+ provider: FreemiumEventProvider::class,
|
|
|
|
|
+ processor: FreemiumEventProcessor::class
|
|
|
)]
|
|
)]
|
|
|
-#[ApiFilter(SearchFilter::class, properties: ['name' => 'partial'])]
|
|
|
|
|
|
|
+#[OrganizationDefaultValue(fieldName: 'organization')]
|
|
|
|
|
+#[ApiFilter(filterClass: DateFilter::class, properties: ['datetimeStart'])]
|
|
|
|
|
+#[ApiFilter(filterClass: OrderFilter::class, properties: ['datetimeStart'], arguments: ['orderParameterName' => 'order'])]
|
|
|
#[Map(source: Event::class)]
|
|
#[Map(source: Event::class)]
|
|
|
|
|
+#[OpentalentAssert\LessThanField(field: 'datetimeStart', comparedTo: 'datetimeEnd')]
|
|
|
class FreemiumEvent implements ApiResourcesInterface
|
|
class FreemiumEvent implements ApiResourcesInterface
|
|
|
{
|
|
{
|
|
|
#[ApiProperty(identifier: true)]
|
|
#[ApiProperty(identifier: true)]
|
|
|
public ?int $id = null;
|
|
public ?int $id = null;
|
|
|
- #[Map(source: 'organization.id')]
|
|
|
|
|
- public int $organizationName;
|
|
|
|
|
- public ?string $name = null;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ public Organization $organization;
|
|
|
|
|
+
|
|
|
|
|
+ public string $name;
|
|
|
|
|
+
|
|
|
|
|
+ public ?\DateTimeInterface $datetimeStart = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?\DateTimeInterface $datetimeEnd = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?string $description = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?File $image = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?string $url = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?string $urlTicket = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?Place $place = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.name')]
|
|
|
|
|
+ public ?string $placeName = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.streetAddress')]
|
|
|
|
|
+ public ?string $streetAddress = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.streetAddressSecond')]
|
|
|
|
|
+ public ?string $streetAddressSecond = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.streetAddressThird')]
|
|
|
|
|
+ public ?string $streetAddressThird = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.postalCode')]
|
|
|
|
|
+ public ?string $postalCode = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.addressCity')]
|
|
|
|
|
+ public ?string $addressCity = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.addressCountry')]
|
|
|
|
|
+ public ?Country $addressCountry = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.latitude')]
|
|
|
|
|
+ public ?float $latitude = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(source: 'place?.addressPostal?.longitude')]
|
|
|
|
|
+ public ?float $longitude = null;
|
|
|
|
|
+
|
|
|
|
|
+ #[Map(if: false)]
|
|
|
|
|
+ public Collection $categories;
|
|
|
|
|
+
|
|
|
|
|
+ public ?PricingEventEnum $pricing = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?float $priceMini = null;
|
|
|
|
|
+
|
|
|
|
|
+ public ?float $priceMaxi = null;
|
|
|
}
|
|
}
|