You have make yours a hybrid api, which is public and will enhance the results if the user is authenticated
One way to do it is as given below. It is using a hidden property in Restler
class Simple
{
/**
* @var \Luracast\Restler\Restler
*/
public $restler;
/**
* @access hybrid
*/
function item($name)
{
if ($name == "somerestricted") {
if ($this->restler->_authenticated) {
// Proceed
} else {
// ???
}
} else {
echo "Hi!";
}
}
}
Another (recommended) way is to use iUseAuthentication Interface
use Luracast\Restler\iUseAuthentication;
class Simple implements iUseAuthentication
{
protected $authenticated;
/**
* @access hybrid
*/
function item($name)
{
if ($name == "somerestricted") {
if ($this->authenticated) {
// Proceed
} else {
// ???
}
} else {
echo "Hi!";
}
}
public function __setAuthenticationStatus($isAuthenticated = false)
{
$this->authenticated = $isAuthenticated;
}
}