Elgg  Version 2.3
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  if (empty($trace['file'])) {
56  // file/line not set for Closures
57  $stack[] = "[#$i] unknown";
58  } else {
59  $stack[] = "[#$i] {$trace['file']}:{$trace['line']}";
60  }
61 
62  $i--;
63 
64  if ($backtrace_level > 0) {
65  if ($backtrace_level <= 1) {
66  break;
67  }
68  $backtrace_level--;
69  }
70  }
71 
72  $msg .= implode("<br /> -> ", $stack);
73 
74  $this->logger->warn($msg);
75 
76  return true;
77  }
78 }
sendNotice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
Save menu items.
__construct(Logger $logger)
Constructor.