• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Script\Event类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Composer\Script\Event的典型用法代码示例。如果您正苦于以下问题:PHP Event类的具体用法?PHP Event怎么用?PHP Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: onPostInstallCommand

    public function onPostInstallCommand(ScriptEvent $event)
    {
        $config = $event->getComposer()->getConfig();
        $filesystem = new Filesystem();
        $vendor_path = $filesystem->normalizePath(realpath($config->get('vendor-dir')));
        $cake_dir = $filesystem->normalizePath($vendor_path . '/cakephp/cakephp');
        $root_dir = $filesystem->normalizePath(realpath(""));
        $app_dir = $filesystem->normalizePath($root_dir . '/app');
        if (!is_dir($app_dir)) {
            $this->copyRecursive($filesystem->normalizePath($cake_dir . '/app'), $app_dir);
            $index_path = $filesystem->normalizePath($app_dir . '/webroot/index.php');
            $index = str_replace('define(\'CAKE_CORE_INCLUDE_PATH\', ROOT);', 'define(\'CAKE_CORE_INCLUDE_PATH\', ROOT . \'vendor\' . DS . \'cakephp\' . DS . \'cakephp\');', file_get_contents($index_path));
            file_put_contents($index_path, $index);
            $loader_of_old_php_path = $filesystem->normalizePath($vendor_path . '/atomita/loader-of-less-than-php5.3-plugin');
            if (file_exists($loader_of_old_php_path)) {
                $loader = <<<EOD
// @generated by atomita/cakephp1-setup-plugin
include(ROOT . DS . '{$config->get('vendor-dir')}' . DS . 'autoload.php');
// @end generated
EOD;
                $config_path = $filesystem->normalizePath($app_dir . '/config/core.php');
                $config = file_get_contents($config_path);
                if (false === strpos($config, $loader)) {
                    file_put_contents($config_path, $config . PHP_EOL . PHP_EOL . $loader);
                }
            }
        }
    }
开发者ID:atomita,项目名称:cakephp1-setup-plugin,代码行数:28,代码来源:Cakephp1Setup.php


