| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Service\OnChange;
- class OnChangeContext
- {
- /**
- * @param array<mixed> $context
- */
- public function __construct(
- private array $context
- ) {}
- /**
- * La requête traitée est de type POST
- *
- * @return bool
- */
- public function isPostRequest(): bool
- {
- return ($this->context['collection_operation_name'] ?? null) === 'post';
- }
- /**
- * La requête traitée est de type PUT
- *
- * @return bool
- */
- public function isPutRequest(): bool
- {
- return ($this->context['item_operation_name'] ?? null) === 'put';
- }
- /**
- * Retourne l'entité existante (avant mise à jour) si elle existe, null sinon
- *
- * @return mixed|null
- */
- public function previousData() {
- return $this->context['previous_data'] ?? null;
- }
- }
|