-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathListener.php
More file actions
39 lines (34 loc) · 925 Bytes
/
Copy pathListener.php
File metadata and controls
39 lines (34 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* Created by PhpStorm.
* User: Andriy
* Date: 12.06.2019
* Time: 22:37
* Made with <3 by West from TechGate Studio
*/
namespace West\ProtectACP;
class Listener
{
/**
* @param \XF\Mvc\Controller $controller
* @param $action
* @param \XF\Mvc\ParameterBag $params
* @throws \XF\Mvc\Reply\Exception
*/
public static function preDispatchAdmin(\XF\Mvc\Controller $controller, $action, \XF\Mvc\ParameterBag $params)
{
if (!$controller->app() instanceof \XF\Admin\App)
{
return;
}
/** @var \XF\Entity\User|null $user */
$user = \XF::em()->find(
'XF:User',
\XF::app()->container('session.public')['userId']
);
if (!$user || !$user->is_admin)
{
throw $controller->exception($controller->redirect(\XF::app()->router('public')->buildLink('index')));
}
}
}