示例2: migrateSettingsFile

 public static function migrateSettingsFile(Event $event = null)
 {
     if ($event !== null) {
         $event->getIO()->write("Migrating old setting file...");
     }
     if ($event) {
         $root_dir = realpath('');
     } else {
         $root_dir = realpath('../../');
     }
     if (file_exists($root_dir . '/app/config/parameters.yml')) {
         return false;
     }
     if (file_exists($root_dir . '/' . self::SETTINGS_FILE)) {
         $tmp_settings = file_get_contents($root_dir . '/' . self::SETTINGS_FILE);
         if (strpos($tmp_settings, '_DB_SERVER_') !== false) {
             $tmp_settings = preg_replace('/(\'|")\\_/', '$1_LEGACY_', $tmp_settings);
             file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $tmp_settings);
             include $root_dir . '/' . self::SETTINGS_FILE;
             $factory = new RandomLib\Factory();
             $generator = $factory->getLowStrengthGenerator();
             $secret = $generator->generateString(56);
             $default_parameters = Yaml::parse($root_dir . '/app/config/parameters.yml.dist');
             $parameters = array('parameters' => array('database_host' => _LEGACY_DB_SERVER_, 'database_port' => '~', 'database_user' => _LEGACY_DB_USER_, 'database_password' => _LEGACY_DB_PASSWD_, 'database_name' => _LEGACY_DB_NAME_, 'database_prefix' => _LEGACY_DB_PREFIX_, 'database_engine' => _LEGACY_MYSQL_ENGINE_, 'cookie_key' => _LEGACY_COOKIE_KEY_, 'cookie_iv' => _LEGACY_COOKIE_IV_, 'ps_caching' => _LEGACY_PS_CACHING_SYSTEM_, 'ps_cache_enable' => _LEGACY_PS_CACHE_ENABLED_, 'ps_creation_date' => _LEGACY_PS_CREATION_DATE_, 'secret' => $secret, 'mailer_transport' => 'smtp', 'mailer_host' => '127.0.0.1', 'mailer_user' => '~', 'mailer_password' => '~') + $default_parameters['parameters']);
             if (file_put_contents($root_dir . '/app/config/parameters.yml', Yaml::dump($parameters))) {
                 $settings_content = "<?php\n";
                 $settings_content .= "//@deprecated 1.7";
                 file_put_contents($root_dir . '/' . self::SETTINGS_FILE, $settings_content);
             }
         }
     }
     if ($event !== null) {
         $event->getIO()->write("Finished...");
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:35,代码来源:Migrate.php


示例3: update

 /**
  * Update the stored database.
  *
  * @since 0.1.0
  *
  * @param Event $event The event that has called the update method.
  */
 public static function update(Event $event)
 {
     $dbFilename = PHPReleases::getLocation();
     self::maybeCreateDBFolder(dirname($dbFilename));
     $io = $event->getIO();
     $io->write('Fetching change logs from official PHP website...', false);
     $io->write(' PHP5...', false);
     $php5 = self::downloadFile(self::PHP_5_RELEASES);
     $io->write(' PHP7...', false);
     $php7 = self::downloadFile(self::PHP_7_RELEASES);
     $io->write(' done!', true);
     $releases = array();
     $io->write('Parsing change logs to extract versions...', false);
     $io->write(' PHP5...', false);
     $php5Releases = self::parseReleases($php5);
     $io->write('(' . count($php5Releases) . ' releases)', false);
     $releases = array_merge($releases, $php5Releases);
     $io->write(' PHP7...', false);
     $php7Releases = self::parseReleases($php7);
     $io->write('(' . count($php7Releases) . ' releases)', false);
     $releases = array_merge($releases, $php7Releases);
     $io->write(' done!', true);
     ksort($releases, SORT_NATURAL);
     self::generateConfig($releases, $dbFilename);
     $io->write('The PHP Releases database has been updated.', true);
 }
开发者ID:brightnucleus,项目名称:php-releases,代码行数:33,代码来源:PHPReleases_Plugin.php


示例4: checkForSecurityIssues

 /**
  * @param Event $event
  */
 public static function checkForSecurityIssues(Event $event)
 {
     $extra = $event->getComposer()->getPackage()->getExtra();
     $config = isset($extra['rolebi-dependencies-security-checker']) ? $extra['rolebi-dependencies-security-checker'] : array();
     if (!is_array($config)) {
         throw new \InvalidArgumentException('The extra.rolebi-dependencies-security-checker setting must be an array.');
     }
     $config = ConfigHandler::processConfig($config);
     $io = $event->getIO();
     $io->write("\n" . '<info>Checking your dependencies for known vulnerabilities using your composer.lock</info>');
     $io->write('<comment>This checker can only detect vulnerabilities that are referenced in the SensioLabs ' . 'security advisories database.</comment>' . "\n");
     try {
         $vulnerabilities = static::getVulnerabilities(static::getComposerFile(), $config['ignored-packages']);
     } catch (ServiceUnavailableException $exception) {
         if ($config['error-on-service-unavailable']) {
             throw $exception;
         } else {
             $io->write("\n" . '  <error>' . $exception->getMessage() . '</error>');
             return;
         }
     }
     $errorCount = count($vulnerabilities);
     if ($errorCount) {
         $io->write("\n" . '  <error>' . $errorCount . ' vulnerability(ies) found!</error>');
         static::dumpVulnerabilities($io, $vulnerabilities);
         if ($config['error-on-vulnerabilities']) {
             $exception = new UnsafeDependenciesException('At least one of your dependencies contains known vulnerability(ies)');
             throw $exception->setVulnerabilities($vulnerabilities);
         }
     }
 }
开发者ID:beejhuff,项目名称:ComposerDependenciesSecurityChecker,代码行数:34,代码来源:ScriptHandler.php


示例5: publish

 /**
  * @param Event $event
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  * @throws \Symfony\Component\Filesystem\Exception\IOException
  *
  * @api
  *
  * @quality:method [C]
  */
 public static function publish(Event $event)
 {
     $composer = $event->getComposer();
     $extras = $composer->getPackage()->getExtra();
     if (!isset($extras['admin-lte'])) {
         throw new \InvalidArgumentException('The AdminLTE installer needs to be configured through the extra.admin-lte setting.');
     }
     $config = $extras['admin-lte'];
     if (!isset($config['target'])) {
         throw new \InvalidArgumentException('The extra.admin-lte must contains target path.');
     }
     $package = $composer->getRepositoryManager()->getLocalRepository()->findPackage('almasaeed2010/adminlte', '~2.0');
     if ($package === null) {
         throw new \RuntimeException('The AdminLTE package not found.');
     }
     $forPublishing = ['dist' => 'adminlte'];
     if (!empty($config['bootstrap'])) {
         $forPublishing['bootstrap'] = 'adminlte-bootstrap';
     }
     if (!empty($config['plugins'])) {
         $forPublishing['plugins'] = 'adminlte-plugins';
     }
     if (!empty($config['demo'])) {
         $forPublishing[''] = 'adminlte-demo';
     }
     (new Processor(new Filesystem(), $event->getIO()))->publish($config['target'], $composer->getInstallationManager()->getInstallPath($package), $forPublishing, !empty($config['symlink']), !empty($config['relative']));
 }
开发者ID:kamilsk,项目名称:common,代码行数:38,代码来源:Publisher.php


示例6: ensureHtaccess

    /**
     * Ensures that .htaccess and web.config files are present in Composer root.
     *
     * @param \Composer\Script\Event $event
     */
    public static function ensureHtaccess(Event $event)
    {
        // The current working directory for composer scripts is where you run
        // composer from.
        $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
        // Prevent access to vendor directory on Apache servers.
        $htaccess_file = $vendor_dir . '/.htaccess';
        if (!file_exists($htaccess_file)) {
            file_put_contents($htaccess_file, FileStorage::htaccessLines(TRUE) . "\n");
        }
        // Prevent access to vendor directory on IIS servers.
        $webconfig_file = $vendor_dir . '/web.config';
        if (!file_exists($webconfig_file)) {
            $lines = <<<EOT
<configuration>
  <system.webServer>
    <authorization>
      <deny users="*">
    </authorization>
  </system.webServer>
</configuration>
EOT;
            file_put_contents($webconfig_file, $lines . "\n");
        }
    }
开发者ID:HakS,项目名称:drupal8_training,代码行数:30,代码来源:Composer.php


示例7: postInstall

 /**
  * Does some routine installation tasks so people don't have to.
  *
  * @param \Composer\Script\Event $event The composer event object.
  * @throws \Exception Exception raised by validator.
  * @return void
  */
 public static function postInstall(Event $event)
 {
     $io = $event->getIO();
     $rootDir = dirname(dirname(__DIR__));
     static::createAppConfig($rootDir, $io);
     static::createEnvConfig($rootDir, $io);
     static::createWritableDirectories($rootDir, $io);
     // ask if the permissions should be changed
     if ($io->isInteractive()) {
         $validator = function ($arg) {
             if (in_array($arg, ['Y', 'y', 'N', 'n'])) {
                 return $arg;
             }
             throw new Exception('This is not a valid answer. Please choose Y or n.');
         };
         $setFolderPermissions = $io->askAndValidate('<info>Set Folder Permissions ? (Default to Y)</info> [<comment>Y,n</comment>]? ', $validator, 10, 'Y');
         if (in_array($setFolderPermissions, ['Y', 'y'])) {
             static::setFolderPermissions($rootDir, $io);
         }
     } else {
         static::setFolderPermissions($rootDir, $io);
     }
     static::setSecuritySalt($rootDir, $io);
     if (class_exists('\\Cake\\Codeception\\Console\\Installer')) {
         \Cake\Codeception\Console\Installer::customizeCodeceptionBinary($event);
     }
 }
开发者ID:scherersoftware,项目名称:cakephp-app-template,代码行数:34,代码来源:Installer.php


示例8: ask

 public static function ask(Event $oEvent, $sQuestion, $sDefault = null, $bMandatory = false, $fValidatorCustom = null)
 {
     // Get validator
     if ($bMandatory) {
         $fValidator = function ($sValue) use($fValidatorCustom) {
             if ($sValue !== '' and !is_null($sValue)) {
                 if (is_null($fValidatorCustom)) {
                     return $sValue;
                 } else {
                     return call_user_func_array($fValidatorCustom, [$sValue]);
                 }
             } else {
                 throw new RuntimeException('Value can\'t be blank');
             }
         };
     } else {
         $fValidator = function ($sValue) use($fValidatorCustom) {
             $sValue = is_null($sValue) ? '' : $sValue;
             if (is_null($fValidatorCustom)) {
                 return $sValue;
             } else {
                 return call_user_func_array($fValidatorCustom, [$sValue]);
             }
         };
     }
     // Return
     return $oEvent->getIO()->askAndValidate($sQuestion, $fValidator, null, $sDefault);
 }
开发者ID:asticode,项目名称:php-toolbox,代码行数:28,代码来源:ExtendedComposer.php


示例9: createRequiredFiles

 public static function createRequiredFiles(Event $event)
 {
     $fs = new Filesystem();
     $root = static::getDrupalRoot(getcwd());
     $dirs = ['modules', 'profiles', 'themes'];
     // Required for unit testing
     foreach ($dirs as $dir) {
         if (!$fs->exists($root . '/' . $dir)) {
             $fs->mkdir($root . '/' . $dir);
             $fs->touch($root . '/' . $dir . '/.gitkeep');
         }
     }
     // Prepare the settings file for installation
     if (!$fs->exists($root . '/sites/default/settings.php')) {
         $fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php');
         $fs->chmod($root . '/sites/default/settings.php', 0666);
         $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666");
     }
     // Prepare the services file for installation
     if (!$fs->exists($root . '/sites/default/services.yml')) {
         $fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml');
         $fs->chmod($root . '/sites/default/services.yml', 0666);
         $event->getIO()->write("Create a sites/default/services.yml file with chmod 0666");
     }
     // Create the files directory with chmod 0777
     if (!$fs->exists($root . '/sites/default/files')) {
         $oldmask = umask(0);
         $fs->mkdir($root . '/sites/default/files', 0777);
         umask($oldmask);
         $event->getIO()->write("Create a sites/default/files directory with chmod 0777");
     }
 }
开发者ID:openrestaurant,项目名称:openrestaurant-project,代码行数:32,代码来源:ScriptHandler.php


示例10: mkdirs

 public static function mkdirs(Event $event)
 {
     $extras = $event->getComposer()->getPackage()->getExtra();
     if (!isset($extras['fbourigault-composer-mkdir'])) {
         $message = 'The mkdir handler needs to be configured through the extra.fbourigault-composer-mkdir setting.';
         throw new InvalidArgumentException($message);
     }
     if (!is_array($extras['fbourigault-composer-mkdir'])) {
         $message = 'The extra.fbourigault-composer-mkdir setting must be an array.';
         throw new InvalidArgumentException($message);
     }
     /* Since 2.0, mode is no longer supported */
     $legacy = array_filter($extras['fbourigault-composer-mkdir'], function ($directory) {
         return !is_string($directory);
     });
     if (!empty($legacy)) {
         $message = 'Since 2.0, mode is no longer supported. See UPGRADE-2.0.md for further details.';
         throw new InvalidArgumentException($message);
     }
     /* Remove existing directories from creation list */
     $directories = array_filter($extras['fbourigault-composer-mkdir'], function ($directory) {
         return !file_exists($directory);
     });
     foreach ($directories as $directory) {
         mkdir($directory, 0777, true);
     }
 }
开发者ID:fbourigault,项目名称:composer-mkdir,代码行数:27,代码来源:ScriptHandler.php


示例11: manage

 public static function manage(Event $event, $extras, $newCopy)
 {
     $ciAppDir = realpath($extras['ci-app-dir']) . DIRECTORY_SEPARATOR;
     $libBaseDir = $ciAppDir . "core" . DIRECTORY_SEPARATOR;
     if ($extras['localize-ready']) {
         self::install('Lang', $libBaseDir);
         self::install('Config', $libBaseDir);
         $routeSource = Manager::getResourcePath('routes.php.mu', '/config');
     } else {
         self::remove('Config', $libBaseDir);
         self::remove('Lang', $libBaseDir);
         $routeSource = Manager::getResourcePath('routes.php', '/config');
     }
     $routeDest = $ciAppDir . "config" . DIRECTORY_SEPARATOR . 'routes.php';
     $writeRoute = TRUE;
     $io = $event->getIO();
     if (!$newCopy) {
         $writeMode = "Updating";
         if (file_exists($routeDest)) {
             $confirmMsg = Colors::confirm("Re-Write Route Configuration File(yes,no)?[no]") . " :";
             $writeRoute = $io->askConfirmation($confirmMsg, FALSE);
         }
     } else {
         $writeMode = PHP_EOL . "Writing";
     }
     if ($writeRoute) {
         $io->write(Colors::message(sprintf("%s Route Configuration File ", $writeMode)) . Colors::info('"config/routes.php"'));
         copy($routeSource, $routeDest);
     }
 }
开发者ID:NaszvadiG,项目名称:codeigniter-extended,代码行数:30,代码来源:CoreLibrary.php


示例12: postInstall

 /**
  * Run composer post-install script
  * 
  * @param  Event  $event
  * @return void
  */
 public static function postInstall(Event $event)
 {
     static::init();
     $event->getIO()->write('<info>Writing resources.lock file</info>');
     $installed = json_decode(file_get_contents(static::$vendorPath . '/composer/installed.json'));
     $data = [];
     $finder = (new Finder())->directories()->ignoreVCS(true)->in(static::$resourcesPath . '/packages');
     foreach ($installed as $package) {
         if (!property_exists($package, 'extra')) {
             continue;
         }
         $extra = $package->extra;
         if (!property_exists($extra, 'resources')) {
             continue;
         }
         $resources = $extra->resources;
         foreach ($resources as $resource => $namespaces) {
             foreach ($namespaces as $namespace => $path) {
                 $finder->exclude($namespace);
                 $data[$resource][$namespace] = $path;
             }
         }
     }
     // We turn the iterator to an array to
     // prevent an exception when we delete the directorys
     foreach (iterator_to_array($finder) as $file) {
         \Filesystem::deleteDirectory($file->getPathname());
     }
     file_put_contents(static::$resourcesPath . '/resources.lock', json_encode($data, JSON_PRETTY_PRINT));
 }
开发者ID:encorephp,项目名称:kernel,代码行数:36,代码来源:Script.php


示例13: __construct

 /**
  * private constructor
  * @param Event $event
  */
 private function __construct($event)
 {
     $this->io = $event->getIO();
     $this->event = $event;
     $this->dir = realpath(__DIR__ . "/../../");
     $this->dbDir = $this->dir . '/scripts/dbupdates';
 }
开发者ID:bokultis,项目名称:kardiomedika,代码行数:11,代码来源:Installer.php


示例14: postUpdate

 /**
  * Does some routine installation tasks so people don't have to.
  *
  * @param \Composer\Script\Event $event The composer event object.
  * @throws \Exception Exception raised by validator.
  * @return void
  */
 public static function postUpdate(Event $event)
 {
     $io = $event->getIO();
     $rootDir = dirname(dirname(__DIR__));
     $jqueryVendorDir = $rootDir . '/vendor/components/jquery';
     $jqueryWebrootDir = $rootDir . '/webroot/js/vendor/jquery';
     $foundationVendorDir = $rootDir . '/vendor/zurb/foundation/js/foundation';
     $foundationWebrootDir = $rootDir . '/webroot/js/vendor/foundation';
     $modernizrVendorDir = $rootDir . '/vendor/components/modernizr';
     $modernizrWebrootDir = $rootDir . '/webroot/js/vendor/modernizr';
     if (is_dir($jqueryVendorDir)) {
         $jqueryFolder = new Folder($jqueryVendorDir);
         $jqueryFolder->copy($jqueryWebrootDir);
         $io->write('Copied `Jquery` files');
     }
     if (is_dir($foundationVendorDir)) {
         $foundationFolder = new Folder($foundationVendorDir);
         $foundationFolder->copy($foundationWebrootDir);
         $io->write('Copied `Zurb Foundation JS` files');
     }
     if (is_dir($modernizrVendorDir)) {
         $modernizrFolder = new Folder($modernizrVendorDir);
         $modernizrFolder->copy($modernizrWebrootDir);
         $io->write('Copied `Modernizr` files');
     }
 }
开发者ID:BobyTT,项目名称:Cake3Foundation,代码行数:33,代码来源:Installer.php


示例15: postInstall

 public static function postInstall(Event $event)
 {
     // provides access to the current Composer instance
     $composer = $event->getComposer();
     // run any post install tasks here
     copy('vendor/xqus/octoguard/gpg-mailgate.php', 'gpg-mailgate.php');
 }
开发者ID:xqus,项目名称:octoguard,代码行数:7,代码来源:Installer.php


示例16: preUpdate

 /**
  * Merge repositories and requirements from a separate composer-local.json.
  *
  * This allows static development dependencies to be shipped with Vanilla, but can be customized with a
  * composer-local.json file that specifies additional dependencies such as plugins or compatibility libraries.
  *
  * @param Event $event The event being fired.
  */
 public static function preUpdate(Event $event)
 {
     self::clearAddonManagerCache();
     // Check for a composer-local.json.
     $composerLocalPath = './composer-local.json';
     if (!file_exists($composerLocalPath)) {
         return;
     }
     $composer = $event->getComposer();
     $factory = new Factory();
     $localComposer = $factory->createComposer($event->getIO(), $composerLocalPath, true, null, false);
     // Merge repositories.
     $localRepositories = $localComposer->getRepositoryManager()->getRepositories();
     foreach ($localRepositories as $repository) {
         /* @var \Composer\Repository\RepositoryInterface $repository */
         if (method_exists($repository, 'getRepoConfig')) {
             $config = $repository->getRepoConfig();
         } else {
             $config = ['url' => ''];
         }
         // Skip the packagist repo.
         if (strpos($config['url'], 'packagist.org') !== false) {
             continue;
         }
         $composer->getRepositoryManager()->addRepository($repository);
     }
     // Merge requirements.
     $requires = array_merge($composer->getPackage()->getRequires(), $localComposer->getPackage()->getRequires());
     $composer->getPackage()->setRequires($requires);
     $devRequires = array_merge($composer->getPackage()->getDevRequires(), $localComposer->getPackage()->getDevRequires());
     $composer->getPackage()->setDevRequires($devRequires);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:40,代码来源:ComposerHelper.php


示例17: postPackageInstall

 /**
  * Installs index.php and themes.
  *
  * @param Event $event
  * @return bool
  */
 public static function postPackageInstall(Event $event)
 {
     $installedPackage = $event->getOperation()->getPackage();
     // do stuff
     // var_dump($event);
     return true;
 }
开发者ID:dav-m85,项目名称:picono,代码行数:13,代码来源:Bootstrap.php


示例18: onInstallUpdateOrDump

 /**
  * {@inheritdoc}
  */
 public function onInstallUpdateOrDump(Event $event)
 {
     // Wikimedia is also registered as a plugin, so it will have a chance to
     // merge it's dependencies. Here we override and add our module
     // dependencies.
     $this->mergeForDrupalRootPackage($event->getComposer());
 }
开发者ID:paul-m,项目名称:drupal-merge-plugin,代码行数:10,代码来源:MergePlugin.php


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


示例20: setup

 public static function setup(Event $event)
 {
     $composer = $event->getComposer();
     $installer = new self($event->getIO(), $composer, 'tiki-theme');
     $composer->getInstallationManager()->addInstaller($installer);
     $composer->getEventDispatcher()->addSubscriber($installer);
 }
开发者ID:rjsmelo,项目名称:tiki,代码行数:7,代码来源:ThemeInstaller.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Util\Filesystem类代码示例发布时间:2022-05-23
下一篇:
PHP Script\CommandEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap