summaryrefslogtreecommitdiffstats
path: root/app/class
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2018-09-12 02:53:53 -0400
committerMalf Furious <m@lfurio.us>2018-09-12 02:53:53 -0400
commit11f83706e5774b417f6d8a52786e925bec88fc43 (patch)
tree74faf616800d219a32dfb2202f43313d3ec82008 /app/class
parent54782f88a2987ef2d0a5a530cfd0f027c38be396 (diff)
downloadscrott-11f83706e5774b417f6d8a52786e925bec88fc43.tar.gz
scrott-11f83706e5774b417f6d8a52786e925bec88fc43.zip
Add function agent::getAgentObj()
This is basically a constructor for agent. The actual type returned is a contrete agent.
Diffstat (limited to 'app/class')
-rw-r--r--app/class/agent.class.php17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/class/agent.class.php b/app/class/agent.class.php
index 4af13d5..63a21ed 100644
--- a/app/class/agent.class.php
+++ b/app/class/agent.class.php
@@ -33,6 +33,23 @@ abstract class agent extends obj
}
/*
+ * Since this class is abstract, this function is provided as a
+ * means of constructing the appropriate agent object based on
+ * a GUID.
+ */
+ public static function getAgentObj(string $guid) : agent
+ {
+ try
+ {
+ return new user($guid);
+ }
+ catch (Exception $e)
+ {
+ return new group($guid);
+ }
+ }
+
+ /*
* Check whether this agent is the owner of the given object
*/
public function isOwnerOf(obj $obj) : bool