/**
  * @Route("/{id}")
  * @Method("PUT")
  */
 public function putAction(UserFollow $follow, Request $request)
 {
     if ($this->getUser() !== $follow->getUser()) {
         throw new AccessDeniedHttpException();
     }
     $data = json_decode($request->getContent(), true);
     if (!empty($data) && isset($data['status'])) {
         $follow->setStatus($data['status']);
         if ($follow->getStatus() === $follow::STATUS_ACTIVE) {
             $follow->setDateApproval(new \DateTime());
         }
     }
     $this->getDoctrine()->getManager()->flush($follow);
     return $this->createJSONResponse($this->jmsSerialization($follow, ['api-follow', 'api-info']), 200);
 }
Пример #2
0
 private function createUserFollow(User $user, User $follower)
 {
     $followEntity = new \Civix\CoreBundle\Entity\UserFollow();
     $followEntity->setStatus(\Civix\CoreBundle\Entity\UserFollow::STATUS_PENDING)->setDateCreate(new \DateTime())->setFollower($follower)->setUser($user);
     return $followEntity;
 }
 public function setStatus($status)
 {
     $this->__load();
     return parent::setStatus($status);
 }