public static function getPackageType($source)
    {
        $plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
        $theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';

        if (
            file_exists($source . 'system/defines.php') &&
            file_exists($source . 'system/config/system.yaml')
        ) {
            return 'grav';
        }

        // must have a blueprint
        if (!file_exists($source . 'blueprints.yaml')) {
            return false;
        }

        // either theme or plugin
        $name = basename($source);
        if (Utils::contains($name, 'theme')) {
            return 'theme';
        }
        if (Utils::contains($name, 'plugin')) {
            return 'plugin';
        }
        foreach (glob($source . '*.php') as $filename) {
            $contents = file_get_contents($filename);
            if (preg_match($theme_regex, $contents)) {
                return 'theme';
            }
            if (preg_match($plugin_regex, $contents)) {
                return 'plugin';
            }
        }

        // Assume it's a theme
        return 'theme';
    }
public static function getPackageType($source)
    {
        $plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
        $theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';

        if (
            file_exists($source . 'system/defines.php') &&
            file_exists($source . 'system/config/system.yaml')
        ) {
            return 'grav';
        }

        // must have a blueprint
        if (!file_exists($source . 'blueprints.yaml')) {
            return false;
        }

        // either theme or plugin
        $name = basename($source);
        if (Utils::contains($name, 'theme')) {
            return 'theme';
        }
        if (Utils::contains($name, 'plugin')) {
            return 'plugin';
        }
        foreach (glob($source . '*.php') as $filename) {
            $contents = file_get_contents($filename);
            if (preg_match($theme_regex, $contents)) {
                return 'theme';
            }
            if (preg_match($plugin_regex, $contents)) {
                return 'plugin';
            }
        }

        // Assume it's a theme
        return 'theme';
    }
public static function getPackageType ( $ source ) { $ plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m' ; $ theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m' ; if ( file_exists ( $ source . 'system/defines.php' ) && file_exists ( $ source . 'system/config/system.yaml' ) ) { return 'grav' ; } // must have a blueprint if ( ! file_exists ( $ source . 'blueprints.yaml' ) ) { return false ; } // either theme or plugin $ name = basename ( $ source ) ; if ( Utils :: contains ( $ name , 'theme' ) ) { return 'theme' ; } if ( Utils :: contains ( $ name , 'plugin' ) ) { return 'plugin' ; } foreach ( glob ( $ source . '*.php' ) as $ filename ) { $ contents = file_get_contents ( $ filename ) ; if ( preg_match ( $ theme_regex , $ contents ) ) { return 'theme' ; } if ( preg_match ( $ plugin_regex , $ contents ) ) { return 'plugin' ; } } // Assume it's a theme return 'theme' ; }
Try to guess the package type from the source files

@param string $source
@return bool|string
Try to guess the package type from the source files