Completed
Push — master ( e6bfbd...af89b1 )
by recca
03:06
created

Connector   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 53
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 6 1
A access() 0 6 3
A output() 0 7 1
1
<?php
2
3
namespace Recca0120\Elfinder;
4
5
use elFinder;
6
use elFinderConnector;
7
use Symfony\Component\HttpFoundation\StreamedResponse;
8
9
class Connector extends elFinderConnector
10
{
11
    /**
12
     * response.
13
     *
14
     * @var mixed
15
     */
16
    protected $response;
17
18
    /**
19
     * run.
20
     *
21
     * @return mixed
22
     */
23
    public function run()
24
    {
25
        parent::run();
26
27
        return $this->response;
28
    }
29
30
    /**
31
     * access.
32
     *
33
     * @param array  $attr
34
     * @param string  $path
35
     * @param array $data
36
     * @param string $volume
37
     * @param bool $isDir
38
     * @return bool|null
39
     */
40
    public static function access($attr, $path, $data, $volume, $isDir)
41
    {
42
        return strpos(basename($path), '.') === 0       // if file/folder begins with '.' (dot)
43
            ? ! ($attr == 'read' || $attr == 'write')    // set read+write to false, other (locked+hidden) set to true
44
            : null;                                    // else elFinder decide it itself
45
    }
46
47
    /**
48
     * output.
49
     *
50
     * @param array $data
51
     *
52
     * @return mixed
53
     */
54
    protected function output(array $data)
55
    {
56
        return $this->response = new StreamedResponse(function () use ($data) {
57
            header('Access-Control-Allow-Origin: *');
58
            parent::output($data);
59
        });
60
    }
61
}
62