1 | <?php |
||
35 | class SubscriptionsProxyController extends Controller { |
||
36 | |||
37 | /** |
||
38 | * @var IUserSession |
||
39 | */ |
||
40 | private $userSession; |
||
41 | |||
42 | /** |
||
43 | * @var \OCP\Files\IRootFolder |
||
44 | */ |
||
45 | private $storage; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | private $content; |
||
51 | |||
52 | /** |
||
53 | * @var int |
||
54 | */ |
||
55 | private $responseStatusCode; |
||
56 | |||
57 | /** |
||
58 | * @param string $appName |
||
59 | * @param IRequest $request an instance of the request |
||
60 | * @param IUserSession $userSession |
||
61 | * @param IRootFolder $storage |
||
62 | */ |
||
63 | public function __construct($appName, IRequest $request, |
||
64 | IUserSession $userSession, IRootFolder $storage) { |
||
65 | parent::__construct($appName, $request); |
||
66 | $this->userSession = $userSession; |
||
67 | $this->storage = $storage; |
||
68 | $this->content = ''; |
||
69 | $this->responseStatusCode = HTTP::STATUS_OK; |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @NoAdminRequired |
||
74 | * @NoCSRFRequired |
||
75 | * |
||
76 | * @param string $icsurl |
||
77 | * @return DataDisplayResponse |
||
78 | */ |
||
79 | public function getIcsFile($icsurl) { |
||
80 | try { |
||
81 | $file = $this->storage->get('/' . basename($icsurl)); |
||
82 | |||
83 | if ($file instanceof File) { |
||
|
|||
84 | $date = new \DateTime(); |
||
85 | if ($date->getTimestamp() - $file->getMtime() > 3600) { |
||
86 | $this->fetchFile($file, $icsurl); |
||
87 | } else { |
||
88 | $this->content = $file->getContent(); |
||
89 | } |
||
90 | } |
||
91 | } catch (NotFoundException $e) { |
||
92 | $file = $this->createFile($this->userSession->getUser()->getUID(), $icsurl); |
||
93 | $this->fetchFile($file, $icsurl); |
||
94 | } |
||
95 | |||
96 | return new DataDisplayResponse($this->content, $this->responseStatusCode, [ |
||
97 | 'content-type' => 'text/calendar', |
||
98 | 'Etag' => '"' . md5($this->content) . '"' |
||
99 | ]); |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * @param string $url |
||
104 | * @return boolean |
||
105 | * @throws \Exception |
||
106 | */ |
||
107 | private function checkHeaders($url) { |
||
122 | |||
123 | /** |
||
124 | * @param File $file |
||
125 | * @param $icsurl |
||
126 | * @return null|string |
||
127 | */ |
||
128 | private function fetchFile(File $file, $icsurl) { |
||
144 | |||
145 | |||
146 | /** |
||
147 | * @param int $userId |
||
148 | * @param string $url |
||
149 | * @return File |
||
150 | */ |
||
151 | private function createFile($userId, $url) { |
||
156 | |||
157 | /** |
||
158 | * @param $userId |
||
159 | * @return IRootFolder |
||
160 | */ |
||
161 | private function getFolder() { |
||
170 | } |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.