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 51 52 53 54 55
<?php
namespace hji\users\models;
use hji\membership\models\webservice\abstracts\WebService;
use hji\membership\models\webservice\WebServiceOptions;
class UserActionsModel extends WebService
{
private static $_cache;
public function __construct(ActionsSearchFilters $filters, ActionsWebServiceOptions $options)
{
parent::__construct($filters, $options);
}
function search()
{
return $this->_execute('searchActions');
}
function get()
{
return $this->_execute('getActions');
}
private function _execute($method)
{
$params = $this->getParameters();
if (!empty($params))
{
if (!self::$_cache[$this->_hash($params)])
{
$apiClient = $this->getServiceContainer()->getApiClient();
$result = $apiClient->$method($params);
self::$_cache[$this->_hash($params)] = $result;
}
return self::$_cache[$this->_hash($params)];
}
}
private function _hash($value)
{
return md5(serialize($value));
}
}