0

The JED Checker recommends in Joomla 4 using

Joomla\Filesystem\File 

isteand of

Joomla\CMS\Filesystem\File

because of the second one being deprecated in J5.

But when i use it things like this happen:

Attempted to call an undefined method named "exists" of class "Joomla\Filesystem\File".

So whats the deal here?

1 Answer 1

1

In the newer Joomla\Filesystem\File which is part of the Joomla Platform, there is no longer the method/function called exists()

The exists() method called in the Joomla\CMS\Filesystem\File can be replaced by the standard PHP is_file() function.

This is the exists() function in Joomla 3.

/**
 * Wrapper for the standard file_exists function
 *
 * @param   string  $file  File path
 *
 * @return  boolean  True if path is a file
 *
 * @since   1.7.0
 */
public static function exists($file)
{
    return is_file(Path::clean($file));
}
11
  • I see, and getExt is gone to.
    – maidan
    Sep 26, 2023 at 10:38
  • Among others. There are 13 methods in the original CMS version and only 8 in the platform version.
    – Irata
    Sep 26, 2023 at 10:52
  • I dont get it. In J5 there is still Joomla\CMS\Filesystem\File in TemplateModel e.g being used. Why does the JED Checker say it needs to be replaced in J5 and where is the "platform version" ?
    – maidan
    Sep 26, 2023 at 10:58
  • The Framework file can be found in ..\libraries\vendor\joomla\filesystem\src\File.php
    – Irata
    Sep 26, 2023 at 11:24
  • So what can be done with getExt ? Should i still use Joomla\CMS\Filesystem\File for that
    – maidan
    Sep 26, 2023 at 11:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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