X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/5ef0992d5b771f6348e131023eaa3a8be7fac646..refs/pull/1688/head:/app/Entities/EntityProvider.php diff --git a/app/Entities/EntityProvider.php b/app/Entities/EntityProvider.php index 04939a14a..d0d4a7ad6 100644 --- a/app/Entities/EntityProvider.php +++ b/app/Entities/EntityProvider.php @@ -84,4 +84,23 @@ class EntityProvider $type = strtolower($type); return $this->all()[$type]; } + + /** + * Get the morph classes, as an array, for a single or multiple types. + * @param string|array $types + * @return array + */ + public function getMorphClasses($types) + { + if (is_string($types)) { + $types = [$types]; + } + + $morphClasses = []; + foreach ($types as $type) { + $model = $this->get($type); + $morphClasses[] = $model->getMorphClass(); + } + return $morphClasses; + } }