How can I fix the following deprecation error generated by my php code?

Factory::getDocument() is deprecated

$app = Factory::getApplication();
$wa = $app->getDocument()->getWebAssetManager();

if (!$wa->assetExists('script', 'keyselectmodal'))
    $document = Factory::getDocument();

1 Answer 1


Use Joomla\CMS\Application\WebApplication::getDocument(). In your code you're already doing this with $app->getDocument().

  • unexpected :: error. Jul 9, 2021 at 10:40
  • In your code you only need to replace Factory::getDocument() with $app->getDocument().
    – Sharky
    Jul 9, 2021 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.