]> git.mxchange.org Git - friendica.git/blob - src/Module/Security/Logout.php
Merge pull request #8142 from nupplaphil/task/di_config
[friendica.git] / src / Module / Security / Logout.php
1 <?php
2 /**
3  * @file src/Module/Logout.php
4  */
5
6 namespace Friendica\Module\Security;
7
8 use Friendica\BaseModule;
9 use Friendica\Core\Hook;
10 use Friendica\Core\System;
11 use Friendica\DI;
12 use Friendica\Model\Profile;
13
14 /**
15  * Logout module
16  *
17  * @author Hypolite Petovan <hypolite@mrpetovan.com>
18  */
19 class Logout extends BaseModule
20 {
21         /**
22          * Process logout requests
23          */
24         public static function init(array $parameters = [])
25         {
26                 $visitor_home = null;
27                 if (remote_user()) {
28                         $visitor_home = Profile::getMyURL();
29                         DI::cache()->delete('zrlInit:' . $visitor_home);
30                 }
31
32                 Hook::callAll("logging_out");
33                 DI::cookie()->clear();
34                 DI::session()->clear();
35
36                 if ($visitor_home) {
37                         System::externalRedirect($visitor_home);
38                 } else {
39                         info(DI::l10n()->t('Logged out.'));
40                         DI::baseUrl()->redirect();
41                 }
42         }
43 }