Retrieve the pattern for the given package.

@param \Composer\Package\PackageInterface $package

@return string
116
public function getPattern(PackageInterface $package)
    {
        if (isset($this->packages[$package->getName()])) {
            return $this->packages[$package->getName()];
        } elseif (isset($this->packages[$package->getPrettyName()])) {
            return $this->packages[$package->getPrettyName()];
        } elseif (isset($this->types[$package->getType()])) {
            return $this->types[$package->getType()];
        }
    }
1327094
public function getPatchesFor(PackageInterface $package)
    {
        $patches = array();
        foreach ($this->getPatches() as $patch) {
            if ($patch->isForPackage($package)) {
                $patches[] = $patch;
            }
        }
        $result = new static();
        $result->patches = $patches;

        return $result;
    }
43684
public function getManifest($package)
    {
        if (is_array($package['extra'][self::EXTRA_FIELD])) {
            return $package['extra'][self::EXTRA_FIELD];
        } else if (is_string($package['extra'][self::EXTRA_FIELD])) {
            $manifestFile = $this->vendorPath . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $package['extra'][self::EXTRA_FIELD];
            if (is_file($manifestFile)) {
                return include($manifestFile);
            }
        }
        return [];
    }
599239
public function processPackage(PackageInterface $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        if ($package->getType() !== self::PACKAGE_TYPE && is_null($files)) {
            return;
        }

        $extension = [
            'name'    => $package->getName(),
            'version' => $package->getVersion(),
        ];
        if ($package->getVersion() === '9999999-dev') {
            $reference = $package->getSourceReference() ?: $package->getDistReference();
            if ($reference) {
                $extension['reference'] = $reference;
            }
        }
        $this->data['extensions'][$package->getName()] = $extension;

        $aliases = array_merge(
            $this->prepareAliases($package, 'psr-0'),
            $this->prepareAliases($package, 'psr-4')
        );
        $this->data['aliases'] = array_merge($this->data['aliases'], $aliases);
        foreach ((array) $files as $name => $path) {
            $config = $this->readExtensionConfig($package, $path);
            $config['aliases'] = array_merge(
                $aliases,
                isset($config['aliases']) ? (array) $config['aliases'] : []
            );
            $this->data['aliases'] = array_merge($this->data['aliases'], $config['aliases']);
            $this->data[$name] = isset($this->data[$name]) ? Helper::mergeConfig($this->data[$name], $config) : $config;
        }
    }
1105723
public function getInstallPath(PackageInterface $package)
	{
		$prefix = mb_substr($package->getPrettyName(), 0, 23);
		if ('myadmin/template-' !== $prefix) {
			throw new \InvalidArgumentException(
				'Unable to install template, myadmin templates '
				.'should always start their package name with '
				.'"myadmin/template-"'
			);
		}
		return 'data/templates/'.mb_substr($package->getPrettyName(), 23);
	}
1030749
protected function getEntryFileLocations(PackageInterface $package)
    {
        $muPluginsDir = dirname($this->composer->getInstallationManager()->getInstallPath($package));

        return array_reduce(
            $this->getPackageEntryPoints($package),
            function ($locations, $entryPoint) use ($muPluginsDir) {
                $locations[ $entryPoint ] =  $muPluginsDir . DIRECTORY_SEPARATOR . basename($entryPoint);

                return $locations;
            },
            []
        );
    }
186432
public function isPackageInstalled(PackageInterface $package)
    {
        return $this->filesystem->exists($this->config->getInstallDir() . '/' . $package->getName() . '/.bower.json');
    }
890536
protected function loadInits(PackageInterface $package)
    {
        if (!$package->getInits()) {
            return $this;
        }

        $initLoader = \Parable\DI\Container::create(\Parable\Framework\Loader\InitLoader::class);
        $initLoader->load($package->getInits());
        return $this;
    }
742359
protected function getSourceStandards(PackageInterface $package)
    {
        $basePath = $this->getInstallPath($package);

        return $this->findStandards($basePath);
    }
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;
    }
