fkooman\RemoteStorage\RemoteStorageService::__construct PHP Method

__construct() public method

public __construct ( RemoteStorage $remoteStorage, ApprovalManagementStorage $approvalManagementStorage, fkooman\Tpl\TemplateManagerInterface $templateManager, fkooman\OAuth\ClientStorageInterface $clientStorage, fkooman\OAuth\ResourceServerStorageInterface $resourceServerStorage, fkooman\OAuth\ApprovalStorageInterface $approvalStorage, fkooman\OAuth\AuthorizationCodeStorageInterface $authorizationCodeStorage, fkooman\OAuth\AccessTokenStorageInterface $accessTokenStorage, array $options = [], fkooman\IO\IO $io = null )
$remoteStorage RemoteStorage
$approvalManagementStorage ApprovalManagementStorage
$templateManager fkooman\Tpl\TemplateManagerInterface
$clientStorage fkooman\OAuth\ClientStorageInterface
$resourceServerStorage fkooman\OAuth\ResourceServerStorageInterface
$approvalStorage fkooman\OAuth\ApprovalStorageInterface
$authorizationCodeStorage fkooman\OAuth\AuthorizationCodeStorageInterface
$accessTokenStorage fkooman\OAuth\AccessTokenStorageInterface
$options array
$io fkooman\IO\IO
    public function __construct(RemoteStorage $remoteStorage, ApprovalManagementStorage $approvalManagementStorage, TemplateManagerInterface $templateManager, ClientStorageInterface $clientStorage, ResourceServerStorageInterface $resourceServerStorage, ApprovalStorageInterface $approvalStorage, AuthorizationCodeStorageInterface $authorizationCodeStorage, AccessTokenStorageInterface $accessTokenStorage, array $options = array(), IO $io = null)
    {
        $this->remoteStorage = $remoteStorage;
        $this->approvalManagementStorage = $approvalManagementStorage;
        parent::__construct($templateManager, $clientStorage, $resourceServerStorage, $approvalStorage, $authorizationCodeStorage, $accessTokenStorage, $options, $io);
        $this->get('/_account', function (Request $request, UserInfoInterface $userInfo) {
            $approvalList = $this->approvalManagementStorage->getApprovalList($userInfo->getUserId());
            return $this->templateManager->render('getAccountPage', array('approval_list' => $approvalList, 'host' => $request->getHeader('Host'), 'user_id' => $userInfo->getUserId(), 'disk_usage' => $this->remoteStorage->getFolderSize(new Path('/' . $userInfo->getUserId() . '/')), 'request_url' => $request->getUrl()->toString(), 'show_account_icon' => true));
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('user'))));
        $this->delete('/_approvals', function (Request $request, UserInfoInterface $userInfo) {
            $deleteApprovalRequest = RequestValidation::validateDeleteApprovalRequest($request);
            $approval = new Approval($userInfo->getUserId(), $deleteApprovalRequest['client_id'], $deleteApprovalRequest['response_type'], $deleteApprovalRequest['scope']);
            $this->approvalManagementStorage->deleteApproval($approval);
            return new RedirectResponse($request->getUrl()->getRootUrl() . '_account', 302);
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('user'))));
        $this->get('/.well-known/webfinger', function (Request $request) {
            $resource = $request->getUrl()->getQueryParameter('resource');
            if (null === $resource) {
                throw new BadRequestException('resource parameter missing');
            }
            if (0 !== strpos($resource, 'acct:')) {
                throw new BadRequestException('unsupported resource type');
            }
            $userAddress = substr($resource, 5);
            $atPos = strpos($userAddress, '@');
            if (false === $atPos) {
                throw new BadRequestException('invalid user address');
            }
            $user = substr($userAddress, 0, $atPos);
            $webFingerData = array('links' => array(array('href' => sprintf('%s%s', $request->getUrl()->getRootUrl(), $user), 'properties' => array('http://remotestorage.io/spec/version' => 'draft-dejong-remotestorage-05', 'http://remotestorage.io/spec/web-authoring' => null, 'http://tools.ietf.org/html/rfc6749#section-4.2' => sprintf('%s_oauth/authorize?login_hint=%s', $request->getUrl()->getRootUrl(), $user), 'http://tools.ietf.org/html/rfc6750#section-2.3' => 'true', 'http://tools.ietf.org/html/rfc7233' => 'development' !== $this->options['server_mode'] ? 'GET' : null), 'rel' => 'http://tools.ietf.org/id/draft-dejong-remotestorage'), array('href' => sprintf('%s%s', $request->getUrl()->getRootUrl(), $user), 'properties' => array('http://remotestorage.io/spec/version' => 'draft-dejong-remotestorage-03', 'http://tools.ietf.org/html/rfc2616#section-14.16' => 'development' !== $this->options['server_mode'] ? 'GET' : false, 'http://tools.ietf.org/html/rfc6749#section-4.2' => sprintf('%s_oauth/authorize?login_hint=%s', $request->getUrl()->getRootUrl(), $user), 'http://tools.ietf.org/html/rfc6750#section-2.3' => true), 'rel' => 'remotestorage')));
            $response = new Response(200, 'application/jrd+json');
            $response->setHeader('Access-Control-Allow-Origin', '*');
            $response->setBody(Json::encode($webFingerData));
            return $response;
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('enabled' => false)));
        $this->get('/', function (Request $request, UserInfoInterface $userInfo = null) {
            return $this->templateManager->render('indexPage', array('user_id' => null !== $userInfo ? $userInfo->getUserId() : null, 'show_account_icon' => true));
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('user'), 'require' => false)));
        $this->addRoute(['GET', 'HEAD'], '*', function (Request $request, TokenInfo $tokenInfo = null) {
            $response = $this->getObject($request, $tokenInfo);
            $this->addNoCache($response);
            $this->addCors($response);
            return $response;
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('api'), 'require' => false)));
        // put a document
        $this->put('*', function (Request $request, TokenInfo $tokenInfo) {
            $response = $this->putDocument($request, $tokenInfo);
            $this->addCors($response);
            return $response;
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('api')), 'fkooman\\Rest\\Plugin\\ReferrerCheck\\ReferrerCheckPlugin' => array('enabled' => false)));
        // delete a document
        $this->delete('*', function (Request $request, TokenInfo $tokenInfo) {
            $response = $this->deleteDocument($request, $tokenInfo);
            $this->addCors($response);
            return $response;
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('activate' => array('api')), 'fkooman\\Rest\\Plugin\\ReferrerCheck\\ReferrerCheckPlugin' => array('enabled' => false)));
        // options request
        $this->options('*', function (Request $request) {
            $response = new Response();
            $response->setHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, HEAD, OPTIONS');
            $response->setHeader('Access-Control-Allow-Headers', 'Authorization, Content-Length, Content-Type, Origin, X-Requested-With, If-Match, If-None-Match');
            $this->addCors($response);
            return $response;
        }, array('fkooman\\Rest\\Plugin\\Authentication\\AuthenticationPlugin' => array('enabled' => false)));
    }