From 538af387691c80464c86a652a6077df814953198 Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Mon, 29 Jun 2020 11:36:41 -0400 Subject: [PATCH] - Added a new EntityCollection factory --- src/EntityTrait.php | 10 +++++++++- src/Repository.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/EntityTrait.php b/src/EntityTrait.php index 1abc13b..c19077e 100644 --- a/src/EntityTrait.php +++ b/src/EntityTrait.php @@ -332,7 +332,7 @@ trait EntityTrait { public function isLoaded() : bool { if ( null === $pkField = $this->resolveEntity()->getPrimaryKeyField($this) ) { - throw new Exception\EntityPrimaryKeyUnknown("Entity has no field containing attributes 'primary_key'"); + throw new Exception\EntityPrimaryKeyUnknown(sprintf("Entity %s has no field containing attributes 'primary_key'", static::class)); } $key = key($pkField); @@ -372,6 +372,14 @@ trait EntityTrait { return Ulmus::repository(static::class, $alias); } + /** + * @Ignore + */ + public static function entityCollection(...$arguments) : EntityCollection + { + return new EntityCollection(...$arguments); + } + /** * @Ignore */ diff --git a/src/Repository.php b/src/Repository.php index a19f17c..d856bf8 100644 --- a/src/Repository.php +++ b/src/Repository.php @@ -638,7 +638,7 @@ class Repository public function instanciateEntityCollection() : EntityCollection { - return new EntityCollection(); + return $this->entityClass::entityCollection(); } public function escapeTable(string $identifier) : string