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


PHP Script\Event類代碼示例

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


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


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