|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Quantum PHP Framework |
|
5
|
|
|
* |
|
6
|
|
|
* An open source software development framework for PHP |
|
7
|
|
|
* |
|
8
|
|
|
* @package Quantum |
|
9
|
|
|
* @author Arman Ag. <[email protected]> |
|
10
|
|
|
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) |
|
11
|
|
|
* @link http://quantum.softberg.org/ |
|
12
|
|
|
* @since 2.8.0 |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Quantum\Console\Commands; |
|
16
|
|
|
|
|
17
|
|
|
use Quantum\Libraries\Storage\FileSystem; |
|
18
|
|
|
use Quantum\Console\QtCommand; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Class DebugBarAssetsCommand |
|
22
|
|
|
* @package Quantum\Console\Commands |
|
23
|
|
|
*/ |
|
24
|
|
|
class DebugBarAssetsCommand extends QtCommand |
|
25
|
|
|
{ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Command name |
|
29
|
|
|
* @var string |
|
30
|
|
|
*/ |
|
31
|
|
|
protected $name = 'install:debugbar'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Command description |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $description = 'Publishes debugbar assets'; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Command help text |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $help = 'The command will publish debugbar assets'; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Path to public debug bar resources |
|
47
|
|
|
* @var string |
|
48
|
|
|
*/ |
|
49
|
|
|
private $publicDebugbarFolderPath = 'public/assets/DebugBar/Resources'; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Path to vendor debug bar resources |
|
53
|
|
|
* @var string |
|
54
|
|
|
*/ |
|
55
|
|
|
private $vendorDebugbarFolderPath = 'vendor/maximebf/debugbar/src/DebugBar/Resources'; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Executes the command and publishes the debug bar assets |
|
59
|
|
|
*/ |
|
60
|
|
|
public function exec() |
|
61
|
|
|
{ |
|
62
|
|
|
if (installed(assets_dir() . DS . 'DebugBar' . DS . 'Resources' . DS . 'debugbar.css')) { |
|
63
|
|
|
$this->error('The debuger already installed'); |
|
64
|
|
|
return; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$this->recursive_copy($this->vendorDebugbarFolderPath, $this->publicDebugbarFolderPath); |
|
68
|
|
|
|
|
69
|
|
|
$this->info('Debugbar assets successfully published'); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Recursively copies the debug bar assets |
|
74
|
|
|
* @param string $src |
|
75
|
|
|
* @param string $dst |
|
76
|
|
|
* @throws \RuntimeException |
|
77
|
|
|
*/ |
|
78
|
|
|
private function recursive_copy(string $src, string $dst) |
|
79
|
|
|
{ |
|
80
|
|
|
$fs = new FileSystem(); |
|
81
|
|
|
|
|
82
|
|
|
$dir = opendir($src); |
|
83
|
|
|
|
|
84
|
|
|
if ($dst != $this->publicDebugbarFolderPath) { |
|
85
|
|
|
if ($fs->makeDirectory($dst, 777, true) === false) { |
|
|
|
|
|
|
86
|
|
|
throw new \RuntimeException(t('exception.directory_cant_be_created', $dst)); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
if (is_resource($dir)) { |
|
91
|
|
|
while (($file = readdir($dir))) { |
|
92
|
|
|
if (($file != '.') && ($file != '..')) { |
|
93
|
|
|
if ($fs->isDirectory($src . '/' . $file)) { |
|
94
|
|
|
$this->recursive_copy($src . '/' . $file, $dst . '/' . $file); |
|
95
|
|
|
} else { |
|
96
|
|
|
if ($file) { |
|
97
|
|
|
copy($src . '/' . $file, $dst . '/' . $file); |
|
98
|
|
|
} |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
closedir($dir); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.