Is the class and property @Sharky comment before. But, in my case I never get this property work, not matter what I put in those array.
So, using the preflight method of the Joomla\CMS\Installer\InstallerScript
class, I copy the exact logic of the removeFiles method and it work. This always confuse me, but is what so far I need do for deal with this.
So, at the end, the method look like this:
/**
* Function called before extension installation/update/removal procedure commences.
*
* @param string $type The type of change (install or discover_install, update, uninstall)
* @param InstallerAdapter $adapter The adapter calling this method
*
* @return boolean True on success
*
* @since 4.2.0
*/
public function preflight($type, $adapter): bool
{
if (!empty($this->deleteFiles)) {
foreach ($this->deleteFiles as $file) {
if (file_exists(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) {
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '<br>';
}
}
}
if (!empty($this->deleteFolders)) {
foreach ($this->deleteFolders as $folder) {
if (Folder::exists(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder)) {
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '<br>';
}
}
}
return true;
}