add phone / linkedin / twitter … field for API form
This commit is contained in:
@@ -14,6 +14,8 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use JMS\Serializer\SerializationContext;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class PushController extends FOSRestController
|
||||
{
|
||||
@@ -29,4 +31,29 @@ class PushController extends FOSRestController
|
||||
|
||||
return new JsonResponse(array('isUserSubscribed' => $isUserSubscribed));
|
||||
}
|
||||
|
||||
/**
|
||||
* @Rest\Post("/api/userSubscriptionToPush", name="postUserSubscriptionToPush")
|
||||
* @Rest\View(statusCode=200)
|
||||
*/
|
||||
public function saveSubscription(Request $request)
|
||||
{
|
||||
$user = $this->getUser();
|
||||
$subscription = json_decode($request->getContent(), true);
|
||||
|
||||
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||
throw new BadRequestHttpException(json_last_error_msg());
|
||||
}
|
||||
if (!isset($subscription['endpoint'])) {
|
||||
throw new BadRequestHttpException('Invalid subscription object.');
|
||||
}
|
||||
|
||||
$manager = $this->container->get("app.user_subscription_manager");
|
||||
$subscriptionHash = $manager->hash($subscription['endpoint']);
|
||||
$userSubscription = $manager->getUserSubscription($user, $subscriptionHash)
|
||||
or $userSubscription = $manager->factory($user, $subscriptionHash, $subscription);
|
||||
$manager->save($userSubscription);
|
||||
|
||||
return new JsonResponse(array('success' => true),200);
|
||||
}
|
||||
}
|
||||
@@ -187,7 +187,7 @@ class CompanyController extends Controller
|
||||
$history->recordIt("Anonymous", "r", 'AppBundle\Entity\Company', $company->getId(), serialize($company));
|
||||
}
|
||||
|
||||
return new JsonResponse(array('code' => "ok"));
|
||||
return new JsonResponse(array('code' => "ok", "user" => $this->getUser()->getUsername()));
|
||||
}
|
||||
|
||||
/***********************
|
||||
|
||||
@@ -373,7 +373,12 @@ class User extends BaseUser
|
||||
"lastname" => $this->getLastname(),
|
||||
"email" => $this->getEmail(),
|
||||
"picture" => $this->getPhoto(),
|
||||
"socialPicture" => $this->getSocialPicture()
|
||||
"socialPicture" => $this->getSocialPicture(),
|
||||
"phone" => $this->getCompany()->getPhoneTalent(),
|
||||
"linkedin" => $this->getCompany()->getLinkedin(),
|
||||
"twitter" => $this->getCompany()->getTwitter(),
|
||||
"situationTalent" => $this->getCompany()->getSituationTalent(),
|
||||
"website" => $this->getCompany()->getWebsite(),
|
||||
);
|
||||
return $card;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user