本文整理匯總了PHP中Composer\Script\Event::getMessage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::getMessage方法的具體用法?PHP Event::getMessage怎麽用?PHP Event::getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Composer\Script\Event
的用法示例。
在下文中一共展示了Event::getMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: symlinkWordpressFiles
//.........這裏部分代碼省略.........
$fs = new Filesystem();
$io = $e->getIO();
$finder = new Finder();
$extra = $e->getComposer()->getPackage()->getExtra();
$muPlugins = isset($extra['wp-mu-plugins']) ? $extra['wp-mu-plugins'] : array();
try {
// symlink wordpress content folder
$contentPath = __DIR__ . '/../../../web/wp/wp-content';
$fs->remove(array($contentPath));
$newContentPath = '../../src/Wordpress/WPContent';
$fs->symlink($newContentPath, $contentPath);
$io->write('<info>Symlinked Wordpress Plugin and Themes</info>');
// symlink wordpress vendor plugins
if (!$fs->exists(__DIR__ . '/../../../vendor/wpackagist/')) {
$fs->mkdir(__DIR__ . '/../../../vendor/wpackagist/plugins/');
}
$finder->directories()->in(__DIR__ . '/../../../vendor/wpackagist/plugins/')->depth('== 0');
foreach ($finder as $directory) {
$name = $directory->getFilename();
if (in_array($name, $muPlugins)) {
$targetPath = __DIR__ . '/../../../src/Wordpress/WPContent/mu-plugins';
$relPath = $fs->makePathRelative($directory, $targetPath);
} else {
$targetPath = __DIR__ . '/../../../src/Wordpress/WPContent/plugins';
$relPath = $fs->makePathRelative($directory, $targetPath);
}
$fs->symlink($relPath, $targetPath . '/' . $name);
}
$io->write('<info>Symlinked Wordpress Vendor Plugins</info>');
// autogenerating mu-plugin init
foreach ($muPlugins as $muPlugin) {
$file = __DIR__ . '/../../../src/Wordpress/WPContent/mu-plugins/' . $muPlugin . '/' . $muPlugin . '.php';
$data = self::get_file_data($file);
$data['plugin_name'] = $muPlugin;
$loader = new \Twig_Loader_Filesystem(__DIR__);
$twig = new \Twig_Environment($loader);
$rendered = $twig->render('mu-plugin-init.php.twig', $data);
file_put_contents(__DIR__ . '/../../../src/Wordpress/WPContent/mu-plugins/init-' . $muPlugin . '.php', $rendered);
$twig->loadTemplate('mu-plugin-init.php.twig');
}
// symlink wordpress vendor themes
if (!$fs->exists(__DIR__ . '/../../../vendor/wpackagist/themes/')) {
$fs->mkdir(__DIR__ . '/../../../vendor/wpackagist/themes/');
}
// copy wp-config file.
$fs->copy(__DIR__ . '/wp-config.php.tmp', __DIR__ . '/../../../web/wp/wp-config.php');
$io->write('<info>Copied Wordpress Config Page</info>');
/**
* Create wpConfig.yml
*/
// copy config dist file
$config = __DIR__ . '/../../../config/wpConfig.yml';
$configDist = __DIR__ . '/../../../config/wpConfig.yml.dist';
$parser = new Parser();
$configDistValues = $parser->parse(file_get_contents($configDist));
$io->write('<info>Creating config...</info>');
if ($fs->exists($configDist) && !$fs->exists($config)) {
$finalConfig = array();
/**
* Generate API
*/
$generate = $io->ask('<question>Do you want to regenerate Wordpress security tokens</question> (y/n)?');
if ($generate == 'y') {
$wpApi = file_get_contents('https://api.wordpress.org/secret-key/1.1/salt/');
preg_match_all('/define\\(\'(.*)\'\\,(.*)\'(.*)\'\\);/', $wpApi, $matches);
$wpApiKeys = $matches[1];
$wpApiValues = $matches[3];
foreach ($wpApiKeys as $index => $key) {
if (isset($configDistValues['parameters'][$key])) {
$finalConfig['parameters'][$key] = $wpApiValues[$index];
}
}
}
} else {
$finalConfig = $parser->parse(file_get_contents($config));
}
foreach ($configDistValues['parameters'] as $key => $value) {
if (!isset($finalConfig['parameters'][$key])) {
if ($value === true) {
$defaultValue = 'true';
} elseif ($value === false) {
$defaultValue = 'false';
} elseif (is_null($value)) {
$defaultValue = 'null';
} else {
$defaultValue = '\'' . $value . '\'';
}
$repliedValue = $io->ask('<question>' . $key . '</question> (<comment>' . $defaultValue . '</comment>) ');
if ($repliedValue) {
$value = $repliedValue;
}
$finalConfig['parameters'][$key] = $value;
}
}
file_put_contents($config, "# This file is auto-generated during the composer install\n" . Yaml::dump($finalConfig, 99));
} catch (\Exception $e) {
echo $e->getMessage();
$io->write('<error>Unable to symlink the plugin and theme directory for WordPress. You may have to manually symlink these folders</error>');
}
}