コード例 #1
0
 private function createAKeyword($label, KeyWord $parent = null)
 {
     $keyword = new KeyWord();
     $keyword->setKeyWord($label);
     if ($parent instanceof KeyWord) {
         $keyword->setParent($parent);
     }
     $this->em->persist($keyword);
     $this->em->flush($keyword);
     return $keyword;
 }
コード例 #2
0
ファイル: KeyWordTest.php プロジェクト: gobjila/BackBee
 /**
  * Sets up the fixture.
  */
 public function setUp()
 {
     $this->current_time = new \Datetime();
     $this->keyword = new KeyWord('test');
     $this->keyword->setKeyWord('test');
 }
コード例 #3
0
 /**
  * @return Response
  *
  * @Rest\RequestParam(name="keyword", description="Keyword value", requirements={
  *      @Assert\NotBlank()
  * })
  * @Rest\ParamConverter(name="keyword", class="BackBee\NestedNode\KeyWord")
  * @Rest\Security("is_fully_authenticated() & has_role('ROLE_API_USER')")
  */
 public function putAction(KeyWord $keyword, Request $request)
 {
     try {
         $keywordLabel = trim($request->request->get('keyword'));
         if ($this->keywordAlreadyExists($keywordLabel, $keyword->getUid())) {
             throw new BadRequestHttpException('KEYWORD_ALREADY_EXISTS');
         }
         $keyword->setKeyWord($keywordLabel);
         $this->getEntityManager()->persist($keyword);
         $this->getEntityManager()->flush();
         $response = $this->createJsonResponse(null, 204);
     } catch (\Exception $e) {
         $response = $this->createErrorResponse($e);
     }
     return $response;
 }