зеркало из https://github.com/nextcloud/activity.git
Do not use deprecated Util::linkTo()
This commit is contained in:
Родитель
fa76c5b67d
Коммит
893a5c4d3a
|
@ -70,9 +70,10 @@ class Application extends App {
|
|||
$server = $c->query('ServerContainer');
|
||||
return new DataHelper(
|
||||
$server->getActivityManager(),
|
||||
new ParameterHelper (
|
||||
new ParameterHelper(
|
||||
$server->getActivityManager(),
|
||||
$server->getUserManager(),
|
||||
$server->getURLGenerator(),
|
||||
new View(''),
|
||||
$server->getConfig(),
|
||||
$c->query('ActivityL10N'),
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace OCA\Activity;
|
|||
use OCP\Activity\IManager;
|
||||
use OCP\IConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUserManager;
|
||||
use OCP\Util;
|
||||
use OC\Files\View;
|
||||
|
@ -49,9 +50,13 @@ class ParameterHelper {
|
|||
/** @var string */
|
||||
protected $user;
|
||||
|
||||
/** @var \OCP\IURLGenerator */
|
||||
protected $urlGenerator;
|
||||
|
||||
/**
|
||||
* @param IManager $activityManager
|
||||
* @param IUserManager $userManager
|
||||
* @param IURLGenerator $urlGenerator,
|
||||
* @param View $rootView
|
||||
* @param IConfig $config
|
||||
* @param IL10N $l
|
||||
|
@ -59,12 +64,14 @@ class ParameterHelper {
|
|||
*/
|
||||
public function __construct(IManager $activityManager,
|
||||
IUserManager $userManager,
|
||||
IURLGenerator $urlGenerator,
|
||||
View $rootView,
|
||||
IConfig $config,
|
||||
IL10N $l,
|
||||
$user) {
|
||||
$this->activityManager = $activityManager;
|
||||
$this->userManager = $userManager;
|
||||
$this->urlGenerator = $urlGenerator;
|
||||
$this->rootView = $rootView;
|
||||
$this->config = $config;
|
||||
$this->l = $l;
|
||||
|
@ -207,15 +214,16 @@ class ParameterHelper {
|
|||
$is_dir = $this->rootView->is_dir('/' . $this->user . '/files' . $param);
|
||||
|
||||
if ($is_dir) {
|
||||
$fileLink = Util::linkTo('files', 'index.php', array('dir' => $param));
|
||||
$linkData = ['dir' => $param];
|
||||
} else {
|
||||
$parentDir = (substr_count($param, '/') === 1) ? '/' : dirname($param);
|
||||
$fileName = basename($param);
|
||||
$fileLink = Util::linkTo('files', 'index.php', array(
|
||||
$linkData = [
|
||||
'dir' => $parentDir,
|
||||
'scrollto' => $fileName,
|
||||
));
|
||||
];
|
||||
}
|
||||
$fileLink = $this->urlGenerator->linkTo('files', 'index.php', $linkData);
|
||||
|
||||
$param = trim($param, '/');
|
||||
list($path, $name) = $this->splitPathFromFilename($param);
|
||||
|
|
|
@ -137,8 +137,23 @@ class DataHelperTest extends TestCase {
|
|||
$this->getMock('OCP\IUserSession'),
|
||||
$this->getMock('OCP\IConfig')
|
||||
);
|
||||
$activityManager->registerExtension(function() use ($activityLanguage) {
|
||||
return new Extension($activityLanguage, $this->getMock('\OCP\IURLGenerator'));
|
||||
|
||||
$urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$urlGenerator->expects($this->any())
|
||||
->method('linkTo')
|
||||
->willReturnCallback(function($app, $file, $params) {
|
||||
$paramStrings = [];
|
||||
foreach ($params as $name => $value) {
|
||||
$paramStrings[] = $name . '=' . urlencode($value);
|
||||
}
|
||||
|
||||
return '/index.php/apps/' . $app . '?' . implode('&', $paramStrings);
|
||||
});
|
||||
|
||||
$activityManager->registerExtension(function() use ($activityLanguage, $urlGenerator) {
|
||||
return new Extension($activityLanguage, $urlGenerator);
|
||||
});
|
||||
$config = $this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock();
|
||||
$config->expects($this->any())
|
||||
|
@ -151,6 +166,7 @@ class DataHelperTest extends TestCase {
|
|||
new ParameterHelper(
|
||||
$activityManager,
|
||||
$this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(),
|
||||
$urlGenerator,
|
||||
$this->getMockBuilder('OC\Files\View')->disableOriginalConstructor()->getMock(),
|
||||
$config,
|
||||
$activityLanguage,
|
||||
|
@ -203,6 +219,7 @@ class DataHelperTest extends TestCase {
|
|||
new ParameterHelper(
|
||||
$activityManager,
|
||||
$this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('\OCP\IURLGenerator')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('OC\Files\View')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock(),
|
||||
$activityLanguage,
|
||||
|
|
|
@ -583,6 +583,7 @@ class GroupHelperTest extends TestCase {
|
|||
new ParameterHelper(
|
||||
$activityManager,
|
||||
$this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('\OCP\IURLGenerator')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('OC\Files\View')->disableOriginalConstructor()->getMock(),
|
||||
$this->getMockBuilder('OCP\IConfig')->disableOriginalConstructor()->getMock(),
|
||||
$activityLanguage,
|
||||
|
|
|
@ -57,8 +57,22 @@ class ParameterHelperTest extends TestCase {
|
|||
$this->getMock('OCP\IUserSession'),
|
||||
$this->getMock('OCP\IConfig')
|
||||
);
|
||||
$activityManager->registerExtension(function() use ($activityLanguage) {
|
||||
return new Extension($activityLanguage, $this->getMock('\OCP\IURLGenerator'));
|
||||
$urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$urlGenerator->expects($this->any())
|
||||
->method('linkTo')
|
||||
->willReturnCallback(function($app, $file, $params) {
|
||||
$paramStrings = [];
|
||||
foreach ($params as $name => $value) {
|
||||
$paramStrings[] = $name . '=' . urlencode($value);
|
||||
}
|
||||
|
||||
return '/index.php/apps/' . $app . '?' . implode('&', $paramStrings);
|
||||
});
|
||||
|
||||
$activityManager->registerExtension(function() use ($activityLanguage, $urlGenerator) {
|
||||
return new Extension($activityLanguage, $urlGenerator);
|
||||
});
|
||||
$this->userManager = $this->getMock('OCP\IUserManager');
|
||||
$this->userManager->expects($this->any())
|
||||
|
@ -73,6 +87,7 @@ class ParameterHelperTest extends TestCase {
|
|||
$this->parameterHelper = new \OCA\Activity\ParameterHelper(
|
||||
$activityManager,
|
||||
$this->userManager,
|
||||
$urlGenerator,
|
||||
$view,
|
||||
$this->config,
|
||||
$activityLanguage,
|
||||
|
|
Загрузка…
Ссылка в новой задаче