Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
disk.php
1<?php
3
4use Bitrix\Disk\Controller\File,
6 Bitrix\Disk\Controller\Content,
11
18class Disk extends Controller
19{
20 protected function getDefaultPreFilters(): array
21 {
22 return [
23 new ActionFilter\HttpMethod(['POST']),
24 new Filter\Authorization(),
25 new Filter\DiskFolderAccessCheck(),
26 ];
27 }
28
29 public function configureActions(): array
30 {
31 return [
32 'upload' => [
33 '-prefilters' => [
34 ActionFilter\Csrf::class,
35 ActionFilter\Authentication::class
36 ],
37 ],
38 'commit' => [
39 '-prefilters' => [
40 ActionFilter\Csrf::class,
41 ActionFilter\Authentication::class
42 ],
43 ],
44 ];
45 }
46
47 protected function processBeforeAction(Action $action): bool
48 {
49 if (!Loader::includeModule('disk'))
50 {
51 return false;
52 }
53
54 return parent::processBeforeAction($action);
55 }
56
57 public function uploadAction($filename, $token = null)
58 {
59 $params = [
60 'filename' => $filename,
61 'token' => $token,
62 ];
64
65 return $this->forward(new Content(), 'upload', $params);
66 }
67
68 public function commitAction($folderId, $filename, $contentId, $generateUniqueName = false)
69 {
70 $params = [
71 'folderId' => $folderId,
72 'filename' => $filename,
73 'contentId' => $contentId,
74 'generateUniqueName' => $generateUniqueName,
75 ];
76
78
79 return $this->forward(new File(), 'createByContent', $params);
80 }
81}
commitAction($folderId, $filename, $contentId, $generateUniqueName=false)
Definition disk.php:68
uploadAction($filename, $token=null)
Definition disk.php:57
processBeforeAction(Action $action)
Definition disk.php:47
forward($controller, string $actionName, array $parameters=null)