aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace
diff options
context:
space:
mode:
Diffstat (limited to 'core/namespace')
-rw-r--r--core/namespace/ItemFactory.php12
-rw-r--r--core/namespace/Page/Factory.php6
-rw-r--r--core/namespace/Post/Factory.php6
-rw-r--r--core/namespace/User/Factory.php4
4 files changed, 14 insertions, 14 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
diff --git a/core/namespace/Page/Factory.php b/core/namespace/Page/Factory.php
index f53b35f..4b8d390 100644
--- a/core/namespace/Page/Factory.php
+++ b/core/namespace/Page/Factory.php
@@ -1,9 +1,5 @@
<?php
namespace Page;
-class Factory extends \ItemFactory {
- public static function buildBySlug($slug): \Item {
- return self::build(Item::getIDByField('slug', $slug, \Application::getDatabase()));
- }
-}
+class Factory extends \ItemFactory {}
?> \ No newline at end of file
diff --git a/core/namespace/Post/Factory.php b/core/namespace/Post/Factory.php
index 34aa5e4..4ad8ac8 100644
--- a/core/namespace/Post/Factory.php
+++ b/core/namespace/Post/Factory.php
@@ -1,9 +1,5 @@
<?php
namespace Post;
-class Factory extends \ItemFactory {
- public static function buildBySlug($slug): \Item {
- return self::build(Item::getIDByField('slug', $slug, \Application::getDatabase()));
- }
-}
+class Factory extends \ItemFactory {}
?> \ No newline at end of file
diff --git a/core/namespace/User/Factory.php b/core/namespace/User/Factory.php
index 80e6b49..e352368 100644
--- a/core/namespace/User/Factory.php
+++ b/core/namespace/User/Factory.php
@@ -2,10 +2,6 @@
namespace User;
class Factory extends \ItemFactory {
- public static function buildBySlug($slug): \Item {
- return self::build(Item::getIDByField('slug', $slug, \Application::getDatabase()));
- }
-
public static function buildByUsername($username): \Item {
return self::build(Item::getIDByField('username', $username, \Application::getDatabase()));
}