Back to InstallerHelper class

Method detectType

public static mixed
detectType
(mixed $packageDirectory)
Method to detect the extension type from a package directory
Parameters
  • string $packageDirectory Path to package directory
Returns
  • mixed Extension type string or boolean false on fail
Since
  • 3.1

Method detectType - Source code

/**
 * Method to detect the extension type from a package directory
 *
 * @param   string  $packageDirectory  Path to package directory
 *
 * @return  mixed  Extension type string or boolean false on fail
 *
 * @since   3.1
 */
public static function detectType($packageDirectory)
{
    // Search the install dir for an XML file
    $files = Folder::files($packageDirectory, '\\.xml$', 1, true);
    if (!$files || !\count($files)) {
        Log::add(Text::_('JLIB_INSTALLER_ERROR_NOTFINDXMLSETUPFILE'), Log::WARNING, 'jerror');
        return false;
    }
    foreach ($files as $file) {
        $xml = simplexml_load_file($file);
        if (!$xml) {
            continue;
        }
        if ($xml->getName() !== 'extension') {
            unset($xml);
            continue;
        }
        $type = (string) $xml->attributes()->type;
        // Free up memory
        unset($xml);
        return $type;
    }
    Log::add(Text::_('JLIB_INSTALLER_ERROR_NOTFINDJOOMLAXMLSETUPFILE'), Log::WARNING, 'jerror');
    return false;
}
OSZAR »