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


PHP Event::getComposer方法代碼示例

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


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

示例1: generate

 public static function generate(Event $event)
 {
     $io = $event->getIO();
     $packages = $event->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages();
     $requires = $event->getComposer()->getPackage()->getRequires();
     // the packages and the required dependencies does not have all information
     // so we have to use both arrays to extract needed details
     foreach ($requires as $i => $require) {
         /** @var $require \Composer\Package\Link **/
         $search = array_filter($packages, function ($e) use($require) {
             return $e->getName() == $require->getTarget();
         });
         if (!empty($search)) {
             $package = current($search);
             /** @var $package \Composer\Package\Package **/
             $io->write('<info>name</info>       : ' . '<comment>' . $package->getPrettyName() . '</comment>', true);
             $io->write('<info>descrip.</info>   : ' . $package->getDescription(), true);
             $io->write('<info>license</info>    : ' . implode(', ', $package->getLicense()), true);
             $io->write('<info>version</info>    : ' . $package->getPrettyVersion(), true);
             $io->write('<info>constraint</info> : ' . $require->getPrettyConstraint(), true);
             $io->write('<info>source</info>     : ' . $package->getSourceUrl(), true);
             $io->write('<info>homepage</info>   : ' . ($package->getHomepage() ? $package->getHomepage() : str_replace(".git", "", $package->getSourceUrl())), true);
             $subRequires = implode(', ', array_map(function ($package) {
                 return $package->getTarget();
             }, $package->getRequires()));
             $io->write('<info>requires</info>   : ' . ($subRequires ? $subRequires : 'none'), true);
             $io->write('', true);
         }
     }
 }
開發者ID:tony-co,項目名稱:partition,代碼行數:30,代碼來源:Partition.php

示例2: addPhpCsToPreCommitHook

 public static function addPhpCsToPreCommitHook(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     $dependencyToResolve = self::arrayResolvePath("codesniffer:standard:dependency", $extra);
     if (is_null($dependencyToResolve)) {
         $event->getIO()->writeError("Cannot install pre-commit hooks. No CodeSniffer standard configured at extra->codesniffer->standard.");
         return;
     }
     if (is_array($dependencyToResolve)) {
         $event->getIO()->writeError("Cannot install pre-commit hooks. Configuration of extra->codesniffer->standard->dependency is invalid.");
         return;
     }
     $originFile = getcwd() . '/.git/hooks/pre-commit';
     if (!is_dir(dirname($originFile))) {
         mkdir(dirname($originFile), 0777, true);
     }
     $templateContent = file_get_contents(__DIR__ . '/templates/git/hooks/pre-commit-phpcs');
     $originContent = '';
     if (file_exists($originFile)) {
         $originContent = file_get_contents($originFile);
     }
     if (strpos($originContent, '# BEGIN:metasyntactical/composer-codesniffer-hooks') !== false) {
         return;
     }
     $newContent = $originContent;
     if (mb_strlen($originContent)) {
         $newContent .= "\n";
     }
     $newContent .= str_replace(array("{STANDARDPATH}"), array($event->getComposer()->getConfig()->get("vendor-dir", Config::RELATIVE_PATHS) . "/{$dependencyToResolve}/ruleset.xml"), $templateContent);
     file_put_contents($originFile, $newContent);
     $perms = fileperms($originFile);
     chmod($originFile, $perms | 0x40 | 0x8 | 0x1);
     clearstatcache(null, $originFile);
 }
開發者ID:metasyntactical,項目名稱:composer-codesniffer-hooks,代碼行數:34,代碼來源:ScriptHandler.php

示例3: getOptions

 /**
  * Private method that manages the options of commands.
  *
  * @param Event $event The command event
  *
  * @return array
  */
 private static function getOptions(Event $event)
 {
     $extras = $event->getComposer()->getPackage()->getExtra();
     $options = isset($extras['kreta-distribution']) ? $extras['kreta-distribution'] : [];
     $options = array_merge(['npm-bin-links' => true, 'process-timeout' => $event->getComposer()->getConfig()->get('process-timeout')], $options);
     return $options;
 }
