本文整理汇总了PHP中Composer\Util\Filesystem::isSymlinkedDirectory方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::isSymlinkedDirectory方法的具体用法?PHP Filesystem::isSymlinkedDirectory怎么用?PHP Filesystem::isSymlinkedDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composer\Util\Filesystem
的用法示例。
在下文中一共展示了Filesystem::isSymlinkedDirectory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPostUpdate
public function onPostUpdate(Event $event)
{
// Load global plugin configuration
$globalCfg = $this->getGlobalConfig();
if ($globalCfg) {
$extra = self::get($globalCfg, 'extra', []);
$myConfig = self::get($extra, self::EXTRA_KEY, []);
if ($myConfig) {
$this->info("Global configuration loaded");
}
} else {
$myConfig = [];
}
// Merge project-specific configuration.
// Ignore it if Composer is running in global mode.
$package = $this->composer->getPackage();
if ($package->getName() != '__root__') {
$projCfg = self::get($package->getExtra(), self::EXTRA_KEY, []);
$myConfig = array_merge_recursive($myConfig, $projCfg);
$this->info("Project-specific configuration loaded");
}
// Setup
$rules = array_unique(self::get($myConfig, self::RULES_KEY, []));
$sharedDir = str_replace('~', getenv('HOME'), self::get($myConfig, self::SHARED_DIR_KEY, self::DEFAULT_SHARED_DIR));
$packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
$rulesInfo = implode(', ', $rules);
$this->info("Shared directory: <info>{$sharedDir}</info>");
$this->info("Match packages: <info>{$rulesInfo}</info>");
$fsUtil = new FilesystemUtil();
$fs = new Filesystem();
// Do useful work
$count = 0;
foreach ($packages as $package) {
$srcDir = $this->getInstallPath($package);
$packageName = $package->getName();
if (self::globMatchAny($rules, $packageName) && !$fsUtil->isSymlinkedDirectory($srcDir)) {
$destPath = "{$sharedDir}/{$packageName}";
if (!file_exists($destPath)) {
$fsUtil->copyThenRemove($srcDir, $destPath);
$this->info("Moved <info>{$packageName}</info> to shared directory and symlinked to it");
} else {
$fs->remove($srcDir);
$this->info("Symlinked to existing <info>{$packageName}</info> on shared directory");
}
$fs->symlink($destPath, $srcDir);
++$count;
}
}
if (!$count) {
$this->info("No packages matched");
}
}