mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
ref
This commit is contained in:
@@ -35,14 +35,13 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Services\Layout as Service;
|
||||
use Espo\Tools\Layout\Service as Service;
|
||||
use Espo\Entities\User;
|
||||
|
||||
class Layout
|
||||
{
|
||||
private $user;
|
||||
|
||||
private $service;
|
||||
private User $user;
|
||||
private Service $service;
|
||||
|
||||
public function __construct(User $user, Service $service)
|
||||
{
|
||||
|
||||
@@ -30,21 +30,32 @@
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
|
||||
use Espo\Services\Metadata as Service;
|
||||
|
||||
use Espo\Core\{
|
||||
Controllers\Base,
|
||||
Api\Request,
|
||||
};
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Utils\Metadata as MetadataUtil;
|
||||
use Espo\Entities\User as UserEntity;
|
||||
use Espo\Tools\App\MetadataService as Service;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Metadata extends Base
|
||||
class Metadata
|
||||
{
|
||||
private Service $service;
|
||||
private MetadataUtil $metadata;
|
||||
private UserEntity $user;
|
||||
|
||||
public function __construct(
|
||||
Service $service,
|
||||
MetadataUtil $metadata,
|
||||
UserEntity $user
|
||||
) {
|
||||
$this->service = $service;
|
||||
$this->metadata = $metadata;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
public function getActionRead(): stdClass
|
||||
{
|
||||
return $this->getMetadataService()->getDataForFrontend();
|
||||
return $this->service->getDataForFrontend();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,10 +72,4 @@ class Metadata extends Base
|
||||
|
||||
return $this->metadata->get($key, false);
|
||||
}
|
||||
|
||||
private function getMetadataService(): Service
|
||||
{
|
||||
/** @var Service */
|
||||
return $this->getServiceFactory()->create('Metadata');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Api\Request;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Services\Settings as Service;
|
||||
use Espo\Tools\App\SettingsService as Service;
|
||||
use Espo\Entities\User;
|
||||
|
||||
use stdClass;
|
||||
|
||||
@@ -33,7 +33,7 @@ use Espo\Entities\DashboardTemplate;
|
||||
use Espo\Entities\EmailAccount as EmailAccountEntity;
|
||||
use Espo\Entities\InboundEmail as InboundEmailEntity;
|
||||
use Espo\Entities\Settings;
|
||||
use Espo\Services\Settings as SettingsService;
|
||||
use Espo\Tools\App\SettingsService as SettingsService;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Authentication\Logins\Espo;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\App;
|
||||
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Utils\Metadata as MetadataUtil;
|
||||
@@ -36,13 +36,11 @@ use Espo\Entities\User;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Metadata
|
||||
class MetadataService
|
||||
{
|
||||
private $acl;
|
||||
|
||||
private $metadata;
|
||||
|
||||
private $user;
|
||||
private Acl $acl;
|
||||
private MetadataUtil $metadata;
|
||||
private User $user;
|
||||
|
||||
public function __construct(Acl $acl, MetadataUtil $metadata, User $user)
|
||||
{
|
||||
@@ -27,7 +27,7 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\App;
|
||||
|
||||
use Espo\Core\Authentication\Logins\Espo;
|
||||
use Espo\ORM\Entity;
|
||||
@@ -52,7 +52,7 @@ use Espo\Repositories\Portal as PortalRepository;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Settings
|
||||
class SettingsService
|
||||
{
|
||||
private ApplicationState $applicationState;
|
||||
private Config $config;
|
||||
@@ -27,66 +27,38 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Services;
|
||||
namespace Espo\Tools\Layout;
|
||||
|
||||
use Espo\Entities\LayoutRecord;
|
||||
|
||||
use Espo\Core\{
|
||||
Exceptions\NotFound,
|
||||
Exceptions\Forbidden,
|
||||
Exceptions\Error,
|
||||
Acl,
|
||||
Acl\Exceptions\NotImplemented,
|
||||
Utils\Layout as LayoutUtil,
|
||||
ORM\EntityManager,
|
||||
Utils\Metadata,
|
||||
DataManager,
|
||||
Utils\Json,
|
||||
};
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\Acl\Exceptions\NotImplemented;
|
||||
use Espo\Core\DataManager;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\NotFound;
|
||||
use Espo\Core\ORM\EntityManager;
|
||||
use Espo\Core\Utils\Json;
|
||||
use Espo\Core\Utils\Layout as LayoutUtil;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
|
||||
use Espo\{
|
||||
Entities\User,
|
||||
Tools\LayoutManager\LayoutManager,
|
||||
};
|
||||
use Espo\Entities\LayoutSet;
|
||||
use Espo\Entities\Portal as PortalEntity;
|
||||
use Espo\Entities\Team as TeamEntity;
|
||||
use Espo\Entities\User;
|
||||
use Espo\Tools\LayoutManager\LayoutManager;
|
||||
|
||||
use stdClass;
|
||||
|
||||
class Layout
|
||||
class Service
|
||||
{
|
||||
/**
|
||||
* @var Acl
|
||||
*/
|
||||
protected $acl;
|
||||
|
||||
/**
|
||||
* @var LayoutUtil
|
||||
*/
|
||||
protected $layout;
|
||||
|
||||
/**
|
||||
* @var LayoutManager
|
||||
*/
|
||||
protected $layoutManager;
|
||||
|
||||
/**
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* @var Metadata
|
||||
*/
|
||||
protected $metadata;
|
||||
|
||||
/**
|
||||
* @var DataManager
|
||||
*/
|
||||
protected $dataManager;
|
||||
|
||||
/**
|
||||
* @var User
|
||||
*/
|
||||
protected $user;
|
||||
private Acl $acl;
|
||||
private LayoutUtil $layout;
|
||||
private LayoutManager $layoutManager;
|
||||
private EntityManager $entityManager;
|
||||
private Metadata $metadata;
|
||||
private DataManager $dataManager;
|
||||
private User $user;
|
||||
|
||||
public function __construct(
|
||||
Acl $acl,
|
||||
@@ -169,7 +141,7 @@ class Layout
|
||||
|
||||
if ($portalId) {
|
||||
$portal = $em
|
||||
->getRDBRepository('Portal')
|
||||
->getRDBRepositoryByClass(PortalEntity::class)
|
||||
->select(['layoutSetId'])
|
||||
->where(['id' => $portalId])
|
||||
->findOne();
|
||||
@@ -183,7 +155,7 @@ class Layout
|
||||
|
||||
if ($teamId) {
|
||||
$team = $em
|
||||
->getRDBRepository('Team')
|
||||
->getRDBRepositoryByClass(TeamEntity::class)
|
||||
->select(['layoutSetId'])
|
||||
->where(['id' => $teamId])
|
||||
->findOne();
|
||||
@@ -270,9 +242,9 @@ class Layout
|
||||
bool $skipCheck = false
|
||||
): ?LayoutRecord {
|
||||
|
||||
$em = $this->entityManager;
|
||||
$entityManager = $this->entityManager;
|
||||
|
||||
$layoutSet = $em->getEntity('LayoutSet', $setId);
|
||||
$layoutSet = $entityManager->getEntityById(LayoutSet::ENTITY_TYPE, $setId);
|
||||
|
||||
if (!$layoutSet) {
|
||||
throw new NotFound("LayoutSet {$setId} not found.");
|
||||
@@ -290,15 +262,13 @@ class Layout
|
||||
throw new NotFound("Layout {$fullName} is no allowed in set.");
|
||||
}
|
||||
|
||||
$layout = $em
|
||||
->getRDBRepository('LayoutRecord')
|
||||
return $entityManager
|
||||
->getRDBRepositoryByClass(LayoutRecord::class)
|
||||
->where([
|
||||
'layoutSetId' => $setId,
|
||||
'name' => $fullName,
|
||||
])
|
||||
->findOne();
|
||||
|
||||
return $layout;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -313,7 +283,7 @@ class Layout
|
||||
$layout = $this->getRecordFromSet($scope, $name, $setId);
|
||||
|
||||
if (!$layout) {
|
||||
$layout = $this->entityManager->getNewEntity('LayoutRecord');
|
||||
$layout = $this->entityManager->getNewEntity(LayoutRecord::ENTITY_TYPE);
|
||||
|
||||
$layout->set([
|
||||
'layoutSetId' => $setId,
|
||||
@@ -36,7 +36,7 @@ use Espo\Core\{
|
||||
Record\UpdateParams,
|
||||
};
|
||||
|
||||
use Espo\Services\Settings as SettingsService;
|
||||
use Espo\Tools\App\SettingsService as SettingsService;
|
||||
|
||||
class FieldValidationTest extends \tests\integration\Core\BaseTestCase
|
||||
{
|
||||
@@ -400,8 +400,7 @@ class FieldValidationTest extends \tests\integration\Core\BaseTestCase
|
||||
|
||||
public function testSettings()
|
||||
{
|
||||
/* @var $service SettingsService */
|
||||
$service = $this->getContainer()->get('serviceFactory')->create('Settings');
|
||||
$service = $this->getContainer()->get('injectableFactory')->create(SettingsService::class);
|
||||
|
||||
$this->expectException(BadRequest::class);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user