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

Connector::access()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 4
nop 5
dl 0
loc 6
ccs 0
cts 4
cp 0
crap 12
rs 9.4285
c 0
b 0
f 0
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