public static function getPluginClassNames(
        \Composer\Package\PackageInterface $package,
        \Composer\Package\PackageInterface $rootPackage = null
    ) {
        $packageType = $package->getType();
        $packagePrettyName = $package->getPrettyName();
        $packageName = $package->getName();

        $classNames = array();

        // 1. root package
        $rootPackageExtra = $rootPackage ? $rootPackage->getExtra() : null;
        if (!empty($rootPackageExtra[$packageType])) {
            $classNames = (array) $this->mapRootExtra($rootPackageExtra[$packageType], $packagePrettyName);
        }

        // 2. package
        if (!$classNames) {
            $packageExtra = $package->getExtra();
            if (!empty($packageExtra[$packageType])) {
                $classNames = (array) $packageExtra[$packageType];
            }
        }

        // 3. guess by installer name
        if (!$classNames) {
            $installName = static::getInstallName($package, $rootPackage);
            $classNames = array($installName);
        }

        return $classNames;
    }