本文整理汇总了PHP中OC_Installer::installApp方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Installer::installApp方法的具体用法?PHP OC_Installer::installApp怎么用?PHP OC_Installer::installApp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Installer
的用法示例。
在下文中一共展示了OC_Installer::installApp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUpdateApp
public function testUpdateApp()
{
$pathOfOldTestApp = __DIR__;
$pathOfOldTestApp .= '/../data/';
$pathOfOldTestApp .= 'testapp.zip';
$oldTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
$oldData = array('path' => $oldTmp, 'source' => 'path', 'appdata' => ['id' => 'Bar', 'level' => 100]);
$pathOfNewTestApp = __DIR__;
$pathOfNewTestApp .= '/../data/';
$pathOfNewTestApp .= 'testapp2.zip';
$newTmp = \OC::$server->getTempManager()->getTemporaryFile('.zip');
OC_Helper::copyr($pathOfNewTestApp, $newTmp);
$newData = array('path' => $newTmp, 'source' => 'path', 'appdata' => ['id' => 'Bar', 'level' => 100]);
OC_Installer::installApp($oldData);
$oldVersionNumber = OC_App::getAppVersion(self::$appid);
OC_Installer::updateApp($newData);
$newVersionNumber = OC_App::getAppVersion(self::$appid);
$this->assertNotEquals($oldVersionNumber, $newVersionNumber);
}
示例2: testUpdateApp
public function testUpdateApp()
{
$pathOfOldTestApp = __DIR__;
$pathOfOldTestApp .= '/../data/';
$pathOfOldTestApp .= 'testapp.zip';
$oldTmp = OC_Helper::tmpFile('.zip');
OC_Helper::copyr($pathOfOldTestApp, $oldTmp);
$oldData = array('path' => $oldTmp, 'source' => 'path');
$pathOfNewTestApp = __DIR__;
$pathOfNewTestApp .= '/../data/';
$pathOfNewTestApp .= 'testapp2.zip';
$newTmp = OC_Helper::tmpFile('.zip');
OC_Helper::copyr($pathOfNewTestApp, $newTmp);
$newData = array('path' => $newTmp, 'source' => 'path');
OC_Installer::installApp($oldData);
$oldVersionNumber = OC_App::getAppVersion(self::$appid);
OC_Installer::updateApp($newData);
$newVersionNumber = OC_App::getAppVersion(self::$appid);
$this->assertNotEquals($oldVersionNumber, $newVersionNumber);
}
示例3: downloadApp
/**
* @param string $app
* @return int
*/
public static function downloadApp($app)
{
$appData = OC_OCSClient::getApplication($app);
$download = OC_OCSClient::getApplicationDownload($app, 1);
if (isset($download['downloadlink']) and $download['downloadlink'] != '') {
// Replace spaces in download link without encoding entire URL
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
$info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData);
$app = OC_Installer::installApp($info);
}
return $app;
}
示例4: downloadApp
/**
* @param string $app
* @return int
*/
private static function downloadApp($app)
{
$ocsClient = new OCSClient(\OC::$server->getHTTPClientService(), \OC::$server->getConfig(), \OC::$server->getLogger());
$appData = $ocsClient->getApplication($app, \OCP\Util::getVersion());
$download = $ocsClient->getApplicationDownload($app, \OCP\Util::getVersion());
if (isset($download['downloadlink']) and $download['downloadlink'] != '') {
// Replace spaces in download link without encoding entire URL
$download['downloadlink'] = str_replace(' ', '%20', $download['downloadlink']);
$info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appData);
$app = OC_Installer::installApp($info);
}
return $app;
}
示例5: enable
/**
* @brief enables an app
* @param mixed $app app
* @throws \Exception
* @return void
*
* This function set an app as enabled in appconfig.
*/
public static function enable($app)
{
self::$enabledAppsCache = array();
// flush
if (!OC_Installer::isInstalled($app)) {
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
if (!is_numeric($app)) {
$app = OC_Installer::installShippedApp($app);
} else {
$appdata = OC_OCSClient::getApplication($app, \OC_Util::getVersion());
$download = OC_OCSClient::getApplicationDownload($app, 1, \OC_Util::getVersion());
if (isset($download['downloadlink']) and $download['downloadlink'] != '') {
$info = array('source' => 'http', 'href' => $download['downloadlink'], 'appdata' => $appdata);
$app = OC_Installer::installApp($info);
}
}
}
$l = OC_L10N::get('core');
if ($app !== false) {
// check if the app is compatible with this version of ownCloud
$info = OC_App::getAppInfo($app);
$version = OC_Util::getVersion();
if (!isset($info['require']) or !self::isAppVersionCompatible($version, $info['require'])) {
throw new \Exception($l->t("App \"%s\" can't be installed because it is not compatible with this version of ownCloud.", array($info['name'])));
} else {
OC_Appconfig::setValue($app, 'enabled', 'yes');
if (isset($appdata['id'])) {
OC_Appconfig::setValue($app, 'ocsid', $appdata['id']);
}
\OC_Hook::emit('OC_App', 'post_enable', array('app' => $app));
}
} else {
throw new \Exception($l->t("No app name specified"));
}
}
示例6: enable
/**
* @brief enables an app
* @param mixed $app app
* @return bool
*
* This function set an app as enabled in appconfig.
*/
public static function enable($app)
{
if (!OC_Installer::isInstalled($app)) {
// check if app is a shipped app or not. OCS apps have an integer as id, shipped apps use a string
if (!is_numeric($app)) {
$app = OC_Installer::installShippedApp($app);
} else {
$download = OC_OCSClient::getApplicationDownload($app, 1);
if (isset($download['downloadlink']) and $download['downloadlink'] != '') {
$app = OC_Installer::installApp(array('source' => 'http', 'href' => $download['downloadlink']));
}
}
}
if ($app !== false) {
// check if the app is compatible with this version of ownCloud
$info = OC_App::getAppInfo($app);
$version = OC_Util::getVersion();
if (!isset($info['require']) or $version[0] > $info['require']) {
OC_Log::write('core', 'App "' . $info['name'] . '" can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR);
return false;
} else {
OC_Appconfig::setValue($app, 'enabled', 'yes');
return true;
}
} else {
return false;
}
}