- WIP on first 'doc' and also minimal support for enums where added
This commit is contained in:
1 parent
497fe5547b
commit
d600908f47
22 files changed
+367
-35
No files matched your search
+11
-4
@@ -78,11 +78,19 @@ trait EntityTrait {
|
||||
|
||||
$this->{$field['name']} = $value;
|
||||
}
|
||||
elseif ( $value instanceof \UnitEnum ) {
|
||||
$this->{$field['name']} = $value;
|
||||
}
|
||||
elseif (enum_exists($field['type'])) {
|
||||
$this->{$field['name']} = $field['type']::from($value);
|
||||
}
|
||||
elseif ( ! $field['builtin'] ) {
|
||||
try {
|
||||
$this->{$field['name']} = Ulmus::instanciateObject($field['type'], [ $value ]);
|
||||
}
|
||||
catch(\Error $e) {
|
||||
$f = $field['type'];
|
||||
dump($f, $f::from($value));
|
||||
throw new \Error(sprintf("%s for class '%s' on field '%s'", $e->getMessage(), get_class($this), $field['name']));
|
||||
}
|
||||
}
|
||||
@@ -99,7 +107,7 @@ trait EntityTrait {
|
||||
$this->entityLoadedDataset = array_change_key_case($dataset, \CASE_LOWER) + $this->entityLoadedDataset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -285,9 +293,9 @@ trait EntityTrait {
|
||||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
public static function repository(string $alias = Repository::DEFAULT_ALIAS) : Repository
|
||||
public static function repository(string $alias = Repository::DEFAULT_ALIAS, ConnectionAdapter $adapter = null) : Repository
|
||||
{
|
||||
return Ulmus::repository(static::class, $alias);
|
||||
return Ulmus::repository(static::class, $alias, $adapter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -301,7 +309,6 @@ trait EntityTrait {
|
||||
return $collection;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Ignore
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user