Gets a list files the root package wants to exclude.

@param  PackageInterface $package Root package instance.
@return array|null       Retuns the list of excluded files otherwise NULL if misconfigured or undefined.
502821
private function getExcludedFiles(PackageInterface $package)
    {
        $type = self::EXCLUDE_FILES_PROPERTY;

        $autoload = $package->getAutoload();

        // Skip misconfigured or empty packages
        if (isset($autoload[$type]) && is_array($autoload[$type])) {
            return $autoload[$type];
        }

        $extra = $package->getExtra();

        // Skip misconfigured or empty packages
        if (isset($extra[$type]) && is_array($extra[$type])) {
            return $extra[$type];
        }

        return null;
    }
487497
protected function getModuleName(PackageInterface $package)
    {
        $extra = $package->getExtra();

        if (isset($extra['modulename'])) {
            $name = $extra['modulename'];
        } else {
            $name = strtr($package->getPrettyName(), array(
                '\\' => '.',
                '-' => '.',
                '_' => '.',
                ' ' => ''
            ));
        }

        return $name;
    }
871513
public function getPackageTranslations(Package $package)
    {
        $localStats = $this->localFactory->getAvailablePackageStats($package);
        $remoteStats = $this->remoteProvider->getAvailablePackageStats($package->getPackageHandle(), $package->getPackageVersion());

        return $this->computeUpdates($localStats, $remoteStats, $package);
    }
1277200
private function getPrimaryNamespace(PackageInterface $package)
    {
        $primaryNs = null;

        foreach ($package->getAutoload() as $type => $pathMap) {
            if ($type !== 'psr-4') {
                continue;
            }

            if (count($pathMap) === 1) {
                $primaryNs = key($pathMap);
                break;
            }

            $matches = preg_grep('#^(\./)?src/?$#', $pathMap);
            if ($matches) {
                $primaryNs = key($matches);
                break;
            }

            if (false !== ($key = array_search('', $pathMap, true))
                || false !== ($key = array_search('.', $pathMap, true))
            ) {
                $primaryNs = $key;
            }

            break;
        }

        if (!$primaryNs) {
            throw new RuntimeException(sprintf("Unable to get primary namespace for package %s.", $package->getName()));
        }

        return $primaryNs;
    }
126733
protected function removeLoader(PackageInterface $package)
    {
        $target = $this->getLoaderFileInstallPath($package);

        if (!$this->filesystem->remove($target)) {
            throw new \RuntimeException('Could not completely delete ' . $target . ', aborting.');
        }
    }
180014
protected function findBundleFiles(PackageInterface $package)
    {
        $installPath = $this->composer->getInstallationManager()->getInstallPath($package);

        $autoload = $package->getAutoload();
        if (isset($autoload['psr-0'])) {
            $installPath .= '/' . current($autoload['psr-0']);
        }
        if (isset($autoload['psr-4'])) {
            $installPath .= '/' . current($autoload['psr-4']);
        }

        return glob(rtrim($installPath, '/') . '/*Bundle.php');
    }
1263222
public function scanPackage(PackageInterface $package)
    {
        $extra = $package->getExtra();
        $extra_deps = [];
        foreach ($this->dependencies as $key) {
            $name = $this->name . '-' . $key;
            if (isset($extra[$name])) {
                $extra_deps[$key] = $extra[$name];
            }
        }
        $known_deps = $this->getKnownDeps($package);
        foreach ([$known_deps, $extra_deps] as $deps) {
            if (!empty($deps)) {
                $this->mergeConfig($deps);
            }
        }
    }
899162
public function getInstallPath(PackageInterface $package)
    {
        $flowPackageType = $this->getFlowPackageType($package->getType());
        $camelCasedType = $this->camelCaseFlowPackageType($flowPackageType);
        $flowPackageName = $this->deriveFlowPackageName($package);

        if (isset($this->packageTypeToPathMapping[$flowPackageType])) {
            $installPath = $this->packageTypeToPathMapping[$flowPackageType];
        } else {
            $installPath = $this->packageTypeToPathMapping['*'];
        }

        return $this->replacePlaceholdersInPath($installPath, compact('flowPackageType', 'camelCasedType', 'flowPackageName'));
    }
927427
public static function menu($package)
    {
        $dir = __DIR__.'/../../'.$package.'/src';
        $files = is_dir($dir) ? scandir($dir) : [];

        foreach ($files as $file) {
            if ($file == 'Menu.json') {
                $file_r = file_get_contents($dir.'/'.$file);

                return json_decode($file_r, true);
            }
        }

        return [];
    }
1021879
protected function getPackageEntryPoints(PackageInterface $package)
    {
        $dir = $this->composer->getInstallationManager()->getInstallPath($package);
        $entry = $this->getPackageExtra($package, 'wordpress-muplugin-entry');
        $entryPoints = $entry ? (is_array($entry) ? $entry : [ $entry ]) : [];

        if (empty($entryPoints)) {
            $phpFiles = glob(rtrim($dir, '/') . '/*.php', GLOB_NOSORT);

            foreach ($phpFiles as $file) {
                $entryPoints[] = basename($file);
            }
        }

        foreach ($entryPoints as $index => $file) {
            $entryPoints[ $index ] = $dir . $file;
        }

        return array_filter($entryPoints, [ $this, 'looksLikePlugin' ]);
    }
