$this->_facebookSession = $this->isSessionLongLived($facebookSession) ? $facebookSession->getLongLivedSession() : $facebookSession;
$this->_facebookRequest = (new FacebookRequest($this->_facebookSession, 'GET', '/me?fields=hometown,first_name,last_name'))->execute();
-
+
$id = $this->_facebookRequest->getGraphObject(GraphUser::className())->getId();
// If the user is not in the DB, create them.
private function registerUser()
{
$userProfile = $this->_facebookRequest->getGraphObject(GraphUser::className());
-
+
$homeTownPageId = $userProfile->getProperty('hometown')->getProperty('id');
$pageRequest = (new FacebookRequest($this->_facebookSession, 'GET', '/' . $homeTownPageId ))->execute();
$pageLocation = $pageRequest->getGraphObject(GraphLocation::className())->getProperty('location')->cast(GraphLocation::className());
$firstName = $userProfile->getFirstName();
$lastName = $userProfile->getLastName();
$facebookId = $userProfile->getId();
-
+
//TODO: Is insantiating the VO classes here a good idea?
$newUser = $this->_userStepByStepBuilder->With_Country(new \Domain\VOs\Country($country))
->With_DisplayName($firstName)
->With_Tags(array())
->With_FacebookId($facebookId)
->build();
-
- $newUser->setAuthToken($this->_facebookSession->getToken());
-
+
$this->_userRepository->save($newUser);
-
+
return $newUser;
}
public function save(IDivineEntity $entity)\r
{\r
$queries = AbstractPopulationHelper::generateUpdateSaveQuery($this->_maps, $entity, $entity->getId(), $this->_db);\r
- \r
+\r
$flattened = array();\r
$flattened_tables = array();\r
foreach($queries as $index => $query)\r
{\r
$this_table = $query['table'];\r
$this_columns = $query['columns'];\r
- $add = false;\r
\r
for($i = $index+1; $i<count($queries); $i++)\r
{\r
- if($queries[$i]['table'] == $this_table && !in_array($queries[$i]['table'], $flattened_tables) && isset($query['id'])) //only merge create queries, updates are fine to run multiple times\r
+ if($queries[$i]['table'] == $this_table && !in_array($queries[$i]['table'], $flattened_tables) && !isset($query['id'])) //only merge create queries, updates are fine to run multiple times\r
{\r
$this_columns = array_merge($this_columns, $queries[$i]['columns']);\r
- $add = true;\r
}\r
}\r
\r
//TODO: Config this\r
header("Access-Control-Allow-Origin: http://172.17.12.110:8000");\r
header("Access-Control-Allow-Origin: http://roll.divinelegy.meeples:8000");\r
+header("Access-Control-Allow-Origin: http://roll.divinelegy.dev:8000");\r
\r
require_once('../vendor/autoload.php');\r
\r