Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
bfile.php
1<?php
2
4
5
7
8class BFile extends File
9{
10 protected $file;
11
12 public function __construct(array $file, $name = null)
13 {
14 $this->file = $file;
15 if ($name === null)
16 {
17 $name = $this->file['ORIGINAL_NAME'];
18 }
19
20 parent::__construct(null, $name, $this->file['CONTENT_TYPE']);
21 }
22
23 public static function createByFileData(array $file, $name = null)
24 {
25 return new self($file, $name);
26 }
27
28 public static function createByFileId($fileId, $name = null)
29 {
30 $file = \CFile::getFileArray($fileId);
31 if (!$file)
32 {
33 throw new Main\ObjectNotFoundException("Could not find file ({$fileId})");
34 }
35
36 return new self($file, $name);
37 }
38
42 public function getFile()
43 {
44 return $this->file;
45 }
46
50 protected function prepareFile()
51 {
52 return $this->getFile();
53 }
54
55 protected function prepareOptions()
56 {
57 return [
58 'force_download' => !$this->isShowInline(),
59 'cache_time' => $this->getCacheTime(),
60 'attachment_name' => $this->getName(),
61 'content_type' => $this->getContentType(),
62 ];
63 }
64}
static createByFileData(array $file, $name=null)
Definition bfile.php:23
static createByFileId($fileId, $name=null)
Definition bfile.php:28
__construct(array $file, $name=null)
Definition bfile.php:12