0

在 Symony 2.3.0 中,我可以使用以下命令创建实体和快捷符号:

php app/console generate:doctrine:entity --entity=TravelTravelBundle:User

根据Symfony 的文档,这会创建一个实体快捷方式,可以使用以下函数在默认控制器中调用它:

public function ReturnUserAction($Username)
    {

        $userobject = $this->getDoctrine()
            ->getRepository('TravelTravelBundle:User')
            ->findByusername($Username);
        if($userobject != NULL) {
            return $this->render('TravelTravelBundle:Default:User.html.twig', 
                array(
                'username' => $userobject[0]->getUsername(),
                'email' => $userobject[0]->getEmail(),
                'fn' => $userobject[0]->getFn(),
                'sn' => $userobject[0]->getSn(),
                'password' => $userobject[0]->getPassword(),
                )
            );  
        }
        if(!isset($userobject) || $userobject == NULL || $userobject == "") {
            throw new NotFoundHttpException("The Username:\"$Username\" does not exist");
        }
    }

如何将此实体的快捷表示法更改为 TravelTravel:Username,而不是TravelTravelUser不擦除当前实体并生成新实体?

4

0 回答 0