<?php
/**
 * @author Daniel Knudsen <d.knudsen@spawntree.de>
 * @date 29.04.25
 */


namespace App\State;


use ApiPlatform\Metadata\Operation;
use App\Entity\Trip;

class UserTripStateProcessor extends EntityClassDtoStateProcessor
{


    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = [])
    {
        $res = parent::process($data, $operation, $uriVariables, $context);

        /** @var Trip $trip */
        $trip = $this->em->getRepository(Trip::class)->find($data->tripIri->id);
        $trip->setCompleted();
        $this->em->flush();

        return $res;
    }


}