|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace LeKoala\Encrypt; |
|
4
|
|
|
|
|
5
|
|
|
use Exception; |
|
6
|
|
|
use SilverStripe\Assets\File; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* @mixin \LeKoala\Encrypt\EncryptedDBFile |
|
10
|
|
|
* @property bool $Encrypted |
|
11
|
|
|
*/ |
|
12
|
|
|
class EncryptedFile extends File |
|
13
|
|
|
{ |
|
14
|
|
|
protected function onBeforeWrite() |
|
15
|
|
|
{ |
|
16
|
|
|
parent::onBeforeWrite(); |
|
17
|
|
|
try { |
|
18
|
|
|
$this->encryptFileIfNeeded(false); |
|
|
|
|
|
|
19
|
|
|
} catch (Exception $ex) { |
|
20
|
|
|
$this->Encrypted = false; |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []) |
|
25
|
|
|
{ |
|
26
|
|
|
$this->Encrypted = false; |
|
27
|
|
|
return parent::setFromLocalFile($path, $filename = null, $hash = null, $variant = null, $config = []); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
public function setFromStream($stream, $filename, $hash = null, $variant = null, $config = []) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->Encrypted = false; |
|
33
|
|
|
return parent::setFromStream($stream, $filename, $hash = null, $variant = null, $config = []); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function setFromString($data, $filename, $hash = null, $variant = null, $config = []) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->Encrypted = false; |
|
39
|
|
|
return parent::setFromString($data, $filename, $hash = null, $variant = null, $config = []); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|