Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony返回一些字段实体OneToMany_Php_Symfony_Jmsserializerbundle - Fatal编程技术网

Php Symfony返回一些字段实体OneToMany

Php Symfony返回一些字段实体OneToMany,php,symfony,jmsserializerbundle,Php,Symfony,Jmsserializerbundle,我有一个实体项目和一个域一个域一个域,当我返回项目时,我@Expose()这个域和一个域一个域一个域一个域一个域都有 所有字段位都有@Expose。在实体位中,我对一些字段有注释@Groups({“list”}),例如id,当我返回实体项目时,如何对位使用这个注释@Groups({“list”})?我需要这个项目的返回计数位,我知道如何找到计数位,比如$count=count($project->getBit()->getValues()),以及这个计数如何添加到返回项目中($projects,

我有一个实体项目和一个域一个域一个域,当我返回项目时,我@Expose()这个域和一个域一个域一个域一个域一个域都有 所有字段位都有@Expose。在实体位中,我对一些字段有注释@Groups({“list”}),例如id,当我返回实体项目时,如何对位使用这个注释@Groups({“list”})?我需要这个项目的返回计数位,我知道如何找到计数位,比如$count=count($project->getBit()->getValues()),以及这个计数如何添加到返回项目中($projects,根据某些条件,这是数组项目)

实体:

 class Project
 {
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @Expose()
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var string
 *
 * @ORM\Column(name="project_name", type="string", length=255, nullable=true)
 * @Expose()
 * @Type("string")
 */
protected $project_name;

/**
 * @ORM\OneToMany(targetEntity="Bit", mappedBy="projectId", cascade={"remove"})
 * @Expose()
 */
protected $bit;
位:

在这个json中,我不需要位中的开发者,只需要位中没有关系的字段

{
"id": 101,
"main_skill": "105",
"type": "fixed_cost",
"name": "fsfefsef",
"markets": [
  "2"
],
"platforms": [
  "2"
],
"speciality": [],
"slug": "105-fsfefsef",
"description": "fsefs",
"duration": "fsef",
"expected_budget": "$ 34.00",
"project_skills": [
  "15"
],
"created": "2015-11-27T12:24:39+0200",
"closed": 0,
"stripped_name": "__105_fsfefsef",
"current_status": "published",
"bit": [
  {
    "id": 501,
    "created": "2015-11-27T12:25:11+0200",
    "developer_id": {
      "id": 82,
      "level": "Senior",
      "main_skill": "Ext JS",
      "skills": [
        "jQuery",
        "Dojo",
        "Akelos",
        "Visual Studio",
        "jenkins",
        "WPF",
        "LMS",
        "Hadoop",
        "gui",
        ".NET",
        "JavaScript",
        "Web",
        "DevOps",
        "Parse",
        "Java EE",
        "Python"
      ],
      "platforms": [],
      "english": "Basic",
      "rate": 6,
      "tags": [
        "tag5",
        "only main skill"
      ],
      "user": [
        {
          "id": 200,
          "first_name": "Twila",
          "last_name": "Leuschke",
          "email": "bulah.wolff@gmail.com",
          "skype": "Crystal Bartoletti",
          "telephone": "1-933-454-0851x97226"
        }
      ],
      "created_at": "2015-11-27T12:19:18+0200",
      "updated_at": "2015-11-27T12:19:37+0200"
    },
    "rate": 4,
    "comment": "fsefsf"
  },
class Bit
{
/**
 * @var integer
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 * @Expose()
 * @Groups({"list"})
 */
private $id;

/**
 * @var datetime $created
 *
 * @Gedmo\Timestampable(on="create")
 * @ORM\Column(type="datetime")
 * @Expose()
 */
private $created;

/**
 * @var datetime $updated
 *
 * @Gedmo\Timestampable(on="update")
 * @ORM\Column(type="datetime")
 */
private $updated;
{
"id": 101,
"main_skill": "105",
"type": "fixed_cost",
"name": "fsfefsef",
"markets": [
  "2"
],
"platforms": [
  "2"
],
"speciality": [],
"slug": "105-fsfefsef",
"description": "fsefs",
"duration": "fsef",
"expected_budget": "$ 34.00",
"project_skills": [
  "15"
],
"created": "2015-11-27T12:24:39+0200",
"closed": 0,
"stripped_name": "__105_fsfefsef",
"current_status": "published",
"bit": [
  {
    "id": 501,
    "created": "2015-11-27T12:25:11+0200",
    "developer_id": {
      "id": 82,
      "level": "Senior",
      "main_skill": "Ext JS",
      "skills": [
        "jQuery",
        "Dojo",
        "Akelos",
        "Visual Studio",
        "jenkins",
        "WPF",
        "LMS",
        "Hadoop",
        "gui",
        ".NET",
        "JavaScript",
        "Web",
        "DevOps",
        "Parse",
        "Java EE",
        "Python"
      ],
      "platforms": [],
      "english": "Basic",
      "rate": 6,
      "tags": [
        "tag5",
        "only main skill"
      ],
      "user": [
        {
          "id": 200,
          "first_name": "Twila",
          "last_name": "Leuschke",
          "email": "bulah.wolff@gmail.com",
          "skype": "Crystal Bartoletti",
          "telephone": "1-933-454-0851x97226"
        }
      ],
      "created_at": "2015-11-27T12:19:18+0200",
      "updated_at": "2015-11-27T12:19:37+0200"
    },
    "rate": 4,
    "comment": "fsefsf"
  },