開發者ID:kreta,項目名稱:distribution,代碼行數:14,代碼來源:ScriptHandler.php

示例4: install

 /**
  * @return int
  */
 public function install()
 {
     $io = $this->event->getIO();
     $composer = $this->event->getComposer();
     $repository = new PhantomJSVersionRepository($io, $composer);
     $versions = $repository->getVersions();
     if (!count($versions)) {
         $io->write('<error>Could not found any version.</error>');
         return 1;
     }
     $binDir = $composer->getConfig()->get('bin-dir');
     is_dir($binDir) ?: mkdir($binDir, 0755, true);
     $binDir = realpath($binDir);
     $vendorDir = $composer->getConfig()->get('vendor-dir') . '/sgc-fireball/phantomjs';
     is_dir($vendorDir) ?: mkdir($vendorDir, 0755, true);
     $vendorDir = realpath($vendorDir);
     $downloader = new PhantomJSDownloader($io, $composer);
     foreach ($versions as $version) {
         try {
             $package = $downloader->createComposerPackage($version, $vendorDir);
             if ($downloader->download($package)) {
                 copy($vendorDir . '/bin/phantomjs', $binDir . '/phantomjs');
                 chmod($binDir . '/phantomjs', 0755);
                 return 0;
             }
         } catch (\Exception $e) {
         }
     }
     $io->write(sprintf('<error>Could not download %s.</error>', $package->getDistUrl()));
     return 2;
 }
開發者ID:sgc-fireball,項目名稱:selenium-server-standalone-installer,代碼行數:34,代碼來源:Installer.php

示例5: install

 /**
  * Installs the shop files.
  *
  * @param \Composer\Script\Event $event Event instance
  * @throws \RuntimeException If an error occured
  */
 public static function install(\Composer\Script\Event $event)
 {
     $repository = $event->getComposer()->getRepositoryManager();
     $t3package = $repository->findPackage('aimeos/aimeos-typo3', '*');
     if ($t3package !== null) {
         $installer = $event->getComposer()->getInstallationManager();
         $t3path = $installer->getInstallPath($t3package);
         if (($package = $repository->findPackage('aimeos/ai-client-html', '*')) !== null) {
             $event->getIO()->write('Installing Aimeos public files from HTML client');
             $path = $installer->getInstallPath($package);
             self::copyRecursive($path . '/client/html/themes', $t3path . '/Resources/Public/Themes');
         }
         if (($package = $repository->findPackage('aimeos/ai-admin-extadm', '*')) !== null) {
             $event->getIO()->write('Installing Aimeos public files from ExtJS admin');
             $path = $installer->getInstallPath($package);
             self::copyRecursive($path . '/admin/extjs/resources', $t3path . '/Resources/Public/Admin/extjs/resources');
             self::copyRecursive($path . '/admin/extjs/lib/ext.ux/Portal/resources', $t3path . '/Resources/Public/Admin/extjs/lib/ext.ux/Portal');
             self::copyRecursive($path . '/admin/extjs/lib/ext.ux/AdvancedSearch/resources', $t3path . '/Resources/Public/Admin/extjs/lib/ext.ux/AdvancedSearch');
         }
         if (file_exists($t3path . '/Resources/Private/Extensions') === false && ($package = $repository->findPackage('aimeos/ai-typo3', '*')) !== null) {
             $event->getIO()->write('Creating symlink to Aimeos extension directory');
             $path = dirname($installer->getInstallPath($package));
             symlink(getcwd() . '/' . $path, $t3path . '/Resources/Private/Extensions');
         }
     }
 }
開發者ID:aimeos,項目名稱:aimeos-typo3,代碼行數:32,代碼來源:Composer.php

