示例#1
0
 /**
  * @View(serializerGroups={"Default"})
  * @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')")
  * @param integer $id id of the remark
  * @ApiDoc(
  *  section="Responses",
  *  description="Add response",
  *  input="LKE\RemarkBundle\Form\Type\ResponseType",
  *  output={
  *      "class"="LKE\RemarkBundle\Entity\Response",
  *      "groups"={"Default"}
  *  }
  * )
  */
 public function postRemarkResponseAction(Request $request, $id)
 {
     $response = new Response();
     $remark = $this->getEntity($id, Voter::VIEW, ["repository" => "LKERemarkBundle:Remark"]);
     $response->setRemark($remark);
     $response->setAuthor($this->getUser());
     return $this->formResponse($response, $request, "post");
 }
示例#2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $parser = $this->getContainer()->get('lke_core.parse_csv');
     $rows = $parser->parse(self::FILE);
     foreach ($rows as $row) {
         $response = new Response();
         $response->setSentence(substr($row[self::SENTENCE], 0, 140));
         $response->setPostedAt($this->getDateTime($row[self::POSTEDAT]));
         $response->setRemark($this->getRemark($row[self::REMARK_ID]));
         $response->setAuthor($this->getUser($row[self::USER_ID]));
         $em->persist($response);
     }
     $em->flush();
     $output->writeln("Responses loaded");
 }