当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayLoader::load方法代码示例

本文整理汇总了PHP中Composer\Package\Loader\ArrayLoader::load方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayLoader::load方法的具体用法?PHP ArrayLoader::load怎么用?PHP ArrayLoader::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Composer\Package\Loader\ArrayLoader的用法示例。


在下文中一共展示了ArrayLoader::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getComposerPackage

 /**
  *
  * @param string $packageName
  * @return CompletePackage
  */
 public function getComposerPackage($packageName)
 {
     if ($this->composerCache->has($packageName)) {
         return $this->composerCache->get($packageName);
     }
     $package = $this->loader->load($this->getJson($this->getFile($packageName)));
     $this->composerCache->set($packageName, $package);
     return $package;
 }
开发者ID:keeko,项目名称:framework,代码行数:14,代码来源:PackageManager.php

示例2: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => '');
         if (!isset($package['version'])) {
             $package['version'] = $this->versionGuesser->guessVersion($package, $path) ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         } else {
             $package['dist']['reference'] = Locker::getContentHash($json);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
     if (count($this->getPackages()) == 0) {
         throw new \RuntimeException(sprintf('No `composer.json` file found in any path repository in "%s"', $this->url));
     }
 }
开发者ID:AppChecker,项目名称:composer,代码行数:33,代码来源:PathRepository.php

示例3: initialize

 /**
  * Initializes repository (reads file, or remote address).
  */
 protected function initialize()
 {
     parent::initialize();
     if (!$this->file->exists()) {
         return;
     }
     $packages = $this->file->read();
     if (!is_array($packages)) {
         throw new \UnexpectedValueException('Could not parse package list from the ' . $this->file->getPath() . ' repository');
     }
     $loader = new ArrayLoader();
     foreach ($packages as $packageData) {
         $package = $loader->load($packageData);
         // package was installed as alias, so we only add the alias
         if ($this instanceof InstalledRepositoryInterface && !empty($packageData['installed-as-alias'])) {
             $alias = $packageData['installed-as-alias'];
             $package->setAlias($alias);
             $package->setPrettyAlias($alias);
             $package->setInstalledAsAlias(true);
             $this->addPackage($this->createAliasPackage($package, $alias, $alias));
         } else {
             // only add regular package - if it's not an installed repo the alias will be created on the fly
             $this->addPackage($package);
         }
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:29,代码来源:FilesystemRepository.php

示例4: load

 public function load($config)
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     if (!isset($config['version'])) {
         $config['version'] = '1.0.0';
     }
     $package = parent::load($config);
     if (isset($config['repositories'])) {
         foreach ($config['repositories'] as $index => $repo) {
             if (isset($repo['packagist']) && $repo['packagist'] === false) {
                 continue;
             }
             if (!is_array($repo)) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' should be an array, ' . gettype($repo) . ' given');
             }
             if (!isset($repo['type'])) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' must have a type defined');
             }
             $repository = $this->manager->createRepository($repo['type'], $repo);
             $this->manager->addRepository($repository);
         }
         $package->setRepositories($config['repositories']);
     }
     return $package;
 }
开发者ID:natxet,项目名称:composer,代码行数:27,代码来源:RootPackageLoader.php

示例5: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     foreach ($this->getUrlMatches() as $url) {
         $path = realpath($url) . DIRECTORY_SEPARATOR;
         $composerFilePath = $path . 'composer.json';
         if (!file_exists($composerFilePath)) {
             continue;
         }
         $json = file_get_contents($composerFilePath);
         $package = JsonFile::parseJson($json, $composerFilePath);
         $package['dist'] = array('type' => 'path', 'url' => $url, 'reference' => sha1($json));
         $package['transport-options'] = $this->options;
         if (!isset($package['version'])) {
             $versionData = $this->versionGuesser->guessVersion($package, $path);
             $package['version'] = $versionData['version'] ?: 'dev-master';
         }
         $output = '';
         if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H', $output, $path)) {
             $package['dist']['reference'] = trim($output);
         }
         $package = $this->loader->load($package);
         $this->addPackage($package);
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:30,代码来源:PathRepository.php

