public function getUser($apiKey = null)
{
// get the logged user
$user = parent::getUser();
if (null === $user) {
// if the logged user doesn't exist, check if there's an api key
if (null !== $apiKey) {
$em = $this->getDoctrine()->getEntityManager();
$user = $em->getRepository("ZeegaDataBundle:User")->findOneBy(array("apiKey" => $apiKey));
if (null !== $user) {
return $user;
}
}
} else {
if ($this->container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) {
return $user;
}
}
return null;
}