fix orm types

This commit is contained in:
Yuri Kuznetsov
2021-11-03 17:01:17 +02:00
parent 3fa33b6706
commit fc6dfd1994
3 changed files with 26 additions and 7 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ use stdClass;
* A collection of entities.
*
* @template TValue of Entity
* @extends Traversable<TValue>
* @bypass-extends Traversable<TValue>
*
* @todo Extend from Traversable once the min supported PHP version is 7.4. Remove bypass.
*/
+3 -2
View File
@@ -29,9 +29,10 @@
namespace Espo\ORM\Locker;
use Espo\ORM\QueryComposer\MysqlQueryComposer;
use Espo\ORM\{
TransactionManager,
QueryComposer\QueryComposer,
Query\LockTableBuilder,
};
@@ -51,7 +52,7 @@ class MysqlLocker implements Locker
private $isLocked = false;
public function __construct(PDO $pdo, QueryComposer $queryComposer, TransactionManager $transactionManager)
public function __construct(PDO $pdo, MysqlQueryComposer $queryComposer, TransactionManager $transactionManager)
{
$this->pdo = $pdo;
$this->queryComposer = $queryComposer;
@@ -164,9 +164,7 @@ class RDBRelationSelectBuilder
{
$transformedWhere = [];
$middleName = lcfirst(
$this->entity->getRelationParam($this->relationName, 'relationName')
);
$middleName = lcfirst($this->getRelationParam('relationName'));
foreach ($where as $key => $value) {
$transformedKey = $key;
@@ -429,7 +427,7 @@ class RDBRelationSelectBuilder
}
if (!$this->middleTableAlias) {
$middleName = $this->entity->getRelationParam($this->relationName, 'relationName');
$middleName = $this->getRelationParam('relationName');
if (!$middleName) {
throw new RuntimeException("No relation name.");
@@ -495,4 +493,24 @@ class RDBRelationSelectBuilder
return $this->entityManager->getCollectionFactory()->createFromSthCollection($collection);
}
/**
* @return mixed
*/
private function getRelationParam(string $param)
{
if ($this->entity instanceof BaseEntity) {
return $this->entity->getRelationParam($this->relationName, $param);
}
$entityDefs = $this->entityManager
->getDefs()
->getEntity($this->entity->getEntityType());
if (!$entityDefs->hasRelation($this->relationName)) {
return null;
}
return $entityDefs->getRelation($this->relationName)->getParam($param);
}
}