Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Commit 4400dbb

Browse files
committed
Added a top level function to the machine class that allows a function to discover which function called it.
1 parent 6910738 commit 4400dbb

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Machine/MachineAbstract.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,21 @@ protected function makeCall($url)
125125

126126
return $this->xmlAttributesToArray($xml);
127127
}
128+
129+
/**
130+
* Universal function so any method belonging to a child class of a Plex
131+
* machine can discover which fucntion called it. This is used mainly for
132+
* some of our polymorphic requests as the calling function can tell us what
133+
* type of item is being requested.
134+
*
135+
* @return string The name of the function that called the function that
136+
* issued the getCallingFunction request.
137+
*/
138+
protected function getCallingFunction()
139+
{
140+
$backtrace = debug_backtrace();
141+
// Index will always be 2 because 0 is this function and 1 will be the
142+
// function that asked for the calling function.
143+
return $backtrace[2]['function'];
144+
}
128145
}

0 commit comments

Comments
 (0)