本文整理汇总了PHP中Alchemy\Phrasea\Application::isGuestAllowed方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::isGuestAllowed方法的具体用法?PHP Application::isGuestAllowed怎么用?PHP Application::isGuestAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alchemy\Phrasea\Application
的用法示例。
在下文中一共展示了Application::isGuestAllowed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticateAsGuest
public function authenticateAsGuest(PhraseaApplication $app, Request $request)
{
if (!$app->isGuestAllowed()) {
$app->abort(403, $app->trans('Phraseanet guest-access is disabled'));
}
$context = new Context(Context::CONTEXT_GUEST);
$app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context));
$user = $app['manipulator.user']->createUser(uniqid('guest'), \random::generatePassword(24));
$invite_user = $app['manipulator.user']->getRepository()->findByLogin(User::USER_GUEST);
$usr_base_ids = array_keys($app['acl']->get($user)->get_granted_base());
$app['acl']->get($user)->revoke_access_from_bases($usr_base_ids);
$invite_base_ids = array_keys($app['acl']->get($invite_user)->get_granted_base());
$app['acl']->get($user)->apply_model($invite_user, $invite_base_ids);
$this->postAuthProcess($app, $user);
$response = $this->generateAuthResponse($app, $app['browser'], $request->request->get('redirect'));
$response->headers->setCookie(new Cookie('invite-usr-id', $user->getId()));
$event = new PostAuthenticate($request, $response, $user, $context);
$app['dispatcher']->dispatch(PhraseaEvents::POST_AUTHENTICATE, $event);
return $response;
}