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

Commit

Permalink
Added a way to change the depth of the getCallingFunction so child cl…
Browse files Browse the repository at this point in the history
…asses that override methods or have 'hops' can specifically define the depth to which the getCallingFunction will check to make sure we return the correct calling function.
  • Loading branch information
nickbart committed Dec 25, 2012
1 parent b4aa08e commit 4cb038d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Machine/MachineAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,19 @@ protected function makeCall($url)
* some of our polymorphic requests as the calling function can tell us what
* type of item is being requested.
*
* @param integer $depth Depth defaults to 2 because 0 is this function and
* 1 will be the function that asked for the calling function. This can be
* changed by the calling function in case a specific calling function needs
* to be identified. This can be handy if the original calling function goes
* through a number of hops on its way to identification.
*
* @return string The name of the function that called the function that
* issued the getCallingFunction request.
*/
protected function getCallingFunction()
protected function getCallingFunction($depth = 2)
{
$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'];

return $backtrace[$depth]['function'];
}
}

0 comments on commit 4cb038d

Please sign in to comment.