- Merged stash after pull
This commit is contained in:
1 parent
114fa5be09
commit
efa957fe58
20 files changed
+623
-436
No files matched your search
@@ -2,7 +2,8 @@
|
||||
|
||||
namespace Ulmus\Common;
|
||||
|
||||
use Ulmus\Annotation\Annotation,
|
||||
use Ulmus\Ulmus,
|
||||
Ulmus\Annotation\Annotation,
|
||||
Ulmus\Annotation\Classes\Table,
|
||||
Ulmus\Annotation\Property\Field,
|
||||
Ulmus\Annotation\Property\Relation;
|
||||
@@ -123,20 +124,36 @@ class EntityResolver {
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function tableName() : string
|
||||
public function tableName($required = false) : string
|
||||
{
|
||||
if ( null === $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
throw new \LogicException("Your entity {$this->entityClass} seems to be missing a @Table() annotation");
|
||||
$table = $this->tableAnnotation($required);
|
||||
|
||||
if ( ( $table->name ?? "" ) === "") {
|
||||
if ($required) {
|
||||
throw new \ArgumentCountError("Your entity {$this->entityClass} seems to be missing a `name` argument for your @Table() annotation");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $table->name === "" ) {
|
||||
throw new \ArgumentCountError("Your entity {$this->entityClass} seems to be missing a `name` argument for your @Table() annotation");
|
||||
}
|
||||
|
||||
return $table->name;
|
||||
return $table->name ?? "";
|
||||
}
|
||||
|
||||
public function databaseAdapter() : ? \Ulmus\ConnectionAdapter
|
||||
public function tableAnnotation($required = false) : Table
|
||||
{
|
||||
if ( null === $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
if ($required) {
|
||||
throw new \LogicException("Your entity {$this->entityClass} seems to be missing a @Table() annotation");
|
||||
}
|
||||
}
|
||||
|
||||
return $table;
|
||||
}
|
||||
|
||||
public function databaseName() : string
|
||||
{
|
||||
return $this->tableAnnotation(false)->database ?? $this->databaseAdapter()->adapter()->database;
|
||||
}
|
||||
|
||||
public function databaseAdapter() : \Ulmus\ConnectionAdapter
|
||||
{
|
||||
if ( null !== $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
if ( $table->adapter ?? null ) {
|
||||
@@ -148,18 +165,17 @@ class EntityResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
return Ulmus::$defaultAdapter;
|
||||
}
|
||||
|
||||
|
||||
public function schemaName() : ? string
|
||||
public function schemaName(bool $required = false) : ? string
|
||||
{
|
||||
if ( null === $table = $this->getAnnotationFromClassname( Table::class ) ) {
|
||||
throw new \LogicException("Your entity {$this->entityClass} seems to be missing a @Table() annotation");
|
||||
}
|
||||
|
||||
if ( $table->name === "" ) {
|
||||
if ( $required && ( ( $table->schema ?? "" ) === "" ) ) {
|
||||
throw new \ArgumentCountError("Your entity {$this->entityClass} seems to be missing a `schema` argument for your @Table() annotation");
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user