aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Item.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2018-04-01 15:40:48 +0200
committerThomas Lange <code@nerdmind.de>2018-04-01 15:40:48 +0200
commit381cdf93ab53b27db034453cc9144b6ab5707fec (patch)
tree3e35be923d63f5e9204a3f6e72e9864327547ca3 /core/namespace/Item.php
parent7c307baeb1172ca1387966338d11ede4ee6dbb56 (diff)
downloadblog-381cdf93ab53b27db034453cc9144b6ab5707fec.tar.gz
blog-381cdf93ab53b27db034453cc9144b6ab5707fec.tar.xz
blog-381cdf93ab53b27db034453cc9144b6ab5707fec.zip
Add possibility to create instance with Attribute as first parameter
Diffstat (limited to 'core/namespace/Item.php')
-rw-r--r--core/namespace/Item.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/namespace/Item.php b/core/namespace/Item.php
index 60f7547..ba54579 100644
--- a/core/namespace/Item.php
+++ b/core/namespace/Item.php
@@ -10,7 +10,7 @@ abstract class Item implements ItemInterface {
#===============================================================================
# Abstract item constructor
#===============================================================================
- public final function __construct($itemID, \Database $Database) {
+ public final function __construct($param, \Database $Database) {
$this->Database = $Database;
$this->Reflection = new ReflectionObject($this);
@@ -18,6 +18,17 @@ abstract class Item implements ItemInterface {
$attribute = "{$this->Reflection->getNamespaceName()}\\Attribute";
$exception = "{$this->Reflection->getNamespaceName()}\\Exception";
+ # If $param is an instance of Attribute,
+ # skip fetching attribute from database!
+ if($param instanceof Attribute) {
+ $this->Attribute = $param;
+ return;
+ }
+
+ # If this gets executed, then $param
+ # is not an instance of Attribute!
+ $itemID = $param;
+
#===============================================================================
# Checking if item in database exists
#===============================================================================