From 4400dbbea7deba6b0002c493f3cbf829bfc5d808 Mon Sep 17 00:00:00 2001 From: Nick Bartkowiak Date: Mon, 24 Dec 2012 13:19:41 -0600 Subject: [PATCH] Added a top level function to the machine class that allows a function to discover which function called it. --- Machine/MachineAbstract.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Machine/MachineAbstract.php b/Machine/MachineAbstract.php index 35b4138..64f2f8f 100644 --- a/Machine/MachineAbstract.php +++ b/Machine/MachineAbstract.php @@ -125,4 +125,21 @@ protected function makeCall($url) return $this->xmlAttributesToArray($xml); } + + /** + * Universal function so any method belonging to a child class of a Plex + * machine can discover which fucntion called it. This is used mainly for + * some of our polymorphic requests as the calling function can tell us what + * type of item is being requested. + * + * @return string The name of the function that called the function that + * issued the getCallingFunction request. + */ + protected function getCallingFunction() + { + $backtrace = debug_backtrace(); + // Index will always be 2 because 0 is this function and 1 will be the + // function that asked for the calling function. + return $backtrace[2]['function']; + } }