php - 找不到常量 subresourceOperations,类 App\Entity\Comment
问题描述
我有两个表评论和作者之间的 OneToMany 关系,我想显示评论的作者,但它给了我错误[Semantical Error] Couldn't find constant subresourceOperations, class App\Entity\Comment
。
src\Entity\Comment.php
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\CommentRepository;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
/**
* @ApiResource(itemOperations={"GET","DELETE",
* "PUT"={
* "access_control"="is_granted('IS_AUTHENTICATED_FULLY') and object.getAuthor() == user"
* }
* },
* collectionOperations={"GET",
* "POST"={
* "access_control"="is_granted('IS_AUTHENTICATED_FULLY')"
* },
* subresourceOperations={
* "api_posts_comments_get_subresource"={
* "normalization_context"={
* "groups"={"get-comment-with-author"}
* }
* }
* }
* }
*)
* @ORM\Entity(repositoryClass=CommentRepository::class)
*/
解决方案
推荐阅读
- c# - 通过 NGINX 在 Linux 上部署的 ASP.Net Core 2.2,POST 请求返回 HTTP 错误 400
- node.js - 在 npm install 和 npm start 后找不到 package.json。该项目在我将其推送到 github 之前能够运行
- sql - 如何将所有值更改为序列中的第一个?
- c# - AWS Lambda 函数 (c#) - 在调试模式下工作,但发布后会出现错误
- php - 如何在laravel中比较created_at时间戳和碳日期?
- database-design - Realm Database Full Sync - 如何实现全局评论系统
- sql - 如果用户没有所需的记录,则将其标记为非活动用户
- python - 如何使用 MagicMock 避免 __init__ 依赖
- python - 为什么 VS-Code Autopep8 格式化 2 条白线?
- javascript - Azure 函数 blob 输出绑定路径参数 (javascript)