fix stream parent fields load
This commit is contained in:
@@ -527,16 +527,10 @@ class Stream extends \Espo\Core\Services\Base
|
||||
|
||||
foreach ($collection as $e) {
|
||||
if ($e->get('parentId') && $e->get('parentType')) {
|
||||
$entity = $this->getEntityManager()->getEntity($e->get('parentType'), $e->get('parentId'));
|
||||
if ($entity) {
|
||||
$e->set('parentName', $entity->get('name'));
|
||||
}
|
||||
$e->loadParentNameField('parent');
|
||||
}
|
||||
if ($e->get('relatedId') && $e->get('relatedType')) {
|
||||
$entity = $this->getEntityManager()->getEntity($e->get('relatedType'), $e->get('relatedId'));
|
||||
if ($entity) {
|
||||
$e->set('relatedName', $entity->get('name'));
|
||||
}
|
||||
$e->loadParentNameField('related');
|
||||
}
|
||||
if ($e->get('type') == 'Post' && $e->get('parentId') === null && !$e->get('isGlobal')) {
|
||||
$targetType = $e->get('targetType');
|
||||
@@ -658,17 +652,11 @@ class Stream extends \Espo\Core\Services\Base
|
||||
($e->get('parentId') != $id) ||
|
||||
($e->get('parentType') != $scope)
|
||||
) {
|
||||
$parent = $this->getEntityManager()->getEntity($e->get('parentType'), $e->get('parentId'));
|
||||
if ($parent) {
|
||||
$e->set('parentName', $parent->get('name'));
|
||||
}
|
||||
$e->loadParentNameField('parent');
|
||||
}
|
||||
}
|
||||
if ($e->get('relatedId') && $e->get('relatedType')) {
|
||||
$entity = $this->getEntityManager()->getEntity($e->get('relatedType'), $e->get('relatedId'));
|
||||
if ($entity) {
|
||||
$e->set('relatedName', $entity->get('name'));
|
||||
}
|
||||
$e->loadParentNameField('related');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1003,9 +991,11 @@ class Stream extends \Espo\Core\Services\Base
|
||||
$wasParentType = $was[$field . 'Type'];
|
||||
$wasParentId = $was[$field . 'Id'];
|
||||
if ($wasParentType && $wasParentId) {
|
||||
$wasParent = $this->getEntityManager()->getEntity($wasParentType, $wasParentId);
|
||||
if ($wasParent) {
|
||||
$was[$field . 'Name'] = $wasParent->get('name');
|
||||
if ($this->getEntityManager()->hasRepository($wasParentType)) {
|
||||
$wasParent = $this->getEntityManager()->getEntity($wasParentType, $wasParentId);
|
||||
if ($wasParent) {
|
||||
$was[$field . 'Name'] = $wasParent->get('name');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +1013,7 @@ class Stream extends \Espo\Core\Services\Base
|
||||
'fields' => $updatedFieldList,
|
||||
'attributes' => array(
|
||||
'was' => $was,
|
||||
'became' => $became,
|
||||
'became' => $became
|
||||
)
|
||||
));
|
||||
|
||||
@@ -1127,6 +1117,9 @@ class Stream extends \Espo\Core\Services\Base
|
||||
if (empty($data->entityId) || empty($data->entityType)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$this->getEntityManager()->hasRepository($data->entityType)) return;
|
||||
|
||||
$entity = $this->getEntityManager()->getEntity($data->entityType, $data->entityId);
|
||||
if (!$entity) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user