mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 15:06:06 +00:00
orm refactoring. preferences
This commit is contained in:
37
application/Espo/Controllers/Preferences.php
Normal file
37
application/Espo/Controllers/Preferences.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use \Espo\Core\Exceptions\Error;
|
||||
use \Espo\Core\Exceptions\Forbidden;
|
||||
use \Espo\Core\Exceptions\NotFound;
|
||||
|
||||
class Preferences extends \Espo\Core\Controllers\Base
|
||||
{
|
||||
protected function getPreferences()
|
||||
{
|
||||
return $this->getContainer()->get('preferences');
|
||||
}
|
||||
|
||||
protected function getEntityManager()
|
||||
{
|
||||
return $this->getContainer()->get('entityManager');
|
||||
}
|
||||
|
||||
public function actionRead($params)
|
||||
{
|
||||
$userId = $params['id'];
|
||||
if (!$this->getUser()->isAdmin()) {
|
||||
if ($this->getUser()->id != $userId) {
|
||||
throw new Forbidden();
|
||||
}
|
||||
}
|
||||
$entity = $this->getEntityManager()->getEntity('Preferences', $userId);
|
||||
if ($entity) {
|
||||
return $entity->toArray();
|
||||
}
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user