Back to CallbackController class

Method _makeId

protected string
_makeId
(mixed $callback, mixed $args)
Generate a callback cache ID
Parameters
  • mixed $callback Callback to cache
  • array $args Arguments to the callback method to cache
Returns
  • string MD5 Hash
Since
  • 1.7.0

Method _makeId - Source code

/**
 * Generate a callback cache ID
 *
 * @param   mixed  $callback  Callback to cache
 * @param   array  $args      Arguments to the callback method to cache
 *
 * @return  string  MD5 Hash
 *
 * @since   1.7.0
 */
protected function _makeId($callback, $args)
{
    if (\is_array($callback) && \is_object($callback[0])) {
        $vars = get_object_vars($callback[0]);
        $vars[] = strtolower(\get_class($callback[0]));
        $callback[0] = $vars;
    }
    // A Closure can't be serialized, so to generate the ID we'll need to get its hash
    if ($callback instanceof \closure) {
        $hash = spl_object_hash($callback);
        return md5($hash . serialize(array($args)));
    }
    return md5(serialize(array($callback, $args)));
}