首页 > 解决方案 > 找不到常量 subresourceOperations,类 App\Entity\Comment

问题描述

我有两个表评论和作者之间的 OneToMany 关系,我想显示评论的作者,但它给了我错误[Semantical Error] Couldn't find constant subresourceOperations, class App\Entity\Commentsrc\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)
 */

标签: phpsymfony

解决方案


推荐阅读