示例6: preAutoloadDumpEvent

 public function preAutoloadDumpEvent(Script\Event $event)
 {
     if ($event->isPropagationStopped()) {
         return;
     }
     $references = array();
     // find current package reference
     $localPackageReference = $this->determineLocalPackageReference();
     if ($localPackageReference !== null) {
         $references[$event->getComposer()->getPackage()->getName()] = $localPackageReference;
     }
     // enumerate local repository packages
     foreach ($event->getComposer()->getRepositoryManager()->getLocalRepository()->getCanonicalPackages() as $package) {
         if ($package->getSourceReference() !== null) {
             $references[$package->getName()] = $package->getSourceReference();
         } else {
             if ($package->getDistReference() !== null) {
                 $references[$package->getName()] = $package->getDistReference();
             }
         }
     }
     $destination = $event->getComposer()->getConfig()->get('vendor-dir') . DIRECTORY_SEPARATOR . 'mcuelenaere' . DIRECTORY_SEPARATOR . 'composer-revision-plugin' . DIRECTORY_SEPARATOR . 'gen' . DIRECTORY_SEPARATOR . 'revisions.php';
     $classGenerator = new ReferenceClassGenerator($event->getComposer()->getConfig());
     $classGenerator->generate($destination, $references);
 }
開發者ID:mcuelenaere,項目名稱:composer-revision-plugin,代碼行數:25,代碼來源:Plugin.php

示例7: build

 /**
  * @param Event $event
  *
  * @throws \InvalidArgumentException when extra configuration is not defined properly
  */
 public static function build(Event $event)
 {
     $io = $event->getIO();
     // everything needed for this installer
     // is stored in the "extra" config section
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (!array_key_exists(self::PROPERTY_PUPPET_MODULES_DIR, $extra) || !array_key_exists(self::PROPERTY_PUPPET_MODULES, $extra)) {
         throw new \InvalidArgumentException('"extra" configuration needs properties "modules-dir" and "modules"');
     }
     // find out where we are and where we should install the puppet modules
     $modulesDir = $extra[self::PROPERTY_PUPPET_MODULES_DIR];
     $vendorDir = realpath($event->getComposer()->getConfig()->get('vendor-dir'));
     $projectDir = realpath($vendorDir . '/..');
     // copy original puppet module dir from vendors to the puppet modules dir
     foreach ($extra[self::PROPERTY_PUPPET_MODULES] as $name => $target) {
         if (empty($name) || empty($target)) {
             $io->write(sprintf('Skip Puppet module installation from "%s" to "%s"', $name, $target));
             continue;
         }
         $modulePath = $modulesDir . '/' . $target;
         $io->write(sprintf('Installing Puppet module "%s" to "%s"', $name, $modulePath));
         $from = $vendorDir . '/' . $name;
         $to = $projectDir . '/' . $modulePath;
         // @TODO is there a better way without installing any other vendor lib?
         shell_exec("rsync -rv --delete {$from}/ {$to}/");
     }
 }
開發者ID:frastel,項目名稱:puphpeteer-installer,代碼行數:32,代碼來源:Installer.php

示例8: overload

 /**
  * @param Event $event
  */
 public static function overload(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     if ($event->isDevMode()) {
         $envs = [static::EXTRA_OVERLOAD_CLASS, static::EXTRA_OVERLOAD_CLASS_DEV];
         $cacheDir = static::EXTRA_OVERLOAD_CACHE_DIR_DEV;
         if (array_key_exists($cacheDir, $extra) === false) {
             $cacheDir = static::EXTRA_OVERLOAD_CACHE_DIR;
         }
     } else {
         $envs = [static::EXTRA_OVERLOAD_CLASS];
         $cacheDir = static::EXTRA_OVERLOAD_CACHE_DIR;
     }
     foreach ($envs as $extraKey) {
         if (array_key_exists($extraKey, $extra)) {
             $autoload = $event->getComposer()->getPackage()->getAutoload();
             if (array_key_exists('classmap', $autoload) === false) {
                 $autoload['classmap'] = array();
             }
             foreach ($extra[$extraKey] as $className => $infos) {
                 static::generateProxy($extra[$cacheDir], $className, $infos['original-file']);
                 $autoload['classmap'][$className] = $infos['overload-file'];
             }
             $event->getComposer()->getPackage()->setAutoload($autoload);
         }
     }
 }
