Completed
Push — master ( 61c24d...075a0d )
by recca
07:28
created

elFinderVolumeTrash::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * elFinder driver for trash bin at local filesystem.
4
 *
5
 * @author NaokiSawada
6
 **/
7
class elFinderVolumeTrash extends elFinderVolumeLocalFileSystem
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
{
9
    /**
10
     * Driver id
11
     * Must be started from letter and contains [a-z0-9]
12
     * Used as part of volume id.
13
     *
14
     * @var string
15
     **/
16
    protected $driverId = 't';
17
18
    public function __construct()
19
    {
20
        parent::__construct();
21
        // original option of the Trash
22
        $this->options['lockEverything'] = false; // Lock all items in the trash to disable delete, move, rename.
23
24
        // common options as the volume driver
25
        $this->options['alias'] = 'Trash';
26
        $this->options['quarantine'] = '';
27
        $this->options['rootCssClass'] = 'elfinder-navbar-root-trash';
28
        $this->options['copyOverwrite'] = false;
29
        $this->options['uiCmdMap'] = ['paste' => 'hidden', 'mkdir' => 'hidden', 'copy' => 'restore'];
30
        $this->options['disabled'] = ['archive', 'duplicate', 'edit', 'extract', 'mkfile', 'places', 'put', 'rename', 'resize', 'upload'];
31
    }
32
33
    public function mount(array $opts)
34
    {
35
        if ($this->options['lockEverything']) {
36
            if (! is_array($opts['attributes'])) {
37
                $opts['attributes'] = [];
38
            }
39
            $attr = [
40
                'pattern' => '/./',
41
                'locked' => true,
42
            ];
43
            array_unshift($opts['attributes'], $attr);
44
        }
45
        // force set `copyJoin` to true
46
        $opts['copyJoin'] = true;
47
48
        return parent::mount($opts);
49
    }
50
}
51