controller refactoring

This commit is contained in:
Yuri Kuznetsov
2020-06-29 14:29:33 +03:00
parent 9d3fbf8d27
commit 7753eb32af

View File

@@ -29,27 +29,33 @@
namespace Espo\Controllers;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\BadRequest;
class DataPrivacy extends \Espo\Core\Controllers\Base
use Espo\Core\ServiceFactory;
use Espo\Core\Acl;
class DataPrivacy
{
protected function checkControllerAccess()
protected $serviceFactory;
protected $acl;
public function __construct(ServiceFactory $serviceFactory, Acl $acl)
{
if ($this->getAcl()->get('dataPrivacyPermission') === 'no') {
$this->serviceFactory = $serviceFactory;
$this->acl = $acl;
if ($this->acl->get('dataPrivacyPermission') === 'no') {
throw new Forbidden();
}
}
public function postActionErase($params, $data)
public function postActionErase($params, \StdClass $data)
{
if (empty($data->entityType) || empty($data->id) || empty($data->fieldList) || !is_array($data->fieldList)) {
throw new BadRequest();
}
return $this->getServiceFactory()->create('DataPrivacy')->erase($data->entityType, $data->id, $data->fieldList);
return $this->serviceFactory->create('DataPrivacy')->erase($data->entityType, $data->id, $data->fieldList);
}
}