forked from scandio/lmvc-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnonymousController.php
More file actions
50 lines (42 loc) · 1.21 KB
/
AnonymousController.php
File metadata and controls
50 lines (42 loc) · 1.21 KB
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
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Scandio\lmvc\modules\security;
use Scandio\lmvc\Controller;
use Scandio\lmvc\utils\config\Config;
use Scandio\lmvc\modules\rendering\traits;
class AnonymousController extends Controller
{
use traits\RendererController;
/**
* @var AbstractUser
*/
protected static $currentUser;
/**
* @var string
*/
protected static $controllerRole = 'anonymous';
/**
* @return bool
*/
public static function preProcess()
{
if (!parent::preProcess()) {
return false;
}
static::$currentUser = Security::get()->currentUser();
return true;
}
public static function render($renderArgs = array(), $httpCode = 200, $template = null, $masterTemplate = null)
{
static::setRenderArg('currentUser', static::$currentUser);
return static::renderEngine('php', $renderArgs, ['minor' => $template], $httpCode);
}
/**
* @return bool
*/
public static function forbidden()
{
$forbiddenAction = (isset(Config::get()->security->forbiddenAction)) ? Config::get()->security->forbiddenAction : 'Security::forbidden';
static::redirect($forbiddenAction);
return false;
}
}