aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/ItemFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace/ItemFactory.php')
-rw-r--r--core/namespace/ItemFactory.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/namespace/ItemFactory.php b/core/namespace/ItemFactory.php
index d81ff9f..ba32cd5 100644
--- a/core/namespace/ItemFactory.php
+++ b/core/namespace/ItemFactory.php
@@ -18,6 +18,18 @@ abstract class ItemFactory extends Factory {
#===========================================================================
public static function buildBySlug($slug): Item {
$Item = (new ReflectionClass(get_called_class()))->getNamespaceName().'\\Item';
- return self::build($Item::getIDByField('slug', $slug, \Application::getDatabase()));
+ return self::buildByAttribute($Item::getByField('slug', $slug, \Application::getDatabase()));
+ }
+
+ #===========================================================================
+ # Build instance by Attribute
+ #===========================================================================
+ public static function buildByAttribute(Attribute $Attribute) {
+ if(!$Instance = parent::fetchInstance($Attribute->get('id'))) {
+ $Item = (new ReflectionClass(get_called_class()))->getNamespaceName().'\\Item';
+ $Instance = parent::storeInstance($Attribute->get('id'), new $Item($Attribute, \Application::getDatabase()));
+ }
+
+ return $Instance;
}
}