當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PackageInterface::getAutoload方法代碼示例

本文整理匯總了PHP中Composer\Package\PackageInterface::getAutoload方法的典型用法代碼示例。如果您正苦於以下問題:PHP PackageInterface::getAutoload方法的具體用法?PHP PackageInterface::getAutoload怎麽用?PHP PackageInterface::getAutoload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Composer\Package\PackageInterface的用法示例。


在下文中一共展示了PackageInterface::getAutoload方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: primaryNamespace

 /**
  * Get the primary namespace for a plugin package.
  *
  * @param \Composer\Package\PackageInterface $package composer object
  * @return string The package's primary namespace.
  * @throws \RuntimeException When the package's primary namespace cannot be determined.
  */
 public function primaryNamespace($package)
 {
     $primaryNs = null;
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $pathMap) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($pathMap);
         if ($count === 1) {
             $primaryNs = key($pathMap);
             break;
         }
         $matches = preg_grep('#^(\\./)?src/?$#', $pathMap);
         if ($matches) {
             $primaryNs = key($matches);
             break;
         }
         foreach (['', '.'] as $path) {
             $key = array_search($path, $pathMap, true);
             if ($key !== false) {
                 $primaryNs = $key;
             }
         }
         break;
     }
     if (!$primaryNs) {
         throw new RuntimeException(sprintf("Unable to get primary namespace for package %s." . "\nEnsure you have added proper 'autoload' section to your plugin's config", $package->getName()));
     }
     return trim($primaryNs, '\\');
 }
開發者ID:CoreTyson,項目名稱:plugin-installer,代碼行數:38,代碼來源:Installer.php

示例2: getPackageBasePath

 /**
  * {@inheritDoc}
  *
  * @throws \RuntimeException
  */
 public function getPackageBasePath(PackageInterface $package)
 {
     $extra = $package->getExtra();
     if (!empty($extra['installer-name'])) {
         return 'plugins/' . $extra['installer-name'];
     }
     $primaryNS = null;
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $pathMap) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($pathMap);
         if ($count === 1) {
             $primaryNS = key($pathMap);
             break;
         }
         $matches = preg_grep('#^(\\./)?src/?$#', $pathMap);
         if ($matches) {
             $primaryNS = key($matches);
             break;
         }
         foreach (['', '.'] as $path) {
             $key = array_search($path, $pathMap, true);
             if ($key !== false) {
                 $primaryNS = $key;
             }
         }
         break;
     }
     if (!$primaryNS) {
         throw new \RuntimeException('Unable to get CakePHP plugin name.');
     }
     return 'plugins/' . trim(str_replace('\\', '/', $primaryNS), '/');
 }
開發者ID:maitrepylos,項目名稱:nazeweb,代碼行數:40,代碼來源:PluginInstaller.php

示例3: getPathName

 /**
  * Returns the path name for given package.
  *
  * @param PackageInterface $package Package to install.
  * @return string path name.
  */
 public static function getPathName(PackageInterface $package)
 {
     $autoload = $package->getAutoload();
     if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) {
         $namespace = key($autoload['psr-4']);
     } elseif (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) {
         $namespace = key($autoload['psr-0']);
     } else {
         throw new \InvalidArgumentException('Your Package needs to support PSR-4 or at least PSR-0.');
     }
     return rtrim(str_replace('\\', '.', $namespace), '.');
 }
開發者ID:google-code-backups,項目名稱:xinc,代碼行數:18,代碼來源:Installer.php

示例4: uninstall

 /**
  * {@inheritDoc}
  */
 public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
 {
     $installedModules = $this->getInstalledModules();
     $filePath = $this->getConfigFilePath();
     // Get package information
     $name = $package->getPrettyName();
     $autoload = $package->getAutoload();
     // Remove the module from the list
     $installedModules = $this->array_remove_object($installedModules, $name, 'name');
     // Remove duplicated entries
     $installedModules = array_unique($installedModules, SORT_REGULAR);
     // Write to file
     $prettyJson = json_encode($installedModules, JSON_PRETTY_PRINT | JSON_NUMERIC_CHECK);
     file_put_contents($filePath, $prettyJson);
     parent::uninstall($repo, $package);
 }
開發者ID:mc388,項目名稱:slim-composer-installer,代碼行數:19,代碼來源:Installer.php

