2016-07-04 21 views
1

私の行動では早くも配列のような応答がありますが、オブジェクトのような応答の変化と私はなぜundestandしません。機能は変更されませfindBitByProject - 私のアクションSymfony RestBundle注釈表示

$results = $query->getResult(); 

[ 
    {} 
    {} 
] 

{ 
0: {} 
1: {} 
} 

私の入札クラス

早期

$bits = $this->getDoctrine()->getManager() 
     ->getRepository('ArtelProfileBundle:Bit') 
     ->findBitByProject($request); 

    //$bits return array<Bit> 

    return View::create() 
     ->setStatusCode(200) 
     ->setData($bits) 
     ->setSerializationContext(
      SerializationContext::create() 
       ->setGroups(
        array('for_project_bit') 
       ) 
     ); 

応答を返します

/** 
* Bit. 
* 
* @ORM\Table(name="bit") 
* @ORM\HasLifecycleCallbacks 
* @ORM\Entity(repositoryClass="Artel\ProfileBundle\Entity\Repository\BitRepository") 
* @Gedmo\SoftDeleteable(fieldName="deletedAt") 
* @Annotation\ExclusionPolicy("all") 
*/ 
class Bit 
{ 
const NOT_APPROPRIATE  = 'not_appropriate'; 
const WAITING_FOR_DECISION = 'waiting_for_decision'; 
const CONFIRM    = 'confirmed'; 
const STATUS_SEND_CLIENT = 'send_client'; 
const WAITING_FOR_FEEDBACK = 'waiting_for_feedback'; 
const STATUS_SENT_CV  = 'sent_cv'; 
const STATUS_UNRESOLVED  = 'unresolved'; 

use Timestampable; 

/** 
* @var int 
* 
* @ORM\Column(name="id", type="integer") 
* @ORM\Id 
* @ORM\GeneratedValue(strategy="AUTO") 
* @Annotation\Expose() 
* @Annotation\Groups({ 
*  "get_client_by_id", "get_bid_id", "for_project_bit", "for_project_bit_admin", "for_all_projects", 
*  "get_entity_bits", "get_all_projects", "for_projects", "get_all_workorders", "get_workorder" 
* }) 
*/ 
private $id; 

/** 
* @var Developer 
* 
* @ORM\ManyToOne(targetEntity="Developer", inversedBy="bit", cascade={"persist"}) 
* @ORM\JoinColumn(name="developer_id", nullable = true, referencedColumnName="id") 
* @Annotation\Expose() 
* @Annotation\Groups({ 
*  "get_client_by_id", "get_bid_id", "for_project_bit", "for_project_bit_admin", "for_all_projects", "get_entity_bits", 
*  "for_projects", "get_all_projects" 
* }) 
*/ 
protected $developerId; 

/** 
* @var Users 
* 
* @ORM\ManyToOne(targetEntity="Users", inversedBy="bid", cascade={"persist"}) 
* @ORM\JoinColumn(name="author_id", nullable = true, referencedColumnName="id") 
* @Annotation\Expose() 
* @Annotation\Groups({ 
*  "get_client_by_id", "get_bid_id", "for_project_bit", "for_project_bit_admin", "for_all_projects", "get_entity_bits", 
*  "for_projects", "get_all_projects" 
* }) 
*/ 
protected $author; 

/** 
* @var Project 
* 
* @ORM\ManyToOne(targetEntity="Project", inversedBy="bit") 
* @ORM\JoinColumn(name="project_id", referencedColumnName="id", onDelete="CASCADE") 
* @Annotation\Expose() 
* @Annotation\Groups({"for_all_projects", "for_project_bit", "for_project_bit_admin", "get_entity_bits"}) 
*/ 
private $projectId; 

/** 
* @var float 
* 
* @Assert\NotBlank(groups={"post_bid"}) 
* @ORM\Column(name="rate", type="float") 
* @Annotation\Expose() 
* @Annotation\Groups({ 
*  "get_client_by_id", "get_bid_id", "for_projects", "for_project_bit", "for_project_bit_admin", 
*  "for_all_projects", "get_entity_bits" 
* }) 
*/ 
private $rate; 

これは私とどのように修正するとhappenesなぜ私はOK everythin開発者の関係のために

をシリアライザグループをdesable? :)

+0

あなたの「ビット」クラス – LBA

+0

更新質問 –

+0

を表示して下さいは、関連するビットコレクションにビットまたはプロジェクトを含む$ビットのですか? – LBA

答えて

0

次のことを試してみてください。

$view = View::create() 
    ->setStatusCode(200) 
    ->setData($bits) 
    ->setSerializationContext(
     SerializationContext::create() 
      ->setGroups(
       array('for_project_bit') 
      ) 
    ); 

return $this->handleView($view); 
関連する問題