- Worked on support for multiple adapters based on @Table() annotation's entity
This commit is contained in:
1 parent
d01e99b18f
commit
79fdabe786
7 files changed
+47
-21
No files matched your search
@@ -136,6 +136,23 @@ class EntityResolver {
|
||||
return $table->name;
|
||||
}
|
||||
|
||||
public function databaseAdapter() : ? \Ulmus\ConnectionAdapter
|
||||
{
|
||||
if ( null !== $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
if ( $table->adapter ?? null ) {
|
||||
if ( null === ( $adapter = \Ulmus\Ulmus::$registeredAdapters[$table->adapter] ?? null ) ) {
|
||||
throw new \Exception("Requested database adapter ( {$table->adapter} ) is not registered.");
|
||||
}
|
||||
else {
|
||||
return $adapter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public function schemaName() : ? string
|
||||
{
|
||||
if ( null === $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
@@ -150,10 +167,10 @@ class EntityResolver {
|
||||
}
|
||||
|
||||
public function getPrimaryKeyField() : ? array
|
||||
{
|
||||
{
|
||||
foreach($this->fieldList() as $key => $value) {
|
||||
if ( null !== ( $field = $this->searchFieldAnnotation($key, new Field() ) ) ) {
|
||||
if (false !== $field->attributes['primary_key'] ?? false ) {
|
||||
if ( false !== ( $field->attributes['primary_key'] ?? false ) ) {
|
||||
return [ $key => $field ];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user