Я разрабатываю API с платформой Symfony4 + Api и создаю маршрут для извлечения команды на основе параметра, который я отправляю в GET, за исключением того, что при вызове маршрута у меня появляется сообщение об ошибке, которое я не могу определить:
{
"@context": "/ api / contexts / Error",
"@type": "hydra: Error",
"hydra: title": "произошла ошибка",
"hydra: description": "Не найдено из-за неверной конфигурации идентификатора",
«след»: [
{
Вот мой класс, к которому я определил маршрут:
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
/**
* @ApiResource(
* collectionOperations={
* "get"={
* "method"="GET",
* "normalization_context"={"groups"={"orderGET", "orderGetCollection"}},
* "access_control"="is_granted('ROLE_ADMIN')"
* },
* "post"={
* "method"="POST",
* "denormalization_context"={"groups"={"orderPostCustomer"}},
* "access_control"="is_granted('ROLE_CUSTOMER')"
* }
* },
* itemOperations={
* "getItem"={
* "method"="GET",
* "normalization_context"={"groups"={"orderGET", "orderGetItem"}},
* "access_control"="is_granted('ROLE_ADMIN') or is_granted('ROLE_CUSTOMER')"
* },
* "put"={
* "method"="PUT",
* "normalization_context"={"groups"={"orderPostCustomer"}},
* "access_control"="is_granted('ROLE_ADMIN')"
* },
* "tracking_order"={
* "method"="GET",
* "normalization_context"={"groups"={"orderGET", "orderTracking"}},
* "route_name"="get_tracking_code_order",
* "access_control"="is_granted('IS_AUTHENTICATED_ANONYMOUSLY')",
* "swagger_context"={
* "parameters"={
* {
* "idTrackingAkaz" = "string",
* "in" = "path",
* "required" = "true",
* "type" = "string"
* }
* },
* "responses" ={
* "201" ={
* "description" = "Tracking code akaz",
* "schema" = {
* "type" = "object",
* "required" = {
* "idTrackingAkaz"
* },
* "properties" = {
* "idTrackingAkaz" = {
* "type" = "string"
* }
* }
* }
* },
* "400" = {
* "description" = "Invalid input"
* },
* "404" = {
* "description" = "resource not found"
* }
* },
* "summary" = "Send tracking code",
* "consumes" = {
* "application/json",
* "text/html",
* },
* "produces" = {
* "application/json"
* }
* }
* }
* }
* )
* @ApiFilter(SearchFilter::class, properties={"idTrackingAkaz": "exact", "lastHistory.status": "exact", "customer.city": "partial", "city": "partial", "lastHistory.User": "exact"})
* @ApiFilter(DateFilter::class, properties={"dateAdd"})
* @ORM\Entity(repositoryClass="App\Repository\OrderRepository")
*/
class Order
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
* @Groups({"orderGET", "orderDELETE", "orderPostCustomer"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $lastname;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $email;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $phone;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $address;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $address1;
/**
* @ORM\Column(type="integer")
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $zipcode;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGET", "orderPostCustomer"})
*/
private $city;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $country;
/**
* @ORM\Column(type="string", length=2000, nullable=true)
* @Groups("orderGetItem")
*/
private $urlTracking;
/**
* @ORM\Column(type="integer")
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $idOrderMerchant;
/**
* @ORM\Column(type="string", length=50, nullable=true)
* @Groups({"orderGetItem"})
*/
private $idTrackingMerchant;
/**
* @ORM\Column(type="string", length=50, nullable=true)
* @Groups({"orderGET", "orderTracking"})
*/
private $idTrackingAkaz;
/**
* @ORM\OneToMany(targetEntity="App\Entity\OrderHistory", mappedBy="orderId", cascade={"persist", "remove"})
* @Groups("orderGetItem")
*/
private $orderHistories;
/**
* @ORM\OneToOne(targetEntity="App\Entity\OrderHistory", cascade={"persist", "remove"})
* @ORM\JoinColumn(name="last_history_id", referencedColumnName="id")
* @Groups("orderGetCollection")
*/
private $lastHistory;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Customer", inversedBy="orders")
* @ORM\JoinColumn(nullable=true)
* @Groups("orderGET")
*/
private $customer;
/**
* @ORM\Column(type="integer")
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $weightMerchant;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups("orderGetItem")
*/
private $weightReal;
/**
* @ORM\Column(type="integer")
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $packages;
/**
* @ORM\Column(type="datetime")
* @Groups("orderGET")
*/
private $dateAdd;
/**
* @ORM\Column(type="datetime")
* @Groups("orderGET")
*/
private $dateUpd;
/**
* @ORM\OneToMany(targetEntity="App\Entity\OrderDetail", mappedBy="orderId", cascade={"persist", "remove"})
* @Groups({"orderGetItem", "orderPostCustomer"})
*/
private $orderDetails;
/**
* @ORM\Column(type="datetime", nullable=true)
* @Groups("orderGET")
*/
private $dateStampAkaz;
/**
* Order constructor.
*/
public function __construct()
{
$this->dateAdd = new \DateTime();
$this->dateUpd = new \DateTime();
$this->orderHistories = new ArrayCollection();
$this->orderDetails = new ArrayCollection();
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return null|string
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* @param string $phone
* @return Order
*/
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
/**
* @return null|string
*/
public function getAddress(): ?string
{
return $this->address;
}
/**
* @param string $address
* @return Order
*/
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
/**
* @return null|string
*/
public function getAddress1(): ?string
{
return $this->address1;
}
/**
* @param string $address1
* @return Order
*/
public function setAddress1(string $address1): self
{
$this->address1 = $address1;
return $this;
}
/**
* @return int|null
*/
public function getZipcode(): ?int
{
return $this->zipcode;
}
/**
* @param int $zipcode
* @return Order
*/
public function setZipcode(int $zipcode): self
{
$this->zipcode = $zipcode;
return $this;
}
/**
* @return null|string
*/
public function getCity(): ?string
{
return $this->city;
}
/**
* @param string $city
* @return Order
*/
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
/**
* @return null|string
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @param string $country
* @return Order
*/
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
/**
* @return null|int
*/
public function getIdOrderMerchant(): ?int
{
return $this->idOrderMerchant;
}
/**
* @param int $idOrderMerchant
* @return Order
*/
public function setIdOrderMerchant(int $idOrderMerchant): self
{
$this->idOrderMerchant = $idOrderMerchant;
return $this;
}
/**
* @return null|string
*/
public function getUrlTracking(): ?string
{
return $this->urlTracking;
}
/**
* @param string $urlTracking
* @return Order
*/
public function setUrlTracking(string $urlTracking): self
{
$this->urlTracking = $urlTracking;
return $this;
}
/**
* @return null|string
*/
public function getIdTrackingMerchant(): ?string
{
return $this->idTrackingMerchant;
}
/**
* @param string $idTrackingMerchant
* @return Order
*/
public function setIdTrackingMerchant(string $idTrackingMerchant): self
{
$this->idTrackingMerchant = $idTrackingMerchant;
return $this;
}
/**
* @return null|string
*/
public function getIdTrackingAkaz(): ?string
{
return $this->idTrackingAkaz;
}
/**
* @param string $idTrackingAkaz
* @return Order
*/
public function setIdTrackingAkaz(string $idTrackingAkaz): self
{
$this->idTrackingAkaz = $idTrackingAkaz;
return $this;
}
/**
* @return Collection|OrderHistory[]
*/
public function getOrderHistories(): Collection
{
return $this->orderHistories;
}
/**
* @param OrderHistory $orderHistory
* @return Order
*/
public function addOrderHistory(OrderHistory $orderHistory): self
{
if (!$this->orderHistories->contains($orderHistory)) {
$this->orderHistories[] = $orderHistory;
$orderHistory->setOrderId($this);
}
return $this;
}
/**
* @param OrderHistory $orderHistory
* @return Order
*/
public function removeOrderHistory(OrderHistory $orderHistory): self
{
if ($this->orderHistories->contains($orderHistory)) {
$this->orderHistories->removeElement($orderHistory);
// set the owning side to null (unless already changed)
if ($orderHistory->getOrderId() === $this) {
$orderHistory->setOrderId(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getLastHistory()
{
return $this->lastHistory;
}
/**
* @param mixed $lastHistory
*/
public function setLastHistory(OrderHistory $lastHistory): void
{
$this->lastHistory = $lastHistory;
}
/**
* @return Customer|null
*/
public function getCustomer(): ?Customer
{
return $this->customer;
}
/**
* @param Customer|null $customer
* @return Order
*/
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
/**
* @return int|null
*/
public function getWeightMerchant(): ?int
{
return $this->weightMerchant;
}
/**
* @param int $weightMerchant
* @return Order
*/
public function setWeightMerchant(int $weightMerchant): self
{
$this->weightMerchant = $weightMerchant;
return $this;
}
/**
* @return int|null
*/
public function getWeightReal(): ?int
{
return $this->weightReal;
}
/**
* @param int|null $weightReal
* @return Order
*/
public function setWeightReal(?int $weightReal): self
{
$this->weightReal = $weightReal;
return $this;
}
public function getDateAdd()
{
return $this->dateAdd;
}
/**
* @return \DateTimeInterface|null
*/
public function getDateUpd(): ?\DateTimeInterface
{
return $this->dateUpd;
}
/**
* @param \DateTimeInterface $dateUpd
* @return Order
*/
public function setDateUpd(\DateTimeInterface $dateUpd): self
{
$this->dateUpd = $dateUpd;
return $this;
}
/**
* @return Collection|OrderDetail[]
*/
public function getOrderDetails(): Collection
{
return $this->orderDetails;
}
/**
* @param OrderDetail $orderDetail
* @return Order
*/
public function addOrderDetail(OrderDetail $orderDetail): self
{
if (!$this->orderDetails->contains($orderDetail)) {
$this->orderDetails[] = $orderDetail;
$orderDetail->setOrderId($this);
}
return $this;
}
/**
* @param OrderDetail $orderDetail
* @return Order
*/
public function removeOrderDetail(OrderDetail $orderDetail): self
{
if ($this->orderDetails->contains($orderDetail)) {
$this->orderDetails->removeElement($orderDetail);
// set the owning side to null (unless already changed)
if ($orderDetail->getOrderId() === $this) {
$orderDetail->setOrderId(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getPackages()
{
return $this->packages;
}
/**
* @param mixed $packages
*/
public function setPackages($packages): void
{
$this->packages = $packages;
}
/**
* @return mixed
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* @param mixed $firstname
*/
public function setFirstname($firstname): void
{
$this->firstname = $firstname;
}
/**
* @return mixed
*/
public function getLastname()
{
return $this->lastname;
}
/**
* @param mixed $lastname
*/
public function setLastname($lastname): void
{
$this->lastname = $lastname;
}
/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* @param mixed $email
*/
public function setEmail($email): void
{
$this->email = $email;
}
/**
* @return mixed
*/
public function getDateStampAkaz()
{
return $this->dateStampAkaz;
}
/**
* @param \DateTimeInterface $dateStampAkaz
* @return Order
*/
public function setDateStampAkaz(\DateTimeInterface $dateStampAkaz): self
{
$this->dateStampAkaz = $dateStampAkaz;
return $this;
}
}
У вас есть представление о том, что я забыл? Спасибо за вашу помощь.