1040418
public function getInstallPath(PackageInterface $package)
    {
        $type = $package->getType();

        // Both prettyName and name consists of vendor and name, module name
        // requires vendor prefix to be stripped
        $prettyName = $package->getPrettyName();

        if (strpos($prettyName, '/') !== false) {
            list($vendor, $name) = explode('/', $prettyName);
        } else {
            $vendor = '';
            $name = $prettyName;
        }

        // Naming conventions for ZF1 modules require that the camel cased
        // module name must match the class prefix - so it's up to module
        // author or publisher to ensure that module name is correct.
        // If an installer-name extra is specified in module composer.json
        // it will be used as a name part of the installation path.
        $extra = $package->getExtra();
        if (!empty($extra['installer-name'])) {
            $name = $extra['installer-name'];
        }

        $availableVars = compact('name', 'vendor', 'type');

        if ($this->composer->getPackage()) {
            $extra = $this->composer->getPackage()->getExtra();
            if (!empty($extra['installer-paths'])) {
                $customPath = $this->_mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor);
                if ($customPath !== false) {
                    return $this->_templatePath($customPath, $availableVars);
                }
            }
        }

        return $this->_templatePath('application/modules/{$name}', $availableVars);
    }
681131
public function getLoaderInstallPath(PackageInterface $package)
    {
        $config      = $this->getInstallerConfig($package);
        $installPath = 'wp-content/mu-plugins/';

        if (!$this->composer->getPackage()) {
            return $this->parseTemplate($installPath, $config);
        }

        $extra      = $this->composer->getPackage()->getExtra();
        $prettyName = !empty($config['vendor']) ? ($config['vendor'] . '/') : '';
        $prettyName = $prettyName . $config['name'];

        if (!empty($extra['installer-loader-paths'])) {
            $customPath = $this->resolveInstallPath($extra['installer-loader-paths'], $prettyName);

            if ($customPath !== false) {
                $installPath = $customPath;
            }
        }

        return $this->parseTemplate($installPath, $config);
    }
1151607
protected function getRootPath(PackageInterface $package)
    {
        $rootPath = $this->vendorDir . '/raulfraile/ladybug-themes/Ladybug/';

        if ($this->composer->getPackage()->getName() === 'raulfraile/ladybug') {
            $rootPath = 'data/' . ($package->getType() === self::PACKAGE_TYPE_THEME ? 'themes' : 'plugins') . '/Ladybug/';
        }

        $rootPath .= ($package->getType() === self::PACKAGE_TYPE_THEME) ? 'Theme' : 'Plugin';

        return $rootPath;
    }
32865
protected function mustUninstallPackage(PackageInterface $package)
    {
        if ($package instanceof AliasPackage) {
            return false;
        }
        $packageExtra = $package->getExtra();
        $packageHasAppliedPatches = !empty($packageExtra['patches_applied']);
        $packagePatches = $this->getPatchCollection()->getPatchesFor($package);
        $packageHasPatches = !$packagePatches->isEmpty();
        if ($packageHasAppliedPatches === false && $packageHasPatches === false) {
            return false;
        }
        if ($packageHasAppliedPatches === true && $packageHasPatches === true) {
            $installedHash = empty($packageExtra['patches_applied']['hash']) ? '' : $packageExtra['patches_applied']['hash'];
            if ($installedHash === '') {
                return true;
            }
            $patchesHash = $packagePatches->getHash();
            if ($installedHash !== $patchesHash) {
                return true;
            }
        }

        return false;
    }
1251757
public function getSourcePath(PackageInterface $package)
    {
        return !$package instanceof \Composer\Package\RootPackage
            ? $this->installationManager->getInstallPath($package)
            : realpath(dirname(\Composer\Factory::getComposerFile()));
    }
1066241
protected function getPackageMigrationPaths(string $package): array
    {
        return collect($this->option('path') ?: 'database/migrations')
                    ->map(function ($path) use ($package) {
                        return $this->packagePath.'/'.$package.'/'.$path;
                    })->all();
    }
898208
public function getFileList( PackageInterface $package, $map ) {
    $directory = $this->getDirectory( $package );
    $result    = [];

    try {

      foreach( $map as $source => $destination ) {
        if( !is_dir( $directory . $source ) ) $result[ $directory . $source ] = Autoload::DIRECTORY . $destination;
        else {

          $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator( $directory . $source, \RecursiveDirectoryIterator::SKIP_DOTS ),
            \RecursiveIteratorIterator::SELF_FIRST
          );

          foreach( $iterator as $item ) {
            /** @var SplFileInfo $item */
            if( !$item->isDir() ) {
              $result[ $item->getRealPath() ] = Autoload::DIRECTORY . $destination . DIRECTORY_SEPARATOR . call_user_func( [ $iterator, 'getSubPathName' ] );
            }
          }
        }
      }

    } catch( \Throwable $e ) {
      $this->io->writeError( "Spoom\\Composer: Skip {$package->getPrettyName()} public copy, due to an error" );
    }

    return $result;
  }