- Merging..
This commit is contained in:
commit
6c6733b503
20 files changed
+127
-61
No files matched your search
@@ -61,16 +61,7 @@ class EntityResolver {
|
||||
|
||||
public function searchField($name) : null|array
|
||||
{
|
||||
try{
|
||||
return $this->field($name, self::KEY_ENTITY_NAME, false) ?: $this->field($name, self::KEY_COLUMN_NAME, false);
|
||||
}
|
||||
catch(\Throwable $e) {
|
||||
if ( $throwException) {
|
||||
throw new \InvalidArgumentException("Can't find entity field's column named `$name` from entity {$this->entityClass}");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->field($name, self::KEY_ENTITY_NAME, false) ?: $this->field($name, self::KEY_COLUMN_NAME, false);
|
||||
}
|
||||
|
||||
public function fieldList($fieldKey = self::KEY_ENTITY_NAME, bool $skipVirtual = false) : array
|
||||
@@ -173,7 +164,7 @@ class EntityResolver {
|
||||
return $table->name ?? "";
|
||||
}
|
||||
|
||||
public function tableAnnotation($required = false) : Table|Attribute\Obj\Table
|
||||
public function tableAnnotation($required = false) : null|Table|Attribute\Obj\Table
|
||||
{
|
||||
if ( null === $table = $this->getTableAttribute() ) {
|
||||
if ($required) {
|
||||
@@ -191,10 +182,10 @@ class EntityResolver {
|
||||
|
||||
public function sqlAdapter() : \Ulmus\ConnectionAdapter
|
||||
{
|
||||
if ( null !== $table = $this->getTableAttribute() ) {
|
||||
if ( $table->adapter ?? null ) {
|
||||
if ( null === ( $adapter = \Ulmus\Ulmus::$registeredAdapters[$table->adapter] ?? null ) ) {
|
||||
throw new \Exception("Requested database adapter `{$table->adapter}` is not registered.");
|
||||
if ( $adapterObj = $this->getAdapterInterfaceAttribute()) {
|
||||
if ( false !== $adapterName = $adapterObj->adapter() ) {
|
||||
if ( null === ( $adapter = \Ulmus\Ulmus::$registeredAdapters[$adapterName] ?? null ) ) {
|
||||
throw new \Exception("Requested database adapter `$adapterName` is not registered.");
|
||||
}
|
||||
else {
|
||||
return $adapter;
|
||||
@@ -250,6 +241,11 @@ class EntityResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function getAdapterInterfaceAttribute() : null|object
|
||||
{
|
||||
return $this->getAttributeImplementing(Attribute\Obj\AdapterAttributeInterface::class);
|
||||
}
|
||||
|
||||
protected function getTableAttribute()
|
||||
{
|
||||
return $this->getAnnotationFromClassname(Attribute\Obj\Table::class, false) ?: $this->getAnnotationFromClassname( Table::class, false );
|
||||
@@ -294,6 +290,17 @@ class EntityResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getAttributeImplementing(string $interface) : ? object
|
||||
{
|
||||
foreach (array_reverse($this->class['tags']) as $item) {
|
||||
if ($item['object'] instanceof $interface) {
|
||||
return $item['object'];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function instanciateAnnotationObject(array|\ReflectionAttribute $tagDefinition) : object
|
||||
{
|
||||
if ($tagDefinition instanceof \ReflectionAttribute) {
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ abstract class Sql {
|
||||
return static::identifier($sql);
|
||||
}
|
||||
|
||||
public static function escape($value)
|
||||
public static function escape($value) : mixed
|
||||
{
|
||||
switch(true) {
|
||||
case is_object($value):
|
||||
|
||||
Reference in new issue
Block a user