示例5: generatePackagetAlias

 protected function generatePackagetAlias(PackageInterface $package)
 {
     $fs = new Filesystem();
     $autoload = $package->getAutoload();
     $baseDir = $this->baseDir;
     $aliases = [];
     if (!empty($autoload['psr-0'])) {
         foreach ($autoload['psr-0'] as $name => $path) {
             $name = str_replace('\\', '/', trim($name, '\\'));
             if (!$fs->isAbsolutePath($path)) {
                 $path = $baseDir . '/' . $path;
             }
             $path = $fs->normalizePath($path);
             if (strpos($path . '/', $baseDir . '/') === 0) {
                 $aliases["@{$name}"] = '<base-dir>' . substr($path, strlen($baseDir)) . '/' . $name;
             } else {
                 $aliases["@{$name}"] = $path . '/' . $name;
             }
         }
     }
     if (!empty($autoload['psr-4'])) {
         foreach ($autoload['psr-4'] as $name => $path) {
             $name = str_replace('\\', '/', trim($name, '\\'));
             if (!$fs->isAbsolutePath($path)) {
                 $path = $baseDir . '/' . $path;
             }
             $path = $fs->normalizePath($path);
             if (strpos($path . '/', $baseDir . '/') === 0) {
                 $aliases["@{$name}"] = '<base-dir>' . substr($path, strlen($baseDir));
             } else {
                 $aliases["@{$name}"] = $path;
             }
         }
     }
     return $aliases;
 }
開發者ID:deesoft,項目名稱:yii2-composer,代碼行數:36,代碼來源:Installer.php

