- ArrayOf errors now catched in EntityTrait (event soon to be attached to it)
- Fixed some non-nullable defaulted to null vars in functions - Added a new diff method for entities which skips nullable values if they are not defined.
This commit is contained in:
1 parent
709ed63323
commit
13b7cf06f1
9 files changed
+52
-26
No files matched your search
@@ -6,7 +6,6 @@ use Ulmus\EntityCollection;
|
||||
|
||||
class ArrayCollection extends EntityCollection implements JsonUnserializable
|
||||
{
|
||||
|
||||
public function jsonUnserialize(array $json): void
|
||||
{
|
||||
$this->fromArray($json);
|
||||
|
||||
@@ -17,7 +17,7 @@ class DatasetHandler
|
||||
protected bool $entityStrictFieldsDeclaration = false,
|
||||
) {}
|
||||
|
||||
public function pull(object $entity) : Generator
|
||||
public function pull(object $entity, bool $nullable = true) : Generator
|
||||
{
|
||||
foreach($this->entityResolver->fieldList(EntityResolver::KEY_ENTITY_NAME, true) as $key => $field) {
|
||||
$attribute = $this->entityResolver->searchFieldAnnotation($key,[ Field::class ]);
|
||||
@@ -25,7 +25,7 @@ class DatasetHandler
|
||||
if ( $entity->__isset($key) ) {
|
||||
yield $attribute->name ?? $key => $entity->$key;
|
||||
}
|
||||
elseif ( $field->allowsNull() ) {
|
||||
elseif ( $nullable && $field->allowsNull() ) {
|
||||
yield $attribute->name ?? $key => null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ interface EntityInterface extends SearchableInterface /* extends \JsonSerializab
|
||||
public function isLoaded() : bool;
|
||||
public function jsonSerialize() : mixed;
|
||||
public static function resolveEntity() : EntityResolver;
|
||||
public static function repository(string $alias = Repository::DEFAULT_ALIAS, ConnectionAdapter $adapter = null) : Repository;
|
||||
public static function repository(string $alias = Repository::DEFAULT_ALIAS, ?ConnectionAdapter $adapter = null) : Repository;
|
||||
public static function entityCollection(...$arguments) : EntityCollection;
|
||||
public static function queryBuilder() : QueryBuilderInterface;
|
||||
public static function field($name, null|string|false $alias = Repository::DEFAULT_ALIAS) : EntityField;
|
||||
|
||||
@@ -28,7 +28,7 @@ class Datetime extends \DateTime implements EntityObjectInterface, \JsonSerializ
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function setTime($hour, $minute, $second = 0, $microsecond = 0) : \DateTimeInterface
|
||||
public function setTime($hour, $minute, $second = 0, $microsecond = 0) : \DateTime
|
||||
{
|
||||
$fromParent = parent::setTime($hour, $minute, $second, $microsecond);
|
||||
|
||||
@@ -45,14 +45,15 @@ class Datetime extends \DateTime implements EntityObjectInterface, \JsonSerializ
|
||||
return $this->format($this->format);
|
||||
}
|
||||
|
||||
#[\Deprecated]
|
||||
public function formatLocale(string $format) : string
|
||||
{
|
||||
return strftime($format, $this->getTimestamp());
|
||||
}
|
||||
|
||||
public function formatLocaleIntl(int $dateFormatter = \IntlDateFormatter::LONG, int $timeFormatter = \IntlDateFormatter::NONE) : string
|
||||
public function formatLocaleIntl(int $dateFormatter = \IntlDateFormatter::LONG, int $timeFormatter = \IntlDateFormatter::NONE, ? string $pattern = null) : string
|
||||
{
|
||||
$formatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormatter, $timeFormatter, \Locale::getRegion(""));
|
||||
$formatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormatter, $timeFormatter, \date_default_timezone_get(), \IntlDateFormatter::GREGORIAN, $pattern);
|
||||
|
||||
return $formatter->format($this->getTimestamp());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user