php-censor/src/PHPCensor/Helper/User.php

33 lines
667 B
PHP
Raw Normal View History

2013-05-10 17:25:51 +02:00
<?php
2016-07-19 20:28:11 +02:00
namespace PHPCensor\Helper;
2013-05-10 17:25:51 +02:00
/**
2017-03-04 16:39:56 +01:00
* User Helper - Provides access to logged in user information in views.
*
* @author Dan Cryer <dan@block8.co.uk>
*/
2013-05-10 17:25:51 +02:00
class User
{
/**
* Proxies method calls through to the current active user model.
* @param $method
* @param array $params
* @return mixed|null
*/
2016-04-20 17:39:48 +02:00
public function __call($method, $params = [])
{
2016-12-24 10:58:38 +01:00
if (empty($_SESSION['php-censor-user'])) {
return null;
}
2016-07-21 19:02:11 +02:00
$user = $_SESSION['php-censor-user'];
if (!is_object($user)) {
return null;
}
2016-04-20 17:39:48 +02:00
return call_user_func_array([$user, $method], $params);
}
}