本文整理汇总了PHP中OCP\IRequest类的典型用法代码示例。如果您正苦于以下问题:PHP IRequest类的具体用法?PHP IRequest怎么用?PHP IRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(IRequest $request, $baseUri)
{
$this->request = $request;
$this->baseUri = $baseUri;
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server($root);
// Backends
$authBackend = new Auth(\OC::$server->getSession(), \OC::$server->getUserSession());
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($this->request->getRequestUri());
$this->server->setBaseUri($this->baseUri);
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$this->server->addPlugin(new Plugin($authBackend, 'ownCloud'));
$this->server->addPlugin(new \Sabre\DAVACL\Plugin());
$this->server->addPlugin(new \Sabre\CardDAV\Plugin());
// Finder on OS X requires Class 2 WebDAV support (locking), since we do
// not provide locking we emulate it using a fake locking plugin.
if ($request->isUserAgent(['/WebDAVFS/'])) {
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
}
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod', function () {
// custom properties plugin must be the last one
$user = \OC::$server->getUserSession()->getUser();
if (!is_null($user)) {
$this->server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new CustomPropertiesBackend($this->server->tree, \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession()->getUser())));
}
});
}
开发者ID:quality123,项目名称:core,代码行数:29,代码来源:server.php
示例2: isBrowserRequest
/**
* @param IRequest $request
* @return bool
*/
public static function isBrowserRequest(IRequest $request)
{
if ($request->getMethod() !== 'GET') {
return false;
}
return $request->isUserAgent([Request::USER_AGENT_IE, Request::USER_AGENT_MS_EDGE, Request::USER_AGENT_CHROME, Request::USER_AGENT_FIREFOX, Request::USER_AGENT_SAFARI]);
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:11,代码来源:browsererrorpageplugin.php
示例3: __construct
public function __construct(IRequest $request, $baseUri)
{
$this->request = $request;
$this->baseUri = $baseUri;
$logger = \OC::$server->getLogger();
$mailer = \OC::$server->getMailer();
$dispatcher = \OC::$server->getEventDispatcher();
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server($root);
// Backends
$authBackend = new Auth(\OC::$server->getSession(), \OC::$server->getUserSession(), \OC::$server->getRequest());
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($this->request->getRequestUri());
$this->server->setBaseUri($this->baseUri);
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$authPlugin = new Plugin($authBackend, 'ownCloud');
$this->server->addPlugin($authPlugin);
// allow setup of additional auth backends
$event = new SabrePluginEvent($this->server);
$dispatcher->dispatch('OCA\\DAV\\Connector\\Sabre::authInit', $event);
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
// acl
$acl = new DavAclPlugin();
$acl->defaultUsernamePath = 'principals/users';
$this->server->addPlugin($acl);
// calendar plugins
$this->server->addPlugin(new \Sabre\CalDAV\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
$this->server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin());
$this->server->addPlugin(new IMipPlugin($mailer, $logger));
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
$this->server->addPlugin(new DAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
// addressbook plugins
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
// system tags plugins
$this->server->addPlugin(new \OCA\DAV\SystemTag\SystemTagPlugin(\OC::$server->getSystemTagManager(), \OC::$server->getGroupManager(), \OC::$server->getUserSession()));
// comments plugin
$this->server->addPlugin(new \OCA\DAV\Comments\CommentsPlugin(\OC::$server->getCommentsManager(), \OC::$server->getUserSession()));
// Some WebDAV clients do require Class 2 WebDAV support (locking), since
// we do not provide locking we emulate it using a fake locking plugin.
if ($request->isUserAgent(['/WebDAVFS/', '/Microsoft Office OneNote 2013/'])) {
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
}
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod', function () {
// custom properties plugin must be the last one
$user = \OC::$server->getUserSession()->getUser();
if (!is_null($user)) {
$view = \OC\Files\Filesystem::getView();
$this->server->addPlugin(new FilesPlugin($this->server->tree, $view));
$this->server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new CustomPropertiesBackend($this->server->tree, \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession()->getUser())));
}
});
}
开发者ID:gvde,项目名称:core,代码行数:58,代码来源:server.php
示例4: __construct
public function __construct(IRequest $request, $baseUri)
{
$this->request = $request;
$this->baseUri = $baseUri;
$logger = \OC::$server->getLogger();
$dispatcher = \OC::$server->getEventDispatcher();
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server($root);
// Backends
$authBackend = new Auth(\OC::$server->getSession(), \OC::$server->getUserSession());
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($this->request->getRequestUri());
$this->server->setBaseUri($this->baseUri);
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$this->server->addPlugin(new Plugin($authBackend, 'ownCloud'));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ListenerPlugin($dispatcher));
$this->server->addPlugin(new \Sabre\DAV\Sync\Plugin());
// acl
$acl = new \Sabre\DAVACL\Plugin();
$acl->defaultUsernamePath = 'principals/users';
$this->server->addPlugin($acl);
// calendar plugins
$this->server->addPlugin(new \Sabre\CalDAV\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\ICSExportPlugin());
$senderEmail = \OCP\Util::getDefaultEmailAddress('no-reply');
$this->server->addPlugin(new \Sabre\CalDAV\Schedule\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Schedule\IMipPlugin($senderEmail));
$this->server->addPlugin(new \Sabre\CalDAV\SharingPlugin());
$this->server->addPlugin(new \Sabre\CalDAV\Subscriptions\Plugin());
$this->server->addPlugin(new \Sabre\CalDAV\Notifications\Plugin());
$this->server->addPlugin(new CardDAV\Sharing\Plugin($authBackend, \OC::$server->getRequest()));
// addressbook plugins
$this->server->addPlugin(new \OCA\DAV\CardDAV\Plugin());
// system tags plugins
$this->server->addPlugin(new \OCA\DAV\SystemTag\SystemTagPlugin(\OC::$server->getSystemTagManager()));
// Finder on OS X requires Class 2 WebDAV support (locking), since we do
// not provide locking we emulate it using a fake locking plugin.
if ($request->isUserAgent(['/WebDAVFS/'])) {
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
}
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod', function () {
// custom properties plugin must be the last one
$user = \OC::$server->getUserSession()->getUser();
if (!is_null($user)) {
$this->server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new CustomPropertiesBackend($this->server->tree, \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession()->getUser())));
}
});
}
开发者ID:loulancn,项目名称:core,代码行数:52,代码来源:server.php
示例5: __construct
/**
* @param IConfig $config
* @param ICrypto $crypto
* @param ISecureRandom $random
* @param IRequest $request
*/
public function __construct(IConfig $config, ICrypto $crypto, ISecureRandom $random, IRequest $request)
{
$this->crypto = $crypto;
$this->config = $config;
$this->random = $random;
if (!is_null($request->getCookie(self::COOKIE_NAME))) {
$this->passphrase = $request->getCookie(self::COOKIE_NAME);
} else {
$this->passphrase = $this->random->getMediumStrengthGenerator()->generate(128);
$secureCookie = $request->getServerProtocol() === 'https';
// FIXME: Required for CI
if (!defined('PHPUNIT_RUN')) {
setcookie(self::COOKIE_NAME, $this->passphrase, 0, \OC::$WEBROOT, '', $secureCookie, true);
}
}
}
开发者ID:rosarion,项目名称:core,代码行数:22,代码来源:cryptowrapper.php
示例6: __construct
public function __construct(IRequest $request, $baseUri)
{
$this->request = $request;
$this->baseUri = $baseUri;
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server($root);
// Backends
$authBackend = new Auth(\OC::$server->getSession(), \OC::$server->getUserSession());
// Set URL explicitly due to reverse-proxy situations
$this->server->httpRequest->setUrl($this->request->getRequestUri());
$this->server->setBaseUri($this->baseUri);
$this->server->addPlugin(new BlockLegacyClientPlugin(\OC::$server->getConfig()));
$this->server->addPlugin(new Plugin($authBackend, 'ownCloud'));
// wait with registering these until auth is handled and the filesystem is setup
$this->server->on('beforeMethod', function () {
// custom properties plugin must be the last one
$user = \OC::$server->getUserSession()->getUser();
if (!is_null($user)) {
$this->server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new CustomPropertiesBackend($this->server->tree, \OC::$server->getDatabaseConnection(), \OC::$server->getUserSession()->getUser())));
}
});
}
开发者ID:nem0xff,项目名称:core,代码行数:22,代码来源:server.php
示例7: setAppValue
/**
* @param array $parameters
* @return \OC_OCS_Result
*/
public function setAppValue($parameters)
{
$app = $parameters['appid'];
$configKey = $parameters['configkey'];
$value = $this->request->getParam('value');
$this->config->setAppValue($app, $configKey, $value);
return new \OC_OCS_Result();
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:12,代码来源:Config.php
示例8: testLogoutWithToken
public function testLogoutWithToken()
{
$this->request->expects($this->once())->method('getCookie')->with('oc_token')->willReturn('MyLoginToken');
$user = $this->getMock('\\OCP\\IUser');
$user->expects($this->once())->method('getUID')->willReturn('JohnDoe');
$this->userSession->expects($this->once())->method('getUser')->willReturn($user);
$this->config->expects($this->once())->method('deleteUserValue')->with('JohnDoe', 'login_token', 'MyLoginToken');
$this->urlGenerator->expects($this->once())->method('linkToRouteAbsolute')->with('core.login.showLoginForm')->willReturn('/login');
$expected = new RedirectResponse('/login');
$this->assertEquals($expected, $this->loginController->logout());
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:11,代码来源:LoginControllerTest.php
示例9: testRestoreTrashedNote
public function testRestoreTrashedNote()
{
$file = "some-not-existing-test-file.txt";
$timestamp = time();
$this->request->expects($this->at(0))->method("getParam")->with("file_name")->willReturn("/Notes/{$file}");
$this->request->expects($this->at(1))->method("getParam")->with("timestamp")->willReturn($timestamp);
$result = $this->controller->restoreTrashedNote();
$this->assertArrayHasKey("result", $result);
$this->assertArrayHasKey("path", $result);
$this->assertArrayHasKey("filename", $result);
$this->assertFalse($result["result"]);
$this->assertEquals($result["path"], "//{$file}.d{$timestamp}");
$this->assertEquals($result["filename"], $file);
}
开发者ID:pbek,项目名称:qownnotesapi,代码行数:14,代码来源:NoteApiControllerTest.php
示例10: receiveSurveyResults
/**
* request received to ask remote server for a shared secret
*
* @return \OC_OCS_Result
*/
public function receiveSurveyResults()
{
$data = $this->request->getParam('data');
$array = json_decode($data, true);
if ($array === null) {
return new \OC_OCS_Result(null, Http::STATUS_BAD_REQUEST, 'Invalid data supplied.');
}
try {
$this->service->add($array);
} catch (\Exception $e) {
return new \OC_OCS_Result(null, Http::STATUS_BAD_REQUEST, 'Invalid data supplied.');
}
return new \OC_OCS_Result(null, Http::STATUS_OK);
}
开发者ID:schiessle,项目名称:popularitycontestserver,代码行数:19,代码来源:externalapi.php
示例11: mockRSSToken
protected function mockRSSToken($requestToken, $userToken, $users)
{
if ($requestToken !== null) {
$this->request->expects($this->any())->method('getParam')->with('token', '')->willReturn($requestToken);
}
$this->config->expects($this->any())->method('getUsersForUserValue')->with('activity', 'rsstoken', $userToken)->willReturn($users);
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:7,代码来源:ManagerTest.php
示例12: generateHeaders
/**
* @param array $headers
* @param bool $hasMoreActivities
* @return array
*/
protected function generateHeaders(array $headers, $hasMoreActivities)
{
if ($hasMoreActivities && isset($headers['X-Activity-Last-Given'])) {
// Set the "Link" header for the next page
$nextPageParameters = ['since' => $headers['X-Activity-Last-Given'], 'limit' => $this->limit, 'sort' => $this->sort];
if ($this->objectType && $this->objectId) {
$nextPageParameters['object_type'] = $this->objectType;
$nextPageParameters['object_id'] = $this->objectId;
}
if ($this->request->getParam('format') !== null) {
$nextPageParameters['format'] = $this->request->getParam('format');
}
$nextPage = $this->request->getServerProtocol();
# http
$nextPage .= '://' . $this->request->getServerHost();
# localhost
$nextPage .= $this->request->getScriptName();
# /ocs/v2.php
$nextPage .= $this->request->getPathInfo();
# /apps/activity/api/v2/activity
$nextPage .= '?' . http_build_query($nextPageParameters);
$headers['Link'] = '<' . $nextPage . '>; rel="next"';
}
return $headers;
}
开发者ID:ynott,项目名称:activity,代码行数:30,代码来源:ocsendpoint.php
示例13: testLoadingJSAndCSS
/**
* @dataProvider dataLoadingJSAndCSS
* @param string $scriptName
* @param string $pathInfo
* @param IUser|null $user
* @param bool $scriptsAdded
*/
public function testLoadingJSAndCSS($scriptName, $pathInfo, $user, $scriptsAdded)
{
$this->request->expects($this->any())->method('getScriptName')->willReturn($scriptName);
$this->request->expects($this->any())->method('getPathInfo')->willReturn($pathInfo);
$this->session->expects($this->once())->method('getUser')->willReturn($user);
\OC_Util::$scripts = [];
\OC_Util::$styles = [];
include __DIR__ . '/../../appinfo/app.php';
if ($scriptsAdded) {
$this->assertNotEmpty(\OC_Util::$scripts);
$this->assertNotEmpty(\OC_Util::$styles);
} else {
$this->assertEmpty(\OC_Util::$scripts);
$this->assertEmpty(\OC_Util::$styles);
}
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:23,代码来源:AppTest.php
示例14: testAddPersonalRootCertificateInvalidCertificate
public function testAddPersonalRootCertificateInvalidCertificate()
{
$uploadedFile = ['tmp_name' => __DIR__ . '/../../data/certificates/badCertificate.crt', 'name' => 'badCertificate.crt'];
$this->request->expects($this->once())->method('getUploadedFile')->with('rootcert_import')->will($this->returnValue($uploadedFile));
$this->certificateManager->expects($this->once())->method('addCertificate')->with(file_get_contents($uploadedFile['tmp_name'], 'badCertificate.crt'))->will($this->throwException(new \Exception()));
$expected = new DataResponse('An error occurred.', Http::STATUS_UNPROCESSABLE_ENTITY);
$this->assertEquals($expected, $this->certificateController->addPersonalRootCertificate());
}
开发者ID:kenwi,项目名称:core,代码行数:8,代码来源:CertificateControllerTest.php
示例15: testAddGroupWithSpecialChar
public function testAddGroupWithSpecialChar()
{
$this->request->method('getParam')->with('groupid')->willReturn('Iñtërnâtiônàlizætiøn');
$this->groupManager->method('groupExists')->with('Iñtërnâtiônàlizætiøn')->willReturn(false);
$this->groupManager->expects($this->once())->method('createGroup')->with('Iñtërnâtiônàlizætiøn');
$result = $this->api->addGroup([]);
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
}
开发者ID:kenwi,项目名称:core,代码行数:9,代码来源:groupstest.php
示例16: processImage
/**
* Load the image.
*/
protected function processImage()
{
// If image has already been read return
if ($this->image instanceof Image) {
return;
}
$this->image = new Image();
\OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Type: ' . $this->request->getHeader('Content-Type'), \OCP\Util::DEBUG);
\OCP\Util::writeLog('contacts', __METHOD__ . ', Content-Length: ' . $this->request->getHeader('Content-Length'), \OCP\Util::DEBUG);
if (substr($this->request->getHeader('Content-Type'), 0, 6) !== 'image/') {
throw new \Exception('Only images can be used as contact photo', Http::STATUS_UNSUPPORTED_MEDIA_TYPE);
}
$maxSize = \OCP\Util::maxUploadFilesize('/');
if ($this->request->getHeader('Content-Length') > $maxSize) {
throw new \Exception(sprintf('The size of the file exceeds the maximum allowed %s', \OCP\Util::humanFileSize($maxSize)), Http::STATUS_REQUEST_ENTITY_TOO_LARGE);
}
$this->image->loadFromFileHandle($this->request->put);
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:21,代码来源:uploaded.php
示例17: testGenerateHeaders
/**
* @dataProvider dataGenerateHeaders
*
* @param string $sort
* @param int $limit
* @param string $objectType
* @param int $objectId
* @param string $format
* @param array $headersIn
* @param bool $hasMoreActivities
* @param array $expected
*/
public function testGenerateHeaders($sort, $limit, $objectType, $objectId, $format, array $headersIn, $hasMoreActivities, array $expected)
{
$this->invokePrivate($this->controller, 'sort', [$sort]);
$this->invokePrivate($this->controller, 'limit', [$limit]);
$this->invokePrivate($this->controller, 'objectType', [$objectType]);
$this->invokePrivate($this->controller, 'objectId', [$objectId]);
$this->request->expects($this->any())->method('getParam')->with('format')->willReturn($format);
$headers = $this->invokePrivate($this->controller, 'generateHeaders', [$headersIn, $hasMoreActivities]);
$this->assertEquals($expected, $headers);
}
开发者ID:ynott,项目名称:activity,代码行数:22,代码来源:ocsendpointtest.php
示例18: testIndexWithRegularBrowser
public function testIndexWithRegularBrowser()
{
$this->request->expects($this->once())->method('isUserAgent')->with(['/MSIE 8.0/'])->will($this->returnValue(false));
$this->viewController->expects($this->once())->method('getStorageInfo')->will($this->returnValue(['relative' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName']));
$this->config->expects($this->any())->method('getAppValue')->will($this->returnArgument(2));
$nav = new Template('files', 'appnavigation');
$nav->assign('navigationItems', [0 => ['id' => 'files', 'appname' => 'files', 'script' => 'list.php', 'order' => 0, 'name' => new \OC_L10N_String(new \OC_L10N('files'), 'All files', []), 'active' => false, 'icon' => ''], 1 => ['id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => null, 'active' => false, 'icon' => ''], 2 => ['id' => 'sharingin', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 10, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with you', []), 'active' => false, 'icon' => ''], 3 => ['id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 15, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with others', []), 'active' => false, 'icon' => ''], 4 => ['id' => 'sharinglinks', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 20, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared by link', []), 'active' => false, 'icon' => ''], 5 => ['id' => 'trashbin', 'appname' => 'files_trashbin', 'script' => 'list.php', 'order' => 50, 'name' => new \OC_L10N_String(new \OC_L10N('files_trashbin'), 'Deleted files', []), 'active' => false, 'icon' => '']]);
$expected = new Http\TemplateResponse('files', 'index', ['usedSpacePercent' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName', 'isPublic' => false, 'mailNotificationEnabled' => 'no', 'mailPublicNotificationEnabled' => 'no', 'allowShareWithLink' => 'yes', 'appNavigation' => $nav, 'appContents' => [0 => ['id' => 'files', 'content' => null], 1 => ['id' => 'favorites', 'content' => null], 2 => ['id' => 'sharingin', 'content' => null], 3 => ['id' => 'sharingout', 'content' => null], 4 => ['id' => 'sharinglinks', 'content' => null], 5 => ['id' => 'trashbin', 'content' => null]]]);
$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
}
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:10,代码来源:ViewControllerTest.php
示例19: testSetLanguageFromRequest
/**
* @dataProvider dataSetLanguageFromRequest
*
* @param string|null $app
* @param string $header
* @param string|null $requestLanguage
* @param string[] $availableLanguages
* @param string $expected
* @param string $expectedLang
*/
public function testSetLanguageFromRequest($app, $header, $requestLanguage, array $availableLanguages, $expected, $expectedLang)
{
$factory = $this->getFactory(['findAvailableLanguages']);
$factory->expects($this->once())->method('findAvailableLanguages')->with($app)->willReturn($availableLanguages);
$this->request->expects($this->once())->method('getHeader')->with('ACCEPT_LANGUAGE')->willReturn($header);
if ($requestLanguage !== null) {
$this->invokePrivate($factory, 'requestLanguage', [$requestLanguage]);
}
$this->assertSame($expected, $factory->setLanguageFromRequest($app), 'Asserting returned language');
$this->assertSame($expectedLang, $this->invokePrivate($factory, 'requestLanguage'), 'Asserting stored language');
}
开发者ID:farukuzun,项目名称:core-1,代码行数:21,代码来源:factorytest.php
示例20: createServer
/**
* @param string $baseUri
* @param string $requestUri
* @param BackendInterface $authBackend
* @param callable $viewCallBack callback that should return the view for the dav endpoint
* @return Server
*/
public function createServer($baseUri, $requestUri, BackendInterface $authBackend, callable $viewCallBack)
{
// Fire up server
$objectTree = new \OCA\DAV\Connector\Sabre\ObjectTree();
$server = new \OCA\DAV\Connector\Sabre\Server($objectTree);
// Set URL explicitly due to reverse-proxy situations
$server->httpRequest->setUrl($requestUri);
$server->setBaseUri($baseUri);
// Load plugins
$defaults = new \OC_Defaults();
$server->addPlugin(new \OCA\DAV\Connector\Sabre\MaintenancePlugin($this->config));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin($this->config));
$server->addPlugin(new \Sabre\DAV\Auth\Plugin($authBackend, $defaults->getName()));
// FIXME: The following line is a workaround for legacy components relying on being able to send a GET to /
$server->addPlugin(new \OCA\DAV\Connector\Sabre\DummyGetResponsePlugin());
$server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $this->logger));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
// Some WebDAV clients do require Class 2 WebDAV support (locking), since
// we do not provide locking we emulate it using a fake locking plugin.
if ($this->request->isUserAgent(['/WebDAVFS/', '/Microsoft Office OneNote 2013/', '/Microsoft-WebDAV-MiniRedir/'])) {
$server->addPlugin(new \OCA\DAV\Connector\Sabre\FakeLockerPlugin());
}
if (BrowserErrorPagePlugin::isBrowserRequest($this->request)) {
$server->addPlugin(new BrowserErrorPagePlugin());
}
// wait with registering these until auth is handled and the filesystem is setup
$server->on('beforeMethod', function () use($server, $objectTree, $viewCallBack) {
// ensure the skeleton is copied
$userFolder = \OC::$server->getUserFolder();
/** @var \OC\Files\View $view */
$view = $viewCallBack($server);
$rootInfo = $view->getFileInfo('');
// Create ownCloud Dir
if ($rootInfo->getType() === 'dir') {
$root = new \OCA\DAV\Connector\Sabre\Directory($view, $rootInfo, $objectTree);
} else {
$root = new \OCA\DAV\Connector\Sabre\File($view, $rootInfo);
}
$objectTree->init($root, $view, $this->mountManager);
$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($objectTree, $view, $this->config, false, !$this->config->getSystemValue('debug', false)));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\QuotaPlugin($view));
if ($this->userSession->isLoggedIn()) {
$server->addPlugin(new \OCA\DAV\Connector\Sabre\TagsPlugin($objectTree, $this->tagManager));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\SharesPlugin($objectTree, $this->userSession, $userFolder, \OC::$server->getShareManager()));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\CommentPropertiesPlugin(\OC::$server->getCommentsManager(), $this->userSession));
$server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesReportPlugin($objectTree, $view, \OC::$server->getSystemTagManager(), \OC::$server->getSystemTagObjectMapper(), $this->userSession, \OC::$server->getGroupManager(), $userFolder));
// custom properties plugin must be the last one
$server->addPlugin(new \Sabre\DAV\PropertyStorage\Plugin(new \OCA\DAV\Connector\Sabre\CustomPropertiesBackend($objectTree, $this->databaseConnection, $this->userSession->getUser())));
}
$server->addPlugin(new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin());
}, 30);
// priority 30: after auth (10) and acl(20), before lock(50) and handling the request
return $server;
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:61,代码来源:serverfactory.php
注:本文中的OCP\IRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论