Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.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 RestBundle注释视图_Php_Symfony_Fosrestbundle - Fatal编程技术网

Php Symfony RestBundle注释视图

Php Symfony RestBundle注释视图,php,symfony,fosrestbundle,Php,Symfony,Fosrestbundle,在我早期的行为中,我有类似数组的响应,但随后响应会像对象一样发生变化,我不理解为什么。函数findBitByProject未更改-返回 $results = $query->getResult(); 我的行动 $bits = $this->getDoctrine()->getManager() ->getRepository('ArtelProfileBundle:Bit') ->findBitByProject($requ

在我早期的行为中,我有类似数组的响应,但随后响应会像对象一样发生变化,我不理解为什么。函数findBitByProject未更改-返回

$results = $query->getResult();
我的行动

    $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;
当我为开发人员关系删除序列化程序组时一切正常

为什么会发生这种情况以及如何解决

尝试以下操作:

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

return $this->handleView($view);
请尝试以下操作:

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

return $this->handleView($view);

请显示包含位或具有关联位集合的项目的“位”classis$位?如果您使用JMSSerializerBundle,请检查此项:请显示包含位或具有关联位集合的项目的“位”classis$位?如果您使用JMSSerializerBundle,请检查此项:
$view = View::create()
    ->setStatusCode(200)
    ->setData($bits)
    ->setSerializationContext(
        SerializationContext::create()
            ->setGroups(
                array('for_project_bit')
            )
    );

return $this->handleView($view);