public function handle(UserFollow $follow)
 {
     /* @var $entity UserFollow */
     $entity = $this->findOneBy(['user' => $follow->getUser(), 'follower' => $follow->getFollower()]);
     $entity = $entity ?: $follow;
     $entity->setStatus($follow->getStatus())->setDateCreate(new \DateTime());
     $this->getEntityManager()->persist($entity);
     $this->getEntityManager()->flush($entity);
     return $entity;
 }
 /**
  * @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);
 }
 public function getStatus()
 {
     $this->__load();
     return parent::getStatus();
 }