示例6: updateInformation

 private function updateInformation(Package $package, PackageInterface $data, $flags)
 {
     $em = $this->doctrine->getManager();
     $version = new Version();
     $normVersion = $data->getVersion();
     $existingVersion = $package->getVersion($normVersion);
     if ($existingVersion) {
         $source = $existingVersion->getSource();
         // update if the right flag is set, or the source reference has changed (re-tag or new commit on branch)
         if ($source['reference'] !== $data->getSourceReference() || $flags & self::UPDATE_EQUAL_REFS) {
             $version = $existingVersion;
         } else {
             // mark it updated to avoid it being pruned
             $existingVersion->setUpdatedAt(new \DateTime());
             return false;
         }
     }
     $version->setName($package->getName());
     $version->setVersion($data->getPrettyVersion());
     $version->setNormalizedVersion($normVersion);
     $version->setDevelopment($data->isDev());
     $em->persist($version);
     $descr = $this->sanitize($data->getDescription());
     $version->setDescription($descr);
     $package->setDescription($descr);
     $version->setHomepage($data->getHomepage());
     $version->setLicense($data->getLicense() ?: array());
     $version->setPackage($package);
     $version->setUpdatedAt(new \DateTime());
     $version->setReleasedAt($data->getReleaseDate());
     if ($data->getSourceType()) {
         $source['type'] = $data->getSourceType();
         $source['url'] = $data->getSourceUrl();
         $source['reference'] = $data->getSourceReference();
         $version->setSource($source);
     } else {
         $version->setSource(null);
     }
     if ($data->getDistType()) {
         $dist['type'] = $data->getDistType();
         $dist['url'] = $data->getDistUrl();
         $dist['reference'] = $data->getDistReference();
         $dist['shasum'] = $data->getDistSha1Checksum();
         $version->setDist($dist);
     } else {
         $version->setDist(null);
     }
     if ($data->getType()) {
         $type = $this->sanitize($data->getType());
         $version->setType($type);
         if ($type !== $package->getType()) {
             $package->setType($type);
         }
     }
     $version->setTargetDir($data->getTargetDir());
     $version->setAutoload($data->getAutoload());
     $version->setExtra($data->getExtra());
     $version->setBinaries($data->getBinaries());
     $version->setIncludePaths($data->getIncludePaths());
     $version->setSupport($data->getSupport());
     if ($data->getKeywords()) {
         $keywords = array();
         foreach ($data->getKeywords() as $keyword) {
             $keywords[mb_strtolower($keyword, 'UTF-8')] = $keyword;
         }
         $existingTags = [];
         foreach ($version->getTags() as $tag) {
             $existingTags[mb_strtolower($tag->getName(), 'UTF-8')] = $tag;
         }
         foreach ($keywords as $tagKey => $keyword) {
             if (isset($existingTags[$tagKey])) {
                 unset($existingTags[$tagKey]);
                 continue;
             }
             $tag = Tag::getByName($em, $keyword, true);
             if (!$version->getTags()->contains($tag)) {
                 $version->addTag($tag);
             }
         }
         foreach ($existingTags as $tag) {
             $version->getTags()->removeElement($tag);
         }
     } elseif (count($version->getTags())) {
         $version->getTags()->clear();
     }
     $authorRepository = $this->doctrine->getRepository('PackagistWebBundle:Author');
     $version->getAuthors()->clear();
     if ($data->getAuthors()) {
         foreach ($data->getAuthors() as $authorData) {
             $author = null;
             foreach (array('email', 'name', 'homepage', 'role') as $field) {
                 if (isset($authorData[$field])) {
                     $authorData[$field] = trim($authorData[$field]);
                     if ('' === $authorData[$field]) {
                         $authorData[$field] = null;
                     }
                 } else {
                     $authorData[$field] = null;
                 }
             }
//.........這裏部分代碼省略.........
開發者ID:jakoch,項目名稱:packagist,代碼行數:101,代碼來源:Updater.php

示例7: getAutoload

 /**
  * {@inheritdoc}
  */
 public function getAutoload()
 {
     return $this->package->getAutoload();
 }
開發者ID:tenside,項目名稱:core,代碼行數:7,代碼來源:VersionedPackage.php

示例8: generateDefaultAlias

 protected function generateDefaultAlias(PackageInterface $package)
 {
     $fs = new Filesystem();
     $vendorDir = $fs->normalizePath($this->vendorDir);
     $autoload = $package->getAutoload();
     $aliases = [];
     if (!empty($autoload['psr-0'])) {
         foreach ($autoload['psr-0'] as $name => $path) {
             $name = str_replace('\\', '/', trim($name, '\\'));
             if (!$fs->isAbsolutePath($path)) {
                 $path = $this->vendorDir . '/' . $package->getPrettyName() . '/' . $path;
             }
             $path = $fs->normalizePath($path);
             if (strpos($path . '/', $vendorDir . '/') === 0) {
                 $aliases["@{$name}"] = '<vendor-dir>' . substr($path, strlen($vendorDir)) . '/' . $name;
             } else {
                 $aliases["@{$name}"] = $path . '/' . $name;
             }
         }
     }
     if (!empty($autoload['psr-4'])) {
         foreach ($autoload['psr-4'] as $name => $path) {
             if (is_array($path)) {
                 // ignore psr-4 autoload specifications with multiple search paths
                 // we can not convert them into aliases as they are ambiguous
                 continue;
             }
             $name = str_replace('\\', '/', trim($name, '\\'));
             if (!$fs->isAbsolutePath($path)) {
                 $path = $this->vendorDir . '/' . $package->getPrettyName() . '/' . $path;
             }
             $path = $fs->normalizePath($path);
             if (strpos($path . '/', $vendorDir . '/') === 0) {
                 $aliases["@{$name}"] = '<vendor-dir>' . substr($path, strlen($vendorDir));
             } else {
                 $aliases["@{$name}"] = $path;
             }
         }
     }
     return $aliases;
 }
開發者ID:dieos2,項目名稱:bolaoyyi2,代碼行數:41,代碼來源:Installer.php

示例9: registerWithPackage

 /**
  * @param PackageInterface $package
  * @param $output
  *
  * Register a Bundle with package given
  */
 private static function registerWithPackage(PackageInterface $package, $output)
 {
     if ('symfony-bundle' !== $package->getType()) {
         $output->write('<error>' . $package->getName() . ' is not a symfony bundle</error>', true);
         return;
     }
     // get package directory
     $dir = self::getRootDir() . 'vendor/' . $package->getName();
     // scan directory for Bundle file
     $needle = 'Bundle.php';
     $bundleFile = array_merge(array_filter(scandir($dir), function ($haystack) use($needle) {
         return $needle === "" || ($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== false;
     }));
     if (count($bundleFile) == 0) {
         $output->write('<error>Error: Bundle not fount in folder ' . $dir . '</error>', true);
         return;
     }
     // create fully qualified name from bundle class
     $bundleClass = str_replace('.php', '', $bundleFile[0]);
     $autoload = $package->getAutoload();
     if (isset($autoload['psr-4'])) {
         $fullyQualifiedNamespace = array_keys($package->getAutoload()['psr-4'])[0] . $bundleClass;
     } elseif (isset($autoload['psr-0'])) {
         $fullyQualifiedNamespace = array_keys($package->getAutoload()['psr-0'])[0] . $bundleClass;
     } else {
         $output->write('<error>Error: Cannot read package namespace from autoloading section</error>', true);
         return;
     }
     self::registerWithNamespace($fullyQualifiedNamespace, $output);
 }
開發者ID:fuzzyma,項目名稱:composer-register-bundle-plugin,代碼行數:36,代碼來源:RegisterCommand.php

示例10: getPrimaryNamespace

 /**
  * Get primary namespace
  *
  * @param PackageInterface $package
  *
  * @return string
  */
 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;
 }
開發者ID:radphp,項目名稱:composer-installer,代碼行數:33,代碼來源:BundleInstaller.php

示例11: setInstallerName

 /**
  * Set installer-name based on namespace for the source path
  *
  * With one autoload path this will be used as installer-name.
  * With two autoload paths the first non `tests` foldername will be set.
  * If more then 2 autoload paths are provided, installer-name will only be
  * set for if `src` folder is used.
  *
  * @param PackageInterface $package
  */
 protected function setInstallerName(PackageInterface $package)
 {
     $autoLoad = $package->getAutoload();
     foreach ($autoLoad as $type => $typeConfig) {
         if ($type !== 'psr-4') {
             continue;
         }
         $count = count($typeConfig);
         foreach ($typeConfig as $namespace => $path) {
             if ($path === 'tests') {
                 continue;
             }
             if ($count > 2 && $path !== 'src') {
                 continue;
             }
             $installerName = trim(str_replace('\\', '/', $namespace), '/');
             $package->setExtra(array('installer-name' => $installerName));
         }
         break;
     }
 }
開發者ID:grBro,項目名稱:taskmanager,代碼行數:31,代碼來源:CakePHPInstaller.php

示例12: prepareAliases

 /**
  * Prepare aliases.
  *
  * @param PackageInterface $package
  * @param string 'psr-0' or 'psr-4'
  * @return array
  */
 protected function prepareAliases(PackageInterface $package, $psr)
 {
     $autoload = $package->getAutoload();
     if (empty($autoload[$psr])) {
         return [];
     }
     $aliases = [];
     foreach ($autoload[$psr] as $name => $path) {
         if (is_array($path)) {
             // ignore psr-4 autoload specifications with multiple search paths
             // we can not convert them into aliases as they are ambiguous
             continue;
         }
         $name = str_replace('\\', '/', trim($name, '\\'));
         $path = $this->preparePath($package, $path);
         $path = $this->substitutePath($path, $this->getBaseDir(), self::BASE_DIR_SAMPLE);
         if ('psr-0' === $psr) {
             $path .= '/' . $name;
         }
         $aliases["@{$name}"] = $path;
     }
     return $aliases;
 }
開發者ID:hiqdev,項目名稱:composer-extension-plugin,代碼行數:30,代碼來源:Plugin.php

示例13: updateInformation

 private function updateInformation(OutputInterface $output, RegistryInterface $doctrine, $package, PackageInterface $data)
 {
     $em = $doctrine->getEntityManager();
     $version = new Version();
     $version->setName($package->getName());
     $version->setNormalizedVersion(preg_replace('{-dev$}i', '', $data->getVersion()));
     // check if we have that version yet
     foreach ($package->getVersions() as $existingVersion) {
         if ($existingVersion->equals($version)) {
             // avoid updating newer versions, in case two branches have the same version in their composer.json
             if ($existingVersion->getReleasedAt() > $data->getReleaseDate()) {
                 return;
             }
             if ($existingVersion->getDevelopment()) {
                 $version = $existingVersion;
                 break;
             }
             return;
         }
     }
     $version->setVersion($data->getPrettyVersion());
     $version->setDevelopment(substr($data->getVersion(), -4) === '-dev');
     $em->persist($version);
     $version->setDescription($data->getDescription());
     $package->setDescription($data->getDescription());
     $version->setHomepage($data->getHomepage());
     $version->setLicense($data->getLicense() ?: array());
     $version->setPackage($package);
     $version->setUpdatedAt(new \DateTime());
     $version->setReleasedAt($data->getReleaseDate());
     if ($data->getSourceType()) {
         $source['type'] = $data->getSourceType();
         $source['url'] = $data->getSourceUrl();
         $source['reference'] = $data->getSourceReference();
         $version->setSource($source);
     }
     if ($data->getDistType()) {
         $dist['type'] = $data->getDistType();
         $dist['url'] = $data->getDistUrl();
         $dist['reference'] = $data->getDistReference();
         $dist['shasum'] = $data->getDistSha1Checksum();
         $version->setDist($dist);
     }
     if ($data->getType()) {
         $version->setType($data->getType());
         if ($data->getType() && $data->getType() !== $package->getType()) {
             $package->setType($data->getType());
         }
     }
     $version->setTargetDir($data->getTargetDir());
     $version->setAutoload($data->getAutoload());
     $version->setExtra($data->getExtra());
     $version->setBinaries($data->getBinaries());
     $version->getTags()->clear();
     if ($data->getKeywords()) {
         foreach ($data->getKeywords() as $keyword) {
             $version->addTag(Tag::getByName($em, $keyword, true));
         }
     }
     $version->getAuthors()->clear();
     if ($data->getAuthors()) {
         foreach ($data->getAuthors() as $authorData) {
             $author = null;
             // skip authors with no information
             if (empty($authorData['email']) && empty($authorData['name'])) {
                 continue;
             }
             if (!empty($authorData['email'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByEmail($authorData['email']);
             }
             if (!$author && !empty($authorData['homepage'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneBy(array('name' => $authorData['name'], 'homepage' => $authorData['homepage']));
             }
             if (!$author && !empty($authorData['name'])) {
                 $author = $doctrine->getRepository('PackagistWebBundle:Author')->findOneByNameAndPackage($authorData['name'], $package);
             }
             if (!$author) {
                 $author = new Author();
                 $em->persist($author);
             }
             foreach (array('email', 'name', 'homepage') as $field) {
                 if (isset($authorData[$field])) {
                     $author->{'set' . $field}($authorData[$field]);
                 }
             }
             $author->setUpdatedAt(new \DateTime());
             if (!$version->getAuthors()->contains($author)) {
                 $version->addAuthor($author);
             }
             if (!$author->getVersions()->contains($version)) {
                 $author->addVersion($version);
             }
         }
     }
     foreach ($this->supportedLinkTypes as $linkType => $linkEntity) {
         $links = array();
         foreach ($data->{'get' . $linkType . 's'}() as $link) {
             $links[$link->getTarget()] = $link->getPrettyConstraint();
         }
         foreach ($version->{'get' . $linkType}() as $link) {
//.........這裏部分代碼省略.........
開發者ID:nesQuick,項目名稱:packagist,代碼行數:101,代碼來源:UpdatePackagesCommand.php

示例14: getAutoload

 public function getAutoload()
 {
     return $this->aliasOf->getAutoload();
 }
開發者ID:neon64,項目名稱:composer,代碼行數:4,代碼來源:AliasPackage.php

示例15: getFQCN

 /**
  * Try to determine the package name with the filename and
  * the package autoload definition.
  * This won't work 100%, f.e. with Bundles that have only have
  * an autoloader prefix, instead of the full namespace untill the BundleFile
  *
  * @param  \Composer\Package\PackageInterface $package
  * @param  type                               $bundleFileName
  * @return string
  */
 public function getFQCN(PackageInterface $package, $bundleFileName)
 {
     $bundleName = substr(basename($bundleFileName), 0, -4);
     $autoload = $package->getAutoload();
     if (isset($autoload['psr-0'])) {
         $namespace = key($autoload['psr-0']);
         return rtrim($namespace, '\\') . '\\' . $bundleName;
     }
     if (isset($autoload['psr-4'])) {
         $namespace = key($autoload['psr-4']);
         return $namespace . $bundleName;
     }
     return $bundleName;
 }
開發者ID:frogriotcom,項目名稱:CheckBundles,代碼行數:24,代碼來源:ComposerHelper.php


注:本文中的Composer\Package\PackageInterface::getAutoload方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。