本文整理汇总了PHP中PackageManager::getInstalledDir方法的典型用法代码示例。如果您正苦于以下问题:PHP PackageManager::getInstalledDir方法的具体用法?PHP PackageManager::getInstalledDir怎么用?PHP PackageManager::getInstalledDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PackageManager
的用法示例。
在下文中一共展示了PackageManager::getInstalledDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: determineStatus
/**
* Определяет статус пакета;
*
* Пакет должен быть создан на основе локального файла
*
* Определние произволится исходя из местоположения файла.
* @return int
*/
private function determineStatus()
{
$dDir = PackageManager::getDownloadDir();
if (substr($this->file, 0, strlen($dDir)) == $dDir) {
return Package::DOWNLOADED;
}
$iDir = PackageManager::getInstalledDir();
if (substr($this->file, 0, strlen($iDir)) == $iDir) {
return Package::INSTALLED;
}
return Package::LOCALTED;
}
示例2: install
/**
* Инсталяция пакета
*
* Пакет $package может быть представлен ввиде локального фала(~/mypackage.tbz),
* имени пакета (admin) или ввиде имени пакет, версии и отношения (news>=2.0-alpha)
*
* @throw PackageManagerException, RepositoryListException
* @param string $package
*/
static function install($package)
{
// локальный файл
if (($fp = realpath($package)) !== false) {
if (($p = Package::isPackage(new File($fp, true))) !== false) {
$package = $p;
} else {
throw new PackageManagerException('Given file (' . $package . ') isn\'t a well formed package.');
}
}
// зависимости
io::out('~WHITE~Checking dependencies~~~');
$installList = Deps::calculate($package);
if ($installList === false) {
throw new PackageManagerException('Невозможно удовлетворить зависимости, или не найдены требуемые пакеты.');
} elseif ($installList instanceof Package) {
return IO::out('Установленная версия пакета ' . $installList->name . ': ' . $installList->version) | 0;
}
$newPackages = array();
$updatePackages = array();
$installedPackages = array();
$list = array();
for ($i = 0, $c = count($installList); $i < $c; $i++) {
$package = $installList[$i];
if ($package->status != Package::INSTALLED) {
$list[] = $package;
}
// for information oupput
if ($package->status == Package::INSTALLED) {
$installedPackages[] = $package;
} else {
if (false === ($p = PackageManager::getInstalledPackage($package->name))) {
$newPackages[] = $package;
} else {
$updatePackages[] = $p;
}
}
}
foreach ($newPackages as $p) {
$n[] = $p->name . '(' . $p->version . ')';
}
if (isset($n)) {
io::out('New Packages: ' . implode(', ', $n));
}
foreach ($updatePackages as $p) {
$u[] = $p->name . '(' . $p->version . ')';
}
if (isset($u)) {
io::out('Packages to be updated: ' . implode(', ', $u));
}
foreach ($installedPackages as $p) {
$inst[] = $p->name . '(' . $p->version . ')';
}
if (isset($inst)) {
io::out('Installed Packages: ' . implode(', ', $inst));
}
// доставка
$deployList = array();
io::out('~WHITE~Fetching packages~~~');
$dDir = self::getDownloadDir();
foreach ($list as $package) {
io::out($package->name . '_' . $package->version . ': ', false);
$tFile = $dDir->getFile($package->name . '_' . $package->version . '.tbz');
//look in downloaded dir
$p = Package::isPackage($tFile);
if ($p instanceof Package && $p->name == $package->name && $p->version == $package->version) {
io::out('Already downloaded', false);
$deployList[] = $p;
} else {
// откат для скачанногофайла
PackageManager::getRollback()->push('delete', $tFile);
$deployList[] = $package->delivery($tFile);
}
io::done();
}
try {
foreach ($deployList as $p) {
io::out('~WHITE~Deploying ' . $p->name . '(' . $p->version . '):~~~');
$p->deploy();
$p->file->move(PackageManager::getInstalledDir()->getFile($p->name . '_' . $p->version . '.tbz'));
PackageManager::get()->packagesSequence->addPackage($p->name, $p->version);
}
} catch (Exception $e) {
echo $e->getMessage();
PackageManager::getRollback()->stepBack();
}
return;
}