示例6: prepareController

 /**
  * Mock the controller.
  *
  * @return \PHPUnit_Framework_MockObject_MockObject|PackageController
  */
 private function prepareController()
 {
     $manager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->setMethods(null)->getMock();
     $config = new Config();
     $config->merge(array('repositories' => array('packagist' => false)));
     $loader = new RootPackageLoader($manager, $config);
     $rootPackage = $loader->load(json_decode($this->readFixture('composer.json'), true));
     $loader = new ArrayLoader();
     $json = json_decode($this->readFixture('installed.json'), true);
     $packages = [];
     foreach ($json as $package) {
         $packages[] = $loader->load($package);
     }
     $manager->setLocalRepository(new WritableArrayRepository($packages));
     $composer = $this->getMockBuilder(Composer::class)->setMethods(['getPackage', 'getRepositoryManager'])->getMock();
     $composer->method('getPackage')->willReturn($rootPackage);
     $composer->method('getRepositoryManager')->willReturn($manager);
     $controller = $this->getMockBuilder(PackageController::class)->setMethods(['getComposer', 'forward'])->getMock();
     $controller->method('getComposer')->willReturn($composer);
     $home = $this->getMock(HomePathDeterminator::class, ['homeDir']);
     $home->method('homeDir')->willReturn($this->getTempDir());
     $composerJson = $this->provideFixture('composer.json');
     $this->provideFixture('composer.lock');
     $this->provideFixture('installed.json', 'vendor/composer/installed.json');
     $container = new Container();
     $container->set('tenside.home', $home);
     $container->set('tenside.composer_json', new ComposerJson($composerJson));
     /** @var PackageController $controller */
     $controller->setContainer($container);
     return $controller;
 }
开发者ID:tenside,项目名称:core-bundle,代码行数:36,代码来源:PackageControllerTest.php

示例7: load

 public function load(array $config, $class = 'Composer\\Package\\RootPackage')
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     $autoVersioned = false;
     if (!isset($config['version'])) {
         // override with env var if available
         if (getenv('COMPOSER_ROOT_VERSION')) {
             $version = getenv('COMPOSER_ROOT_VERSION');
         } else {
             $version = $this->versionGuesser->guessVersion($config, getcwd());
         }
         if (!$version) {
             $version = '1.0.0';
             $autoVersioned = true;
         }
         $config['version'] = $version;
     }
     $realPackage = $package = parent::load($config, $class);
     if ($realPackage instanceof AliasPackage) {
         $realPackage = $package->getAliasOf();
     }
     if ($autoVersioned) {
         $realPackage->replaceVersion($realPackage->getVersion(), 'No version set (parsed as 1.0.0)');
     }
     if (isset($config['minimum-stability'])) {
         $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
     }
     $aliases = array();
     $stabilityFlags = array();
     $references = array();
     foreach (array('require', 'require-dev') as $linkType) {
         if (isset($config[$linkType])) {
             $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
             $method = 'get' . ucfirst($linkInfo['method']);
             $links = array();
             foreach ($realPackage->{$method}() as $link) {
                 $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
             }
             $aliases = $this->extractAliases($links, $aliases);
             $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
             $references = $this->extractReferences($links, $references);
         }
     }
     $realPackage->setAliases($aliases);
     $realPackage->setStabilityFlags($stabilityFlags);
     $realPackage->setReferences($references);
     if (isset($config['prefer-stable'])) {
         $realPackage->setPreferStable((bool) $config['prefer-stable']);
     }
     $repos = Factory::createDefaultRepositories(null, $this->config, $this->manager);
     foreach ($repos as $repo) {
         $this->manager->addRepository($repo);
     }
     $realPackage->setRepositories($this->config->getRepositories());
     return $package;
 }
开发者ID:neoFaster,项目名称:composer,代码行数:58,代码来源:RootPackageLoader.php

示例8: load

 public function load($config)
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     if (!isset($config['version'])) {
         $version = '1.0.0';
         // try to fetch current version from git branch
         if (0 === $this->process->execute('git branch --no-color --no-abbrev -v', $output)) {
             foreach ($this->process->splitLines($output) as $branch) {
                 if ($branch && preg_match('{^(?:\\* ) *(?:[^/ ]+?/)?(\\S+) *[a-f0-9]+ .*$}', $branch, $match)) {
                     $version = 'dev-' . $match[1];
                 }
             }
         }
         // override with env var if available
         if (getenv('COMPOSER_ROOT_VERSION')) {
             $version = getenv('COMPOSER_ROOT_VERSION');
         }
         $config['version'] = $version;
     } else {
         $version = $config['version'];
     }
     $package = parent::load($config);
     $aliases = array();
     $stabilityFlags = array();
     $references = array();
     foreach (array('require', 'require-dev') as $linkType) {
         if (isset($config[$linkType])) {
             $aliases = $this->extractAliases($config[$linkType], $aliases);
             $stabilityFlags = $this->extractStabilityFlags($config[$linkType], $stabilityFlags);
             $references = $this->extractReferences($config[$linkType], $references);
         }
     }
     $package->setAliases($aliases);
     $package->setStabilityFlags($stabilityFlags);
     $package->setReferences($references);
     if (isset($config['minimum-stability'])) {
         $package->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
     }
     if (isset($config['repositories'])) {
         foreach ($config['repositories'] as $index => $repo) {
             if (isset($repo['packagist']) && $repo['packagist'] === false) {
                 continue;
             }
             if (!is_array($repo)) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' should be an array, ' . gettype($repo) . ' given');
             }
             if (!isset($repo['type'])) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' (' . json_encode($repo) . ') must have a type defined');
             }
             $repository = $this->manager->createRepository($repo['type'], $repo);
             $this->manager->addRepository($repository);
         }
         $package->setRepositories($config['repositories']);
     }
     return $package;
 }
