- Added a 'select' attribute, WIP on ArrayCollection and ArrayOf also
This commit is contained in:
1 parent
b394b9348f
commit
f938e18572
7 files changed
+56
-34
No files matched your search
+19
-17
@@ -10,29 +10,31 @@ use Ulmus\Ulmus,
|
||||
|
||||
class EntityField implements WhereRawParameter
|
||||
{
|
||||
public string $name;
|
||||
|
||||
public string $entityClass;
|
||||
|
||||
public ? string $alias;
|
||||
|
||||
protected EntityResolver $entityResolver;
|
||||
|
||||
public function __construct(string $entityClass, string $name, ? string $alias, EntityResolver $resolver)
|
||||
{
|
||||
$this->entityClass = $entityClass;
|
||||
$this->name = $name;
|
||||
$this->alias = $alias;
|
||||
$this->entityResolver = $resolver;
|
||||
}
|
||||
public function __construct(
|
||||
public string $name,
|
||||
public string $entityClass,
|
||||
public ? string $alias,
|
||||
protected EntityResolver $entityResolver,
|
||||
protected bool $select = false
|
||||
) {}
|
||||
|
||||
public function name($useAlias = true) : string
|
||||
{
|
||||
$name = $this->entityResolver->searchFieldAnnotation($this->name, [ Field::class ] )->name ?? $this->name;
|
||||
|
||||
|
||||
$name = $this->entityResolver->databaseAdapter()->adapter()->escapeIdentifier($name, AdapterInterface::IDENTIFIER_FIELD);
|
||||
|
||||
return $useAlias && $this->alias ? "{$this->alias}.$name" : $name;
|
||||
$fullname = $useAlias && $this->alias ? "{$this->alias}.$name" : $name;
|
||||
|
||||
if ($this->select) {
|
||||
$select = $this->entityResolver->searchFieldAnnotation($this->name, [Field\Select::class]);
|
||||
|
||||
if ($select) {
|
||||
return "(" . str_replace(['%NAME%'], [$fullname], $select->sql) . ") AS code";
|
||||
}
|
||||
}
|
||||
|
||||
return $fullname;
|
||||
}
|
||||
|
||||
public static function isScalarType($type) : bool
|
||||
|
||||
Reference in new issue
Block a user