orm refactoring
This commit is contained in:
@@ -29,8 +29,53 @@
|
||||
|
||||
namespace Espo\ORM\Query;
|
||||
|
||||
use Espo\ORM\Query\Part\OrderExpression;
|
||||
use Espo\ORM\Query\Part\WhereClause;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
trait SelectingTrait
|
||||
{
|
||||
/**
|
||||
* Get ORDER items.
|
||||
*
|
||||
* @return OrderExpression[]
|
||||
*/
|
||||
public function getOrder(): array
|
||||
{
|
||||
return array_map(
|
||||
function ($item) {
|
||||
if (is_array($item) && count($item)) {
|
||||
$itemValue = is_int($item[0]) ? (string) $item[0] : $item[0];
|
||||
|
||||
return OrderExpression::fromString($itemValue)
|
||||
->withDirection($item[1] ?? OrderExpression::ASC);
|
||||
}
|
||||
|
||||
if (is_string($item)) {
|
||||
return OrderExpression::fromString($item);
|
||||
}
|
||||
|
||||
throw new RuntimeException("Bad order item.");
|
||||
},
|
||||
$this->params['orderBy'] ?? []
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WHERE clause.
|
||||
*/
|
||||
public function getWhere(): ?WhereClause
|
||||
{
|
||||
$whereClause = $this->params['whereClause'] ?? null;
|
||||
|
||||
if ($whereClause === null || $whereClause === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return WhereClause::fromRaw($whereClause);
|
||||
}
|
||||
|
||||
private static function validateRawParamsSelecting(array $params): void
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user