summaryrefslogtreecommitdiffstats
path: root/core/namespace/ItemFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace/ItemFactory.php')
-rw-r--r--core/namespace/ItemFactory.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/namespace/ItemFactory.php b/core/namespace/ItemFactory.php
index e5793d4..35182f1 100644
--- a/core/namespace/ItemFactory.php
+++ b/core/namespace/ItemFactory.php
@@ -1,5 +1,9 @@
<?php
abstract class ItemFactory extends Factory implements FactoryInterface {
+
+ #===========================================================================
+ # Build instance by ID
+ #===========================================================================
public static function build($itemID): Item {
if(!$Instance = parent::fetchInstance($itemID)) {
$Item = (new ReflectionClass(get_called_class()))->getNamespaceName().'\\Item';
@@ -8,5 +12,13 @@ abstract class ItemFactory extends Factory implements FactoryInterface {
return $Instance;
}
+
+ #===========================================================================
+ # Build instance by slug
+ #===========================================================================
+ public static function buildBySlug($slug): \Item {
+ $Item = (new ReflectionClass(get_called_class()))->getNamespaceName().'\\Item';
+ return self::build($Item::getIDByField('slug', $slug, \Application::getDatabase()));
+ }
}
?> \ No newline at end of file