deprecate createCollection

This commit is contained in:
Yuri Kuznetsov
2021-06-08 17:20:09 +03:00
parent 5a65ee5254
commit aa3d09a55c
4 changed files with 19 additions and 6 deletions
@@ -33,6 +33,9 @@ use Espo\Core\Exceptions\NotFound;
class Document extends \Espo\Services\Record
{
/**
* @return iterable
*/
public function getAttachmentList(string $id)
{
$entity = $this->getEntity($id);
@@ -51,9 +54,14 @@ class Document extends \Espo\Services\Record
throw new NotFound();
}
$attachment = $this->getEntityManager()->getRepository('Attachment')->getCopiedAttachment($file, 'Attachment');
$attachment = $this->entityManager
->getRepository('Attachment')
->getCopiedAttachment($file, 'Attachment');
$attachmentList = $this->entityManager
->getCollectionFactory()
->create('Attachment');
$attachmentList = $this->getEntityManager()->createCollection('Attachment');
$attachmentList[] = $attachment;
return $attachmentList;
@@ -308,7 +308,9 @@ class TargetList extends \Espo\Services\Record implements
$sth = $em->getQueryExecutor()->execute($unionQuery);
$collection = $this->getEntityManager()->createCollection();
$collection = $this->entityManager
->getCollectionFactory()
->create();
while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
$itemEntity = $this->getEntityManager()->getEntity($row['entityType']);
+1 -1
View File
@@ -476,7 +476,7 @@ class EntityManager
}
/**
* Create a collection. An entity type can be omitted.
* @deprecated Use `getCollectionFactory`.
*/
public function createCollection(?string $entityType = null, array $data = []): EntityCollection
{
+5 -2
View File
@@ -79,7 +79,9 @@ class Notification extends \Espo\Services\Record implements
$now = date('Y-m-d H:i:s');
$collection = $this->entityManager->createCollection();
$collection = $this->entityManager
->getCollectionFactory()
->create();
$userList = $this->entityManager
->getRepository('User')
@@ -87,7 +89,8 @@ class Notification extends \Espo\Services\Record implements
->where([
'isActive' => true,
'id' => $userIdList,
])->find();
])
->find();
foreach ($userList as $user) {
$userId = $user->id;