我正在使用Symfony 2.1应用程序,我有很多参数通过POST请求发送,我正在寻找一种更智能的方法来获取每个请求参数并填充我的实体类.我希望避免$entity->setMyParam($my_param)为n请求参数编写表达式.例如,这是我的实体的片段:
namespace Brea\ApiBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Brea\ApiBundle\Entity\Distributions
*
* @ORM\Table(name="distributions")
* @ORM\Entity
*/
class Distributions
{
/**
* @var string $recordType
*
* @ORM\Column(name="record_type", type="string", nullable=false)
* @Assert\NotBlank()
* @Assert\Choice(choices = {"a", "b", "c", "d", "e"}, message = "Choose a valid record type")
*/
private $recordType;
/**
* Set recordType
*
* @param string $recordType
*/
public function setRecordType($recordType)
{
$this->recordType = $recordType;
}
/**
* …Run Code Online (Sandbox Code Playgroud)