order By Link field

This commit is contained in:
Yuri Kuznetsov
2014-01-14 12:01:49 +02:00
parent 93710c41c2
commit 9a258f2aa5
2 changed files with 8 additions and 2 deletions
+7 -1
View File
@@ -15,12 +15,15 @@ class SelectManager
protected $entityManager;
protected $entityName;
protected $metadata;
public function __construct(ORM\EntityManager $entityManager, \Espo\Entities\User $user, Acl $acl)
public function __construct(ORM\EntityManager $entityManager, \Espo\Entities\User $user, Acl $acl, $metadata)
{
$this->entityManager = $entityManager;
$this->user = $user;
$this->acl = $acl;
$this->metadata = $metadata;
}
public function setEntityName($entityName)
@@ -42,6 +45,9 @@ class SelectManager
{
if (!empty($params['sortBy'])) {
$result['orderBy'] = $params['sortBy'];
if ($this->metadata->get("entityDefs.{$this->entityName}.fields." . $result['orderBy'] . ".type") == 'link') {
$result['orderBy'] .= 'Name';
}
}
if (isset($params['asc'])) {
if ($params['asc']) {
+1 -1
View File
@@ -109,7 +109,7 @@ class Record extends \Espo\Core\Services\Base
$className = '\\Espo\\Core\\SelectManager';
}
$selectManager = new $className($this->getEntityManager(), $this->getUser(), $this->getAcl());
$selectManager = new $className($this->getEntityManager(), $this->getUser(), $this->getAcl(), $this->getMetadata());
$selectManager->setEntityName($entityName);
return $selectManager;