Elgg  Version 2.2
 All Classes Namespaces Files Functions Variables Pages
DeprecationService.php
Go to the documentation of this file.
1 <?php
2 namespace Elgg;
3 
16 
20  protected $logger;
21 
27  public function __construct(Logger $logger) {
28  $this->logger = $logger;
29  }
30 
42  function sendNotice($msg, $dep_version, $backtrace_level = 1) {
43 
44  $msg = "Deprecated in $dep_version: $msg Called from ";
45 
46  // Get a file and line number for the log. Skip over the function that
47  // sent this notice and see who called the deprecated function itself.
48  $stack = array();
49  $backtrace = debug_backtrace();
50  // never show this call.
51  array_shift($backtrace);
52  $i = count($backtrace);
53 
54  foreach ($backtrace as $trace) {
55  $stack[] = "[#$i] {$trace['file']}:{$trace['line']}";
56  $i--;
57 
58  if ($backtrace_level > 0) {
59  if ($backtrace_level <= 1) {
60  break;
61  }
62  $backtrace_level--;
63  }
64  }
65 
66  $msg .= implode("<br /> -> ", $stack);
67 
68  $this->logger->warn($msg);
69 
70  return true;
71  }
72 }
sendNotice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
__construct(Logger $logger)
Constructor.