420149
public function getInstallPath(PackageInterface $package)
    {
        $prettyName = $package->getPrettyName();
        DebugPrinter::log(
            'Getting install path for `%s` package',
            array($prettyName,)
        );
        if (isset($this->installDirCache[$prettyName])) {
            return $this->installDirCache[$prettyName];
        }
        $installDir = null;
        if ($this->composer->getPackage()) {
            $rootExtra = $this->composer->getPackage()->getExtra();
            if (!empty($rootExtra['opencart-install-dir'])) {
                $installDir = $rootExtra['opencart-install-dir'];
            }
        }
        if (!$installDir) {
            $extra = $package->getExtra();
            if (!empty($extra['opencart-install-dir'])) {
                $installDir = $extra['opencart-install-dir'];
            }
        }
        if (is_array($installDir)) {
            if (isset($installDir[$prettyName])) {
                $this->installDirCache[$prettyName] = $installDir[$prettyName];
                return $installDir[$prettyName];
            }
            $this->installDirCache[$prettyName] = $this->defaultInstallDir;
            return $this->defaultInstallDir;
        }
        $installDir = $installDir ? $installDir : $this->defaultInstallDir;
        DebugPrinter::log(
            'Computed install dir for package `%s`: `%s`',
            array($prettyName, $installDir,)
        );
        $this->installDirCache[$prettyName] = $installDir;
        return $installDir;
    }
1097372
public function unlinkDropins(PackageInterface $package)
    {
        $content_dir = realpath($this->getContentPath());
        $dropins_dir = realpath($this->getInstallPath($package) . '/dropins/');

        // Link dropins not yet added.
        foreach (new \DirectoryIterator($dropins_dir) as $dropin) {
            if ($dropin->isDot()) {
                continue;
            }

            $src  = $content_dir . '/' . $dropin->getFilename();
            $dest = $dropins_dir . '/' . $dropin->getFilename();

            if (file_exists($src)) {
                $this->io->write('<info>Unlinking ' . $this->filesystem->findShortestPath($src, $dest) . '</info>');
                unlink($src);
            }
        }
    }
69654
protected static function isAsset(PackageInterface $package)
    {
        foreach (Assets::getTypes() as $type) {
            $type = Assets::createType($type);

            if ($package->getType() === $type->getComposerType()) {
                return true;
            }
        }

        return false;
    }
396207
protected function getPackageExtra(PackageInterface $package, $key, $default = null)
    {
        $extra = $package->getExtra();

        return array_key_exists($key, $extra) ? $extra[ $key ] : $default;
    }
274358
protected function _getKoowaManifest(PackageInterface $package)
    {
        $path      = $this->getInstallPath($package);
        $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::KEY_AS_PATHNAME);
        $iterator  = new \RecursiveIteratorIterator($directory);
        $regex     = new \RegexIterator($iterator, '/koowa-component\.xml/', \RegexIterator::GET_MATCH);
        $files     = iterator_to_array($regex);

        if (empty($files)) {
            return false;
        }

        $manifests = array_keys($files);
        $manifest  = simplexml_load_file($manifests[0]);

        if (!($manifest instanceof \SimpleXMLElement))
        {
            throw new \InvalidArgumentException(
                'Failed to load `koowa-component.xml` manifest for package `'.$package->getPrettyName().'`.'
            );
        }

        return $manifest;
    }
45660
public function getRequiredVersion(RootPackageInterface $package)
    {
        foreach (array($package->getRequires(), $package->getDevRequires()) as $requiredPackages) {
            if (isset($requiredPackages[static::PACKAGE_NAME])) {
                return $requiredPackages[static::PACKAGE_NAME]->getPrettyConstraint();
            }
        }
        throw new \RuntimeException('Can not determine required version of ' . static::PACKAGE_NAME);
    }
921801
public function dropNewFiles(PackageInterface $package){

    //Gather all information for dropin directives
    $info = array();

    //Composer doesn't care about uppercase and so shouldn't we
    $info['package'] = strtolower($package->getName());
    $info['vendor'] = substr($info['package'], 0, strpos($info['package'], '/'));
    $info['type'] = $package->getType();

    #Locate absolute urls
    $projectDir = getcwd();

    #Get directives from composer.json
    $extra = $this->composer->getPackage()->getExtra();

    if (isset($extra['dropin-paths'])) {
      $paths = self::getPaths($extra['dropin-paths']);
    } else {
      //Stop here if dropin-paths is not defined.
      return;
    }

    $dest = self::installPath($info);

    //If dropin has nothing to do with this package just end it now
    if (!$dest) {
      return;
    }else {
      $dest = "{$projectDir}/{$dest}"; //Update to full path
    }

    //Compatibility with composer/installers
    if (class_exists('\\Composer\\Installers\\Installer')) {
      $installer = new Installer($this->io,$this->composer);
    } else {
      //System default
      $installer = new LibraryInstaller($this->io,$this->composer);
    }

    try {
      $src = realpath($installer->getInstallPath($package));
    } catch (\InvalidArgumentException $e) {
      // We will end up here if composer/installers doesn't recognise the type
      // In this case it's the default installation folder in vendor
      $vendorDir = $this->composer->getConfig()->get('vendor-dir');
      $vendorDir = realpath($vendorDir);
      $src = "{$vendorDir}/{$info['package']}";
    }

    $config = $this->composer->getPackage()->getConfig();
    $shouldCopy = isset($config['dropin-installer']) && $config['dropin-installer'] === 'copy';

    $installFiles = self::getFilesToInstall($info);
    if ($shouldCopy) {
      $this->io->write("    Copying dropin files...\n");
      if ($installFiles == "*") {
        self::rcopy($src, $dest);
      } else {
        foreach ($installFiles as $file) {
          self::copy("{$src}/{$file}", $dest);
        }
      }
    } else {
      $this->io->write("    Moving dropin files...\n");
      if ($installFiles == "*") {
        self::rmove($src, $dest);
      } else {
        foreach ($installFiles as $file) {
          self::move("{$src}/{$file}", $dest);
        }
      }
    }
  }