本文整理匯總了PHP中Composer\Script\Event::isDevMode方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::isDevMode方法的具體用法?PHP Event::isDevMode怎麽用?PHP Event::isDevMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Script\Event
的用法示例。
在下文中一共展示了Event::isDevMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: makeAutoload
public static function makeAutoload(Event $event)
{
$composer = $event->getComposer();
$generator = $composer->getAutoloadGenerator();
$generator->setDevMode($event->isDevMode());
$generator->dump($composer->getConfig(), $composer->getRepositoryManager()->getLocalRepository(), $composer->getPackage(), $composer->getInstallationManager(), 'composer', !$event->isDevMode());
$event->getIO()->write('-> generated composer autoload files');
}
示例2: createDoctrineSchema
/**
* Creates the doctrine schema.
*
* @param Event $event
*/
public static function createDoctrineSchema(Event $event)
{
$envs = $event->isDevMode() ? ['dev', 'test'] : ['prod'];
foreach ($envs as $env) {
$cmd = sprintf('sententiaregum:install:database --no-interaction --apply-fixtures --env=%s', $env);
if (!$event->isDevMode()) {
$cmd .= ' --production-fixtures -s migrations';
}
static::executeCommand($event, static::getConsoleDir($event, 'create doctrine schema'), $cmd);
}
}
示例3: getFile
/**
* @param Event $event
* @param $filename
* @param $s3key
* @throws \Exception
*/
protected static function getFile(Event $event, $filename, $s3key)
{
$env = getenv('SYRUP_ENV');
if (!$env) {
$env = $event->isDevMode() ? 'dev' : 'prod';
}
if (!in_array($env, ['dev', 'test', 'prod'])) {
throw new \Exception('SYRUP_ENV only accepts value "dev", "test" or "prod"');
}
if ($env == 'dev') {
if ($event->getIO()->isInteractive()) {
$event->getIO()->askAndValidate("<comment>Get <question>{$filename}</question> from development S3 bucket? [<options=bold>y</options=bold>/n/s]:\ny - yes <info>(default)</info>\nn - no <info>(manually input folder containing the file)</info>\ns - skip <info>(keep current file)</info>\n</comment>", function ($answer) use($event, $s3key, $filename, $env) {
switch ($answer) {
case "y":
self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
break;
case "n":
self::getFromIO($event->getIO(), $filename);
break;
case "s":
break;
default:
throw new \InvalidArgumentException("Invalid option! Please choose either y, n or s");
}
}, 3, "y");
} elseif (file_exists("./{$filename}") && $event->getIO()->askConfirmation("Use './{$filename}'? [<options=bold>y</options=bold>/n]", true)) {
self::getFromIO($event->getIO(), $filename, ".");
} else {
self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
}
} else {
self::getFromS3($event->getIO(), $s3key, self::PARAMETERS_DIR . $filename, $env);
}
}
示例4: onPostUpdate
public function onPostUpdate(Event $event)
{
$requires = [];
$overrides = [];
$resolutions = [];
if ($event->isDevMode()) {
$extra = $this->composer->getPackage()->getExtra();
$bower = isset($extra['bower']) ? $extra['bower'] : [];
if (isset($bower['require-dev'])) {
$requires = $this->_mergeDependencyVersions($requires, $bower['require-dev']);
}
}
$packages = [$this->composer->getPackage()];
$packages = array_merge($packages, $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages());
foreach ($packages as $package) {
if ($package instanceof CompletePackage) {
$extra = $package->getExtra();
$bower = isset($extra['bower']) ? $extra['bower'] : [];
if (isset($bower['require'])) {
$requires = $this->_mergeDependencyVersions($requires, $bower['require']);
}
if (isset($bower['overrides'])) {
$overrides = array_merge_recursive($overrides, $bower['overrides']);
}
if (isset($bower['resolutions'])) {
$resolutions = $bower['resolutions'];
}
}
}
if (!$requires) {
$this->info("No Bower packages are required by the application or by any installed Composer package");
}
$dependencies = $this->_installBower($requires, $overrides, $resolutions);
$this->info((count($dependencies) ?: "No") . " bower packages are installed");
}
示例5: 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);
}
}
}
示例6: checkHooks
/**
* @param Event $event
* @return null
*/
public static function checkHooks(Event $event)
{
$io = $event->getIO();
// Don't run pre-commit in non-dev mode
if (!$event->isDevMode()) {
return null;
}
// Cannot install pre-commit with a windows machine
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return null;
}
$projectRoot = realpath(__DIR__ . '/../../../../../');
$packageHook = $projectRoot . '/bin/pre-commit';
if (strpos($projectRoot, 'laravel') !== false) {
$projectRoot = realpath($projectRoot . '/../');
$packageHook = $projectRoot . '/laravel/bin/pre-commit';
}
$hooksDir = realpath($projectRoot . '/.git/hooks/');
$newHook = $hooksDir . '/pre-commit';
if (@file_get_contents($newHook) !== @file_get_contents($packageHook)) {
$io->write('<comment>GIT hooks are missing</comment>');
$symlink = symlink($packageHook, $newHook);
if (false === $symlink) {
$io->write('<error>Failed to symlink the GIT hooks</error>');
return null;
}
chmod($newHook, 0755);
$defaultPhpCSFile = realpath(__DIR__ . '/../../.php_cs.example');
$newPhpCSFile = $projectRoot . '/.php_cs';
copy($defaultPhpCSFile, $newPhpCSFile);
}
$io->write('<info>GIT hooks are succesfully installed</info>');
}
示例7: buildConfig
public static function buildConfig(Event $event)
{
if (true === $event->isDevMode()) {
$message = "Deprecated instalation script!!\n";
$message .= "Please replace it by \\PhpGitHooks\\Infrastructure\\Composer\\ConfiguratorScript::buildConfig\nin your composer.json file";
$event->getIO()->writeError(sprintf('<error>%s</error>', $message));
}
}
示例8: onPostUpdate
public function onPostUpdate(Event $event)
{
$assetsLock = array('bower-dependencies' => array(), 'npm-dependencies' => array());
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$mergedNpmPackages = array();
// NPM install for dependencies that are not exposed.
foreach ($packages as $package) {
if ($package instanceof \Composer\Package\CompletePackage) {
$extra = $package->getExtra();
if (!isset($extra['expose-npm-packages']) || $extra['expose-npm-packages'] != true) {
$shrinkwrapDeps = $this->_installNpm($this->composer->getConfig()->get('vendor-dir') . '/' . $package->getName(), $package, false, array(), null);
if ($shrinkwrapDeps) {
$assetsLock['npm-dependencies'][$package->getName()] = $shrinkwrapDeps;
}
} else {
$mergedNpmPackages[] = $package;
}
}
}
// NPM install for dependencies that are exposed on the root package.
$shrinkwrapDeps = $this->_installNpm('.', $this->composer->getPackage(), $event->isDevMode(), $mergedNpmPackages, null);
if ($shrinkwrapDeps) {
$assetsLock['npm-dependencies']['self'] = $shrinkwrapDeps;
}
$this->_createNpmBinaries();
$requireBower = array();
if ($event->isDevMode()) {
$extra = $this->composer->getPackage()->getExtra();
if (isset($extra['require-dev-bower'])) {
$requireBower = $this->_mergeDependencyVersions($requireBower, $extra['require-dev-bower']);
}
}
$packages = array($this->composer->getPackage());
$packages = array_merge($packages, $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages());
foreach ($packages as $package) {
if ($package instanceof \Composer\Package\CompletePackageInterface) {
$extra = $package->getExtra();
if (isset($extra['require-bower'])) {
$requireBower = $this->_mergeDependencyVersions($requireBower, $extra['require-bower']);
}
}
}
$assetsLock['bower-dependencies'] = $this->_installBower($requireBower);
$assetsLockFile = new JsonFile('composer-extra-assets.lock');
$assetsLockFile->write($assetsLock);
}
示例9: buildConfig
/**
* @param Event $event
*
* @return mixed
*/
public static function buildConfig(Event $event)
{
if (true === $event->isDevMode()) {
$container = new AppKernel();
/** @var ConfigurationProcessorCommandHandler $processor */
$processor = $container->get('command.bus');
$processor->handle(new ConfigurationProcessorCommand($event->getIO()));
}
}
示例10: buildConfig
public static function buildConfig(Event $event)
{
if (true === $event->isDevMode()) {
$container = new Container();
/** @var ConfiguratorProcessor $processor */
$processor = $container->get('configurator.processor');
$processor->setIO($event->getIO());
return $processor->process();
}
}
示例11: install
private static function install(Event $event)
{
if (!$event->isDevMode()) {
return;
}
$manager = new GitHookManager();
if ($manager->isInstalled() || $manager->install()) {
$event->getIO()->write('Pre-commit hook has been successfully installed.');
} else {
$event->getIO()->writeError('Some errors occurred during the installation process. Pre-commit hook are NOT installed.');
}
}
示例12: start
public function start(Event $e)
{
$package = $this->composer->getPackage();
$fetches = array_merge($this->getFetchesInExtra($package, self::EXTRA_KEY), $this->findFetchesInRequire($package));
$this->baseDir = $this->determineBaseDir($fetches, self::DEFAULT_BASE_DIR);
$this->targets = $this->processFetches($package, $fetches);
if ($e->isDevMode()) {
$devFetches = array_merge($this->getFetchesInExtra($package, self::EXTRA_KEY_DEV), $this->findFetchesInRequireDev($package));
$this->baseDirDev = $this->determineBaseDir($devFetches, self::DEFAULT_BASE_DIR_DEV);
$this->targetsDev = $this->processFetches($package, $devFetches);
}
}
示例13: setupPhpStorm
/**
* @param Event $event
* @return bool
*/
public static function setupPhpStorm(Event $event)
{
if ($event->isDevMode()) {
try {
(new IdeSetup(self::getProject(), new PhpStormIde()))->setup();
} catch (Exception $e) {
null;
}
return true;
}
return false;
}
示例14: buildConfig
/**
* @param Event $event
*
* @return mixed
*/
public static function buildConfig(Event $event)
{
if (true === $event->isDevMode()) {
$app = new AppKernel('dev', true);
$app->boot();
$container = $app->getContainer();
/**
* @var ConfigurationProcessorCommandHandler
*/
$processor = $container->get('bruli.command.bus');
$processor->handle(new ConfigurationProcessorCommand($event->getIO()));
}
}
示例15: rebuildData
public static function rebuildData(Event $event)
{
$io = $event->getIO();
if (!$event->isDevMode()) {
$io->write('This script is only supported in development mode. Exiting.');
return;
}
$destroyed = self::destroyData($event);
if ($destroyed) {
MigrationHandler::runMigration(new Event($event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), ['--all']));
FixtureHandler::importFixture(new Event($event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), ['-target=honeybee.system_account::fixture::writer', '-fixture=20150819120801:import_demo_user']));
FixtureHandler::importFixture(new Event($event->getName(), $event->getComposer(), $event->getIO(), $event->isDevMode(), ['-target=hbdemo.commenting::fixture::writer', '-fixture=20150810231335:initial_test_data']));
}
}