modX.deprecated
Last updated not available | Page history | Improve this page | Report an issue
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn moremodX::deprecated¶
Logs a deprecation notice for a method that is going away. Call it as the first line of that method: the backtrace identifies the deprecated definition and the code that called it.
The call is skipped when the log_deprecated option is off, and the option is on by default.
Notices stay in memory: one per definition, with callers accumulating. When the request shuts down they become modDeprecatedMethod rows. The manager lists them under Reports → Error Log, in the Deprecations Log panel.
Syntax¶
void deprecated (string $since, [string $recommendation = ''], [string $deprecatedDef = ''])
-
$since(string) version in which the feature was deprecated -
$recommendation(string) replacement advice, by default'' -
$deprecatedDef(string) name to record; by default''it is derived from the backtrace
Example¶
function legacy_lookup($modx, $id)
{
$modx->deprecated('3.1.0', 'Use $modx->getObject instead');
return $modx->getObject(modResource::class, $id);
}
See Also¶
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$194 per month—let's make that $500!
Learn more










