本文整理汇总了PHP中SessionController::InvalidateCache方法的典型用法代码示例。如果您正苦于以下问题:PHP SessionController::InvalidateCache方法的具体用法?PHP SessionController::InvalidateCache怎么用?PHP SessionController::InvalidateCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SessionController
的用法示例。
在下文中一共展示了SessionController::InvalidateCache方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: apiUpdate
/**
* Update user profile
*
* @param Request $r
* @return array
* @throws InvalidDatabaseOperationException
* @throws InvalidParameterException
*/
public static function apiUpdate(Request $r)
{
self::authenticateRequest($r);
Validators::isStringNonEmpty($r['name'], 'name', false);
Validators::isStringNonEmpty($r['country_id'], 'country_id', false);
if (!is_null($r['country_id'])) {
try {
$r['country'] = CountriesDAO::getByPK($r['country_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
if ($r['state_id'] === 'null') {
$r['state_id'] = null;
}
Validators::isNumber($r['state_id'], 'state_id', false);
if (!is_null($r['state_id'])) {
try {
$r['state'] = StatesDAO::getByPK($r['state_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
if (!is_null($r['school_id'])) {
if (is_numeric($r['school_id'])) {
try {
$r['school'] = SchoolsDAO::getByPK($r['school_id']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
if (is_null($r['school'])) {
throw new InvalidParameterException('parameterInvalid', 'school');
}
} elseif (empty($r['school_name'])) {
$r['school_id'] = null;
} else {
try {
$schoolR = new Request(array('name' => $r['school_name'], 'state_id' => $r['state_id'], 'auth_token' => $r['auth_token']));
$response = SchoolController::apiCreate($schoolR);
$r['school_id'] = $response['school_id'];
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
}
}
Validators::isStringNonEmpty($r['scholar_degree'], 'scholar_degree', false);
if (!is_null($r['graduation_date'])) {
if (is_numeric($r['graduation_date'])) {
$r['graduation_date'] = (int) $r['graduation_date'];
} else {
Validators::isDate($r['graduation_date'], 'graduation_date', false);
$r['graduation_date'] = strtotime($r['graduation_date']);
}
}
if (!is_null($r['birth_date'])) {
if (is_numeric($r['birth_date'])) {
$r['birth_date'] = (int) $r['birth_date'];
} else {
Validators::isDate($r['birth_date'], 'birth_date', false);
$r['birth_date'] = strtotime($r['birth_date']);
}
}
if (!is_null($r['locale'])) {
// find language in Language
$query = LanguagesDAO::search(new Languages(array('name' => $r['locale'])));
if (sizeof($query) == 1) {
$r['current_user']->setLanguageId($query[0]->getLanguageId());
}
}
$valueProperties = array('name', 'country_id', 'state_id', 'scholar_degree', 'school_id', 'graduation_date' => array('transform' => function ($value) {
return gmdate('Y-m-d', $value);
}), 'birth_date' => array('transform' => function ($value) {
return gmdate('Y-m-d', $value);
}));
self::updateValueProperties($r, $r['current_user'], $valueProperties);
try {
UsersDAO::save($r['current_user']);
} catch (Exception $e) {
throw new InvalidDatabaseOperationException($e);
}
// Expire profile cache
Cache::deleteFromCache(Cache::USER_PROFILE, $r['current_user']->getUsername());
$sessionController = new SessionController();
$sessionController->InvalidateCache();
return array('status' => 'ok');
}