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