Connector::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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