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


PHP ArrayRepository::initialize方法代码示例

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


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

示例1: initialize

 protected function initialize()
 {
     parent::initialize();
     if (!extension_loaded('openssl') && 'https' === substr($this->url, 0, 5)) {
         throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from ' . $this->url);
     }
     try {
         $json = new JsonFile($this->url . '/packages.json', new RemoteFilesystem($this->io));
         $data = $json->read();
         if (!empty($data['notify'])) {
             if ('/' === $data['notify'][0]) {
                 $this->notifyUrl = preg_replace('{(https?://[^/]+).*}i', '$1' . $data['notify'], $this->url);
             } else {
                 $this->notifyUrl = $data['notify'];
             }
         }
         $this->cache->write('packages.json', json_encode($data));
     } catch (\Exception $e) {
         if ($contents = $this->cache->read('packages.json')) {
             $this->io->write('<warning>' . $this->url . ' could not be loaded, package information was loaded from the local cache and may be out of date</warning>');
             $data = json_decode($contents, true);
         } else {
             throw $e;
         }
     }
     $loader = new ArrayLoader();
     $this->loadRepository($loader, $data);
 }
开发者ID:nickl-,项目名称:composer,代码行数:28,代码来源:ComposerRepository.php

示例2: initialize

 protected function initialize()
 {
     parent::initialize();
     $versionParser = new VersionParser();
     try {
         $prettyVersion = PHP_VERSION;
         $version = $versionParser->normalize($prettyVersion);
     } catch (\UnexpectedValueException $e) {
         $prettyVersion = preg_replace('#^(.+?)(-.+)?$#', '$1', PHP_VERSION);
         $version = $versionParser->normalize($prettyVersion);
     }
     $php = new MemoryPackage('php', $version, $prettyVersion);
     $php->setDescription('The PHP interpreter');
     parent::addPackage($php);
     foreach (get_loaded_extensions() as $name) {
         if (in_array($name, array('standard', 'Core'))) {
             continue;
         }
         $reflExt = new \ReflectionExtension($name);
         try {
             $prettyVersion = $reflExt->getVersion();
             $version = $versionParser->normalize($prettyVersion);
         } catch (\UnexpectedValueException $e) {
             $prettyVersion = '0';
             $version = $versionParser->normalize($prettyVersion);
         }
         $ext = new MemoryPackage('ext-' . $name, $version, $prettyVersion);
         $ext->setDescription('The ' . $name . ' PHP extension');
         parent::addPackage($ext);
     }
 }
开发者ID:nlegoff,项目名称:composer,代码行数:31,代码来源:PlatformRepository.php

示例3: initialize

 protected function initialize()
 {
     parent::initialize();
     $this->io->write('Initializing PEAR repository ' . $this->url);
     $this->initializeChannel();
     $this->io->write('Packages names will be prefixed with: pear-' . $this->channel . '/');
     // try to load as a composer repo
     try {
         $json = new JsonFile($this->url . '/packages.json', new RemoteFilesystem($this->io));
         $packages = $json->read();
         if ($this->io->isVerbose()) {
             $this->io->write('Repository is Composer-compatible, loading via packages.json instead of PEAR protocol');
         }
         $loader = new ArrayLoader();
         foreach ($packages as $data) {
             foreach ($data['versions'] as $rev) {
                 if (strpos($rev['name'], 'pear-' . $this->channel) !== 0) {
                     $rev['name'] = 'pear-' . $this->channel . '/' . $rev['name'];
                 }
                 $this->addPackage($loader->load($rev));
                 if ($this->io->isVerbose()) {
                     $this->io->write('Loaded ' . $rev['name'] . ' ' . $rev['version']);
                 }
             }
         }
         return;
     } catch (\Exception $e) {
     }
     $this->fetchFromServer();
 }
开发者ID:nicodmf,项目名称:composer,代码行数:30,代码来源:PearRepository.php

示例4: 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

示例5: 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

示例6: initialize

 protected function initialize()
 {
     parent::initialize();
     set_error_handler(function ($severity, $message, $file, $line) {
         throw new \ErrorException($message, $severity, $severity, $file, $line);
     });
     $this->streamContext = StreamContextFactory::getContext();
     $this->fetchFromServer();
     restore_error_handler();
 }
开发者ID:richardmiller,项目名称:composer,代码行数:10,代码来源:PearRepository.php

示例7: initialize

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

示例8: initialize

 /**
  * Initializes repository (reads file, or remote address).
  */
 protected function initialize()
 {
     parent::initialize();
     $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
     foreach ($this->config as $package) {
         try {
             $package = $loader->load($package);
         } catch (\Exception $e) {
             throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: ' . $e->getMessage() . "\n\nInvalid package definition:\n" . json_encode($package));
         }
         $this->addPackage($package);
     }
 }
开发者ID:neon64,项目名称:composer,代码行数:16,代码来源:PackageRepository.php

