I\'m new to API Platform. I think it\'s great but I cannot find any example how to create custom endpoint that isn\'t based on any entity. There are a lot of examples based on a
You are not forced to use entities. Classes that are marked with @ApiResource
annotation may not be entities. Actually, if your application is smarter than basic CRUD you should avoid marking entities as ApiResource.
Since you want to use POST HTTP method (which is for creating resource items) you can do something like this.
1) Define class describing search fields and which will be your @ApiResource
2) Define DTO that will represent the output
3) Create class that will inplement DataPersisterInterface
for handling business logic.
It will be called by framework because you make POST request.
flights = ['a lot of json data'];
$output->airports = ['a lot of json data'];
$output->cities = ['inputData' => $data];
return $output;
}
public function remove($data)
{
// this method just need to be presented
}
}
That way you will recieve results based on request.