本文整理汇总了PHP中OCP\IRequest类的典型用法代码示例。如果您正苦于以下问题:PHP IRequest类的具体用法?PHP IRequest怎么用?PHP IRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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())));
}
});
}
示例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]);
}
示例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())));
}
});
}
示例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())));
}
});
}
示例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);
}
}
}
示例6: 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();
}
示例7: 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());
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: 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;
}
示例12: 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);
}
}
示例13: 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());
}
示例14: 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());
}
示例15: 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);
}