開發者ID:steevanb,項目名稱:composer-overload-class,代碼行數:30,代碼來源:OverloadClass.php

示例9: onPostAutoloadDump

 /**
  * Plugin callback for this script event, which calls the previously implemented static method
  *
  * @param \Composer\Script\Event $event
  * @return bool
  */
 public function onPostAutoloadDump(\Composer\Script\Event $event)
 {
     $flags = $event->getFlags();
     $config = $event->getComposer()->getConfig();
     $optimizeAutoloadFiles = !empty($flags['optimize']) || $config->get('optimize-autoloader') || $config->get('classmap-authoritative');
     $aliasMapGenerator = new ClassAliasMapGenerator($event->getComposer(), $event->getIO(), $optimizeAutoloadFiles);
     return $aliasMapGenerator->generateAliasMap();
 }
開發者ID:graurus,項目名稱:testgit_t37,代碼行數:14,代碼來源:Plugin.php

示例10: checker

 /**
  * @param Event $event
  */
 public static function checker(Event $event)
 {
     $extras = $event->getComposer()->getConfig()->getExtra();
     var_dump($event->getComposer()->getPackage()->getRepositories());
     die('d');
     $event->getIO()->write("<info>[CheckerPlugin]</info> plugin activate");
     var_dump($extras);
 }
開發者ID:cws-studio,項目名稱:composer-fw-checker,代碼行數:11,代碼來源:CheckerHandler.php

示例11: copyAssets

 /**
  * Copy assets into you assets directory
  *
  * @param Event $event
  */
 public static function copyAssets(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (!isset($extra[self::EXTRA_ASSET_DIR])) {
         return;
     }
     $vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
     $fs = new Filesystem();
     $fs->mirror($vendorDir . '/itkg/profiler/src/Itkg/Profiler/Resources/public', $extra[self::EXTRA_ASSET_DIR] . '/vendor/itkg/profiler/assets');
 }
開發者ID:itkg,項目名稱:profiler,代碼行數:15,代碼來源:Installer.php

示例12: postInstall

 /**
  * @param Event $event
  */
 public static function postInstall(Event $event)
 {
     static::$installationManager = $event->getComposer()->getInstallationManager();
     static::$localRepository = $event->getComposer()->getRepositoryManager()->getLocalRepository();
     $rootDirectory = __DIR__ . '/../../../../';
     static::copyFile('twbs/bootstrap', 'dist/css/bootstrap.min.css', $rootDirectory . 'public/css/bootstrap.min.css');
     static::mirrorDirectory('twbs/bootstrap', 'dist/fonts', $rootDirectory . 'public/fonts');
     if (!file_exists($rootDirectory . 'app/settings.yml')) {
         static::getFileSystem()->copy($rootDirectory . 'app/settings.example.yml', $rootDirectory . 'app/settings.yml', true);
     }
 }
開發者ID:ichhabrecht,項目名稱:git-checker,代碼行數:14,代碼來源:Installer.php

示例13: getRecorder

 /**
  * @param Event $event
  *
  * @return Recorder
  */
 private static function getRecorder(Event $event)
 {
     if (!isset(static::$recorder)) {
         $vendorDir = realpath(rtrim($event->getComposer()->getConfig()->get('vendor-dir'), '/'));
         $configDir = realpath($vendorDir . '/../app/config');
         $logger = new ConsoleIoLogger($event->getIO());
         $manager = $event->getComposer()->getRepositoryManager();
         $rootPackage = $event->getComposer()->getPackage();
         static::$recorder = new Recorder($manager->getLocalRepository(), new Detector($vendorDir), new BundleHandler($configDir, $logger), $rootPackage->getAliases(), $vendorDir);
     }
     return static::$recorder;
 }