开发者ID:romainneutron,项目名称:composer,代码行数:58,代码来源:RootPackageLoader.php

示例9: initialize

 /**
  * Initializes repository (reads file, or remote address).
  */
 protected function initialize()
 {
     parent::initialize();
     $loader = new ArrayLoader();
     foreach ($this->config as $package) {
         $package = $loader->load($package);
         $this->addPackage($package);
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:12,代码来源:PackageRepository.php

示例10: jsonToPackage

 /**
  * @return CompletePackage
  */
 protected function jsonToPackage($json)
 {
     $package = $this->loader->load($json);
     // @codeCoverageIgnoreStart
     if (!$package instanceof CompletePackage) {
         throw new UnexpectedValueException('Expected instance of CompletePackage, got ' . get_class($package));
     }
     // @codeCoverageIgnoreEnd
     return $package;
 }
开发者ID:JasLin,项目名称:composer-merge-plugin,代码行数:13,代码来源:MergePlugin.php

示例11: testNotAbandoned

    public function testNotAbandoned()
    {
        $config = array(
            'name' => 'A',
            'version' => '1.2.3.4'
        );

        $package = $this->loader->load($config);
        $this->assertFalse($package->isAbandoned());
    }
开发者ID:ncusoho,项目名称:composer,代码行数:10,代码来源:ArrayLoaderTest.php

示例12: load

 /**
  * @param  array            $config
  * @param  string           $class
  * @return PackageInterface
  */
 public function load(array $config, $class = 'Composer\\Package\\RootPackage')
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     if (!isset($config['version'])) {
         $config['version'] = '999999';
     }
     return parent::load($config, $class);
 }
开发者ID:bcncommerce,项目名称:magebuild,代码行数:15,代码来源:RootPackageLoader.php

示例13: load

 public function load($json)
 {
     if ($json instanceof JsonFile) {
         $config = $json->read();
     } elseif (file_exists($json)) {
         $config = JsonFile::parseJson(file_get_contents($json));
     } elseif (is_string($json)) {
         $config = JsonFile::parseJson($json);
     }
     return parent::load($config);
 }
开发者ID:nlegoff,项目名称:composer,代码行数:11,代码来源:JsonLoader.php

示例14: load

 public function load($config)
 {
     if (!isset($config['name'])) {
         $config['name'] = '__root__';
     }
     if (!isset($config['version'])) {
         // override with env var if available
         if (getenv('COMPOSER_ROOT_VERSION')) {
             $version = getenv('COMPOSER_ROOT_VERSION');
         } else {
             $version = $this->guessVersion($config);
         }
         if (!$version) {
             $version = '1.0.0';
         }
         $config['version'] = $version;
     } else {
         $version = $config['version'];
     }
     $package = parent::load($config);
     $aliases = array();
     $stabilityFlags = array();
     $references = array();
     foreach (array('require', 'require-dev') as $linkType) {
         if (isset($config[$linkType])) {
             $aliases = $this->extractAliases($config[$linkType], $aliases);
             $stabilityFlags = $this->extractStabilityFlags($config[$linkType], $stabilityFlags);
             $references = $this->extractReferences($config[$linkType], $references);
         }
     }
     $package->setAliases($aliases);
     $package->setStabilityFlags($stabilityFlags);
     $package->setReferences($references);
     if (isset($config['minimum-stability'])) {
         $package->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
     }
     if (isset($config['repositories'])) {
         foreach ($config['repositories'] as $index => $repo) {
             if (isset($repo['packagist']) && $repo['packagist'] === false) {
                 continue;
             }
             if (!is_array($repo)) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' should be an array, ' . gettype($repo) . ' given');
             }
             if (!isset($repo['type'])) {
                 throw new \UnexpectedValueException('Repository ' . $index . ' (' . json_encode($repo) . ') must have a type defined');
             }
             $repository = $this->manager->createRepository($repo['type'], $repo);
             $this->manager->addRepository($repository);
         }
         $package->setRepositories($config['repositories']);
     }
     return $package;
 }
开发者ID:nicodmf,项目名称:composer,代码行数:54,代码来源:RootPackageLoader.php

示例15: convert

 /**
  * Convert json to Package.
  *
  * @param  array  $json
  *
  * @return \Composer\Package\CompletePackage
  *
  * @throws \Arcanedev\Composer\Exceptions\InvalidPackageException
  */
 public static function convert(array $json)
 {
     $loader = new ArrayLoader();
     $package = $loader->load($json);
     if ($package instanceof CompletePackage) {
         return $package;
     }
     // @codeCoverageIgnoreStart
     throw new InvalidPackageException('Expected instance of CompletePackage, got ' . get_class($package));
     // @codeCoverageIgnoreEnd
 }
开发者ID:arcanedev,项目名称:composer,代码行数:20,代码来源:PackageJson.php


注:本文中的Composer\Package\Loader\ArrayLoader::load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。