示例9: 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 $package) {
         $this->addPackage($loader->load($package));
     }
 }
开发者ID:natxet,项目名称:composer,代码行数:18,代码来源:FilesystemRepository.php

示例10: initialize

 protected function initialize()
 {
     parent::initialize();
     $json = new JsonFile($this->url . '/packages.json');
     $packages = $json->read();
     if (!$packages) {
         throw new \UnexpectedValueException('Could not parse package list from the ' . $this->url . ' repository');
     }
     $loader = new ArrayLoader();
     foreach ($packages as $data) {
         foreach ($data['versions'] as $rev) {
             $this->addPackage($loader->load($rev));
         }
     }
 }
开发者ID:natxet,项目名称:composer,代码行数:15,代码来源:ComposerRepository.php

示例11: initialize

 protected function initialize()
 {
     parent::initialize();
     $loader = new ArrayLoader(null, true);
     $directories = glob($this->directory . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT);
     foreach ($directories as $directory) {
         if (!file_exists($directory . DIRECTORY_SEPARATOR . 'composer.json')) {
             continue;
         }
         $jsonFile = new JsonFile($directory . DIRECTORY_SEPARATOR . 'composer.json');
         $packageData = $jsonFile->read();
         $packageData['version'] = '1.0';
         $package = $loader->load($packageData);
         $this->addPackage($package);
     }
 }
开发者ID:cvo-technologies,项目名称:composer-directory-repository,代码行数:16,代码来源:DirectoryRepository.php

示例12: initialize

 protected function initialize()
 {
     parent::initialize();
     $this->io->writeError('Initializing PEAR repository ' . $this->url);
     $reader = new ChannelReader($this->rfs);
     try {
         $channelInfo = $reader->read($this->url);
     } catch (\Exception $e) {
         $this->io->writeError('<warning>PEAR repository from ' . $this->url . ' could not be loaded. ' . $e->getMessage() . '</warning>');
         return;
     }
     $packages = $this->buildComposerPackages($channelInfo, $this->versionParser);
     foreach ($packages as $package) {
         $this->addPackage($package);
     }
 }
开发者ID:Flesh192,项目名称:magento,代码行数:16,代码来源:PearRepository.php

示例13: initialize

 /**
  * Initializes repository (reads file, or remote address).
  */
 protected function initialize()
 {
     parent::initialize();
     if (!$this->file->exists()) {
         return;
     }
     try {
         $packages = $this->file->read();
         if (!is_array($packages)) {
             throw new \UnexpectedValueException('Could not parse package list from the repository');
         }
     } catch (\Exception $e) {
         throw new InvalidRepositoryException('Invalid repository data in ' . $this->file->getPath() . ', packages could not be loaded: [' . get_class($e) . '] ' . $e->getMessage());
     }
     $loader = new ArrayLoader();
     foreach ($packages as $packageData) {
         $package = $loader->load($packageData);
         $this->addPackage($package);
     }
 }
开发者ID:nickelc,项目名称:composer,代码行数:23,代码来源:FilesystemRepository.php

示例14: initialize

 protected function initialize()
 {
     parent::initialize();
     try {
         $json = new JsonFile($this->url . '/packages.json', new RemoteFilesystem($this->io));
         $data = $json->read();
         if (!empty($data['notify'])) {
             $this->notifyUrl = preg_replace('{(https?://[^/]+).*}i', '$1' . $data['notify'], $this->url);
         }
         $this->cache->write('packages.json', json_encode($data));
     } catch (\Exception $e) {
         if ($contents = $this->cache->read('packages.json')) {
             $this->io->write('<warning>' . $this->url . ' could not be loaded, package information was loaded from the local cache and may be out of date</warning>');
             $data = json_decode($contents, true);
         } else {
             throw $e;
         }
     }
     $loader = new ArrayLoader();
     $this->loadRepository($loader, $data);
 }
开发者ID:nlegoff,项目名称:composer,代码行数:21,代码来源:ComposerRepository.php

示例15: initialize

 /**
  * Initializes path repository.
  *
  * This method will basically read the folder and add the found package.
  */
 protected function initialize()
 {
     parent::initialize();
     $path = $this->getPath();
     $composerFilePath = $path . 'composer.json';
     if (!file_exists($composerFilePath)) {
         throw new \RuntimeException(sprintf('No `composer.json` file found in path repository "%s"', $path));
     }
     $json = file_get_contents($composerFilePath);
     $package = JsonFile::parseJson($json, $composerFilePath);
     $package['dist'] = array('type' => 'path', 'url' => $this->url, 'reference' => '');
     if (!isset($package['version'])) {
         $package['version'] = $this->versionGuesser->guessVersion($package, $path) ?: 'dev-master';
     }
     if (is_dir($path . '/.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:4ung,项目名称:composer,代码行数:25,代码来源:PathRepository.php


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