開發者ID:claroline,項目名稱:distribution,代碼行數:17,代碼來源:ScriptHandler.php

示例14: postInstallCmd

 /**
  * On post install cmd.
  * 
  * @param Event $e
  * @return void
  */
 public static function postInstallCmd(Event $e)
 {
     $vendorDir = $e->getComposer()->getConfig()->get('vendor-dir');
     foreach ($e->getComposer()->getPackage()->getExtra() as $pattern => $folder) {
         foreach (glob($vendorDir . DIRECTORY_SEPARATOR . $pattern) as $file) {
             if (file_exists($folder) === false) {
                 mkdir($folder);
             }
             copy($file, $folder . DIRECTORY_SEPARATOR . basename($file));
         }
     }
 }
開發者ID:foxou33,項目名稱:TayoSkeletonApplication,代碼行數:18,代碼來源:Module.php

示例15: onPostUpdateInstall

 /**
  * Script callback; Acted on after install or update.
  */
 public function onPostUpdateInstall(Event $event)
 {
     $settings = array('targetDir' => 'vendor/nodejs/nodejs', 'forceLocal' => false, 'includeBinInPath' => false);
     $extra = $event->getComposer()->getPackage()->getExtra();
     if (isset($extra['mouf']['nodejs'])) {
         $rootSettings = $extra['mouf']['nodejs'];
         $settings = array_merge($settings, $rootSettings);
         $settings['targetDir'] = trim($settings['targetDir'], '/\\');
     }
     $binDir = $event->getComposer()->getConfig()->get('bin-dir');
     if (!class_exists(__NAMESPACE__ . '\\NodeJsVersionMatcher')) {
         //The package is being uninstalled
         $this->onUninstall($binDir, $settings['targetDir']);
         return;
     }
     $nodeJsVersionMatcher = new NodeJsVersionMatcher();
     $versionConstraint = $this->getMergedVersionConstraint();
     $this->verboseLog("<info>NodeJS installer:</info>");
     $this->verboseLog(" - Requested version: " . $versionConstraint);
     $nodeJsInstaller = new NodeJsInstaller($this->io);
     $isLocal = false;
     if ($settings['forceLocal']) {
         $this->verboseLog(" - Forcing local NodeJS install.");
         $this->installLocalVersion($nodeJsInstaller, $versionConstraint, $settings['targetDir']);
         $isLocal = true;
     } else {
         $globalVersion = $nodeJsInstaller->getNodeJsGlobalInstallVersion();
         if ($globalVersion !== null) {
             $this->verboseLog(" - Global NodeJS install found: v" . $globalVersion);
             $npmPath = $nodeJsInstaller->getGlobalInstallPath('npm');
             if (!$npmPath) {
                 $this->verboseLog(" - No NPM install found");
                 $this->installLocalVersion($nodeJsInstaller, $versionConstraint, $settings['targetDir']);
                 $isLocal = true;
             } elseif (!$nodeJsVersionMatcher->isVersionMatching($globalVersion, $versionConstraint)) {
                 $this->installLocalVersion($nodeJsInstaller, $versionConstraint, $settings['targetDir']);
                 $isLocal = true;
             } else {
                 $this->verboseLog(" - Global NodeJS install matches constraint " . $versionConstraint);
             }
         } else {
             $this->verboseLog(" - No global NodeJS install found");
             $this->installLocalVersion($nodeJsInstaller, $versionConstraint, $settings['targetDir']);
             $isLocal = true;
         }
     }
     // Now, let's create the bin scripts that start node and NPM
     $nodeJsInstaller->createBinScripts($binDir, $settings['targetDir'], $isLocal);
     // Finally, let's register vendor/bin in the PATH.
     if ($settings['includeBinInPath']) {
         $nodeJsInstaller->registerPath($binDir);
     }
 }
開發者ID:kaayru,項目名稱:nodejs-installer,代碼行數:56,代碼來源:NodeJsPlugin.php


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