Entity: Throw exception when trying to get save ID of non registered entity

This commit is contained in:
Dylan K. Taylor 2018-01-04 21:05:17 +00:00
parent 90fc649441
commit 684fd46d09

View File

@ -789,6 +789,9 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
* @return string
*/
public function getSaveId(){
if(!isset(self::$saveNames[static::class])){
throw new \InvalidStateException("Entity is not registered");
}
reset(self::$saveNames[static::class]);
return current(self::$saveNames[static::class]);
}