本文整理匯總了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");
}
}