const usage
This commit is contained in:
@@ -31,6 +31,7 @@ namespace Espo\Core\FieldProcessing\Stars;
|
||||
|
||||
use Espo\Core\FieldProcessing\Loader;
|
||||
use Espo\Core\FieldProcessing\Loader\Params;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Entities\User;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Tools\Stars\StarService;
|
||||
@@ -48,12 +49,12 @@ class StarLoader implements Loader
|
||||
public function process(Entity $entity, Params $params): void
|
||||
{
|
||||
if (
|
||||
!$entity->hasAttribute('isStarred') ||
|
||||
!$entity->hasAttribute(Field::IS_STARRED) ||
|
||||
!$this->service->isEnabled($entity->getEntityType())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$entity->set('isStarred', $this->service->isStarred($entity, $this->user));
|
||||
$entity->set(Field::IS_STARRED, $this->service->isStarred($entity, $this->user));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\FieldProcessing\Stream;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Acl;
|
||||
use Espo\Core\FieldProcessing\Loader as LoaderInterface;
|
||||
@@ -61,13 +62,13 @@ class FollowersLoader implements LoaderInterface
|
||||
|
||||
public function processIsFollowed(Entity $entity): void
|
||||
{
|
||||
if (!$entity->hasAttribute('isFollowed')) {
|
||||
if (!$entity->hasAttribute(Field::IS_FOLLOWED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$isFollowed = $this->streamService->checkIsFollowed($entity);
|
||||
|
||||
$entity->set('isFollowed', $isFollowed);
|
||||
$entity->set(Field::IS_FOLLOWED, $isFollowed);
|
||||
}
|
||||
|
||||
public function processFollowers(Entity $entity): void
|
||||
@@ -88,7 +89,7 @@ class FollowersLoader implements LoaderInterface
|
||||
|
||||
$data = $this->streamService->getEntityFollowers($entity, 0, $limit);
|
||||
|
||||
$entity->set('followersIds', $data['idList']);
|
||||
$entity->set('followersNames', $data['nameMap']);
|
||||
$entity->set(Field::FOLLOWERS . 'Ids', $data['idList']);
|
||||
$entity->set(Field::FOLLOWERS . 'Names', $data['nameMap']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,4 +40,7 @@ class Field
|
||||
public const COLLABORATORS = 'collaborators';
|
||||
public const TEAMS = 'teams';
|
||||
public const PARENT = 'parent';
|
||||
public const IS_FOLLOWED = 'isFollowed';
|
||||
public const FOLLOWERS = 'followers';
|
||||
public const IS_STARRED = 'isStarred';
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Core\Select\Applier\AdditionalAppliers;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Select\Applier\AdditionalApplier;
|
||||
use Espo\Core\Select\SearchParams;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
@@ -55,7 +56,7 @@ class IsStarred implements AdditionalApplier
|
||||
}
|
||||
|
||||
$queryBuilder
|
||||
->select(Expr::isNotNull(Expr::column('starSubscription.id')), 'isStarred')
|
||||
->select(Expr::isNotNull(Expr::column('starSubscription.id')), Field::IS_STARRED)
|
||||
->leftJoin(StarSubscription::ENTITY_TYPE, 'starSubscription', [
|
||||
'userId' => $this->user->getId(),
|
||||
'entityType' => $this->entityType,
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace Espo\Core\Utils\Database\Orm;
|
||||
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Espo\Core\InjectableFactory;
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\ORM\Defs\AttributeParam;
|
||||
use Espo\Core\ORM\Type\FieldType;
|
||||
use Espo\Core\Utils\Database\ConfigDataProvider;
|
||||
@@ -498,20 +499,20 @@ class Converter
|
||||
$scopeDefs = $this->metadata->get(['scopes', $entityType]) ?? [];
|
||||
|
||||
if ($scopeDefs['stream'] ?? false) {
|
||||
if (!isset($entityMetadata['fields']['isFollowed'])) {
|
||||
$ormMetadata[$entityType]['attributes']['isFollowed'] = [
|
||||
if (!isset($entityMetadata['fields'][Field::IS_FOLLOWED])) {
|
||||
$ormMetadata[$entityType]['attributes'][Field::IS_FOLLOWED] = [
|
||||
'type' => Entity::BOOL,
|
||||
'notStorable' => true,
|
||||
AttributeParam::NOT_EXPORTABLE => true,
|
||||
];
|
||||
|
||||
$ormMetadata[$entityType]['attributes']['followersIds'] = [
|
||||
$ormMetadata[$entityType]['attributes'][Field::FOLLOWERS . 'Ids'] = [
|
||||
'type' => Entity::JSON_ARRAY,
|
||||
'notStorable' => true,
|
||||
AttributeParam::NOT_EXPORTABLE => true,
|
||||
];
|
||||
|
||||
$ormMetadata[$entityType]['attributes']['followersNames'] = [
|
||||
$ormMetadata[$entityType]['attributes'][Field::FOLLOWERS . 'Names'] = [
|
||||
'type' => Entity::JSON_OBJECT,
|
||||
'notStorable' => true,
|
||||
AttributeParam::NOT_EXPORTABLE => true,
|
||||
@@ -521,8 +522,8 @@ class Converter
|
||||
|
||||
// @todo Refactor.
|
||||
if ($scopeDefs['stars'] ?? false) {
|
||||
if (!isset($entityMetadata['fields']['isStarred'])) {
|
||||
$ormMetadata[$entityType]['attributes']['isStarred'] = [
|
||||
if (!isset($entityMetadata['fields'][Field::IS_STARRED])) {
|
||||
$ormMetadata[$entityType]['attributes'][Field::IS_STARRED] = [
|
||||
'type' => Entity::BOOL,
|
||||
'notStorable' => true,
|
||||
AttributeParam::NOT_EXPORTABLE => true,
|
||||
|
||||
@@ -50,7 +50,7 @@ class Manager
|
||||
|
||||
/** @var string[] */
|
||||
protected $skipAttributeList = [
|
||||
'isFollowed',
|
||||
Field::IS_FOLLOWED,
|
||||
Field::MODIFIED_AT,
|
||||
Field::MODIFIED_BY,
|
||||
];
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\Tools\EntityManager;
|
||||
|
||||
use Espo\Core\Name\Field;
|
||||
use Espo\Core\Utils\Config;
|
||||
use Espo\Core\Utils\Metadata;
|
||||
use Espo\Core\Utils\Route;
|
||||
@@ -136,16 +137,17 @@ class NameUtil
|
||||
'deleted',
|
||||
'deleteId',
|
||||
'skipDuplicateCheck',
|
||||
'isFollowed',
|
||||
'isStarred',
|
||||
'versionNumber',
|
||||
'null',
|
||||
'false',
|
||||
'true',
|
||||
'teams',
|
||||
'assignedUser',
|
||||
'assignedUsers',
|
||||
'collaborators',
|
||||
Field::IS_STARRED,
|
||||
Field::IS_FOLLOWED,
|
||||
Field::FOLLOWERS,
|
||||
Field::TEAMS,
|
||||
Field::ASSIGNED_USER,
|
||||
Field::ASSIGNED_USERS,
|
||||
Field::COLLABORATORS,
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -155,7 +157,6 @@ class NameUtil
|
||||
'posts',
|
||||
'stream',
|
||||
'subscription',
|
||||
'followers',
|
||||
'starSubscription',
|
||||
'action',
|
||||
'null',
|
||||
@@ -163,10 +164,11 @@ class NameUtil
|
||||
'true',
|
||||
'layout',
|
||||
'system',
|
||||
'teams',
|
||||
'assignedUser',
|
||||
'assignedUsers',
|
||||
'collaborators',
|
||||
Field::FOLLOWERS,
|
||||
Field::TEAMS,
|
||||
Field::ASSIGNED_USER,
|
||||
Field::ASSIGNED_USERS,
|
||||
Field::COLLABORATORS,
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -389,7 +389,7 @@ class HookProcessor
|
||||
}
|
||||
|
||||
if (in_array($this->user->getId(), $userIdList)) {
|
||||
$entity->set('isFollowed', true);
|
||||
$entity->set(Field::IS_FOLLOWED, true);
|
||||
}
|
||||
|
||||
$autofollowUserIdList = $this->getAutofollowUserIdList($entity->getEntityType(), $userIdList);
|
||||
@@ -465,7 +465,7 @@ class HookProcessor
|
||||
$this->service->followEntity($entity, $userId);
|
||||
|
||||
if ($this->user->getId() === $userId) {
|
||||
$entity->set('isFollowed', true);
|
||||
$entity->set(Field::IS_FOLLOWED, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,7 +487,7 @@ class HookProcessor
|
||||
$this->service->noteAssign($entity, $options);
|
||||
|
||||
if ($this->user->getId() === $assignedUserId) {
|
||||
$entity->set('isFollowed', true);
|
||||
$entity->set(Field::IS_FOLLOWED, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ class HookProcessor
|
||||
$this->service->noteAssign($entity, $options);
|
||||
|
||||
if (in_array($this->user->getId(), $userIds)) {
|
||||
$entity->set('isFollowed', true);
|
||||
$entity->set(Field::IS_FOLLOWED, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user