Merge pull request #40 from ThomasRubini/kernel_utils
This commit is contained in:
commit
3567dea8c5
@ -21,16 +21,10 @@ final class UserController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getOrDie($DICT, $key)
|
|
||||||
{
|
|
||||||
if (isset($DICT[$key])) return $DICT[$key];
|
|
||||||
else die("Key $key not present");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function signInAction(Array $A_urlParams = null, Array $A_postParams = null)
|
public function signInAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
{
|
{
|
||||||
$S_email = self::getOrDie($A_postParams, "email");
|
$S_email = Utils::getOrDie($A_postParams, "email");
|
||||||
$S_password = self::getOrDie($A_postParams, "password");
|
$S_password = Utils::getOrDie($A_postParams, "password");
|
||||||
|
|
||||||
$O_userModel = new UserModel();
|
$O_userModel = new UserModel();
|
||||||
$A_user = $O_userModel->getUserByEmail($S_email);
|
$A_user = $O_userModel->getUserByEmail($S_email);
|
||||||
@ -56,9 +50,9 @@ final class UserController
|
|||||||
|
|
||||||
public function signUpAction(Array $A_urlParams = null, Array $A_postParams = null)
|
public function signUpAction(Array $A_urlParams = null, Array $A_postParams = null)
|
||||||
{
|
{
|
||||||
$S_email = self::getOrDie($A_postParams, "email");
|
$S_email = Utils::getOrDie($A_postParams, "email");
|
||||||
$S_username = self::getOrDie($A_postParams, "username");
|
$S_username = Utils::getOrDie($A_postParams, "username");
|
||||||
$S_password = self::getOrDie($A_postParams, "password");
|
$S_password = Utils::getOrDie($A_postParams, "password");
|
||||||
|
|
||||||
$O_userModel = new UserModel();
|
$O_userModel = new UserModel();
|
||||||
|
|
||||||
|
12
Kernel/Utils.php
Normal file
12
Kernel/Utils.php
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
final class Utils
|
||||||
|
{
|
||||||
|
|
||||||
|
public static function getOrDie($DICT, $key)
|
||||||
|
{
|
||||||
|
if (isset($DICT[$key])) return $DICT[$key];
|
||||||
|
else die("Key $key not present");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user