Passed
Push — master ( abb116...45058a )
by Georgi
05:11
created

FileAccessHistory::displayFileAccessHistory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 16
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Epesi\FileStorage;
4
5
use Epesi\Core\System\Modules\ModuleView;
0 ignored issues
show
Bug introduced by
The type Epesi\Core\System\Modules\ModuleView was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Epesi\FileStorage\Seeds\FileView;
7
use Epesi\Core\Layout\Seeds\ActionBar;
8
use Epesi\FileStorage\Models\FileAccessLog;
9
use atk4\ui\GridFilterPlugin;
0 ignored issues
show
Bug introduced by
The type atk4\ui\GridFilterPlugin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use atk4\core\SessionTrait;
11
12
class FileAccessHistory extends ModuleView
13
{
14
	use SessionTrait;
15
	
16
	protected $label = 'File Access History';
17
	
18
	protected $fileId;
19
	
20
	public function body()
21
	{
22
		ActionBar::addButton('back')->link(url()->previous());
23
		
24
		$this->fileId = $this->stickyGet('id', $this->recall('fileId'));
25
		
26
		$this->memorize('fileId', $this->fileId);
27
		
28
		$this->displayFileDetails();
29
		
30
		$this->displayFileAccessHistory();
31
	}
32
	
33
	public function displayFileDetails()
34
	{
35
		$this->add(['View', ['ui' => 'segment']])->add([new FileView($this->fileId), 'disableActions' => 'history']);
36
	}
37
	
38
	public function displayFileAccessHistory()
39
	{	
40
		$grid = $this->add([
41
				'CRUD',
42
				'quickSearch' => [
43
						'accessed_by_user', 'action', 'ip_address', 'host_name'
44
				]
45
		]);
46
47
		$grid->addItemsPerPageSelector([10, 25, 50, 100], __('Items per page') . ':');
0 ignored issues
show
Bug introduced by
Are you sure __('Items per page') of type array|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

47
		$grid->addItemsPerPageSelector([10, 25, 50, 100], /** @scrutinizer ignore-type */ __('Items per page') . ':');
Loading history...
48
		
49
		$grid->setModel(FileAccessLog::create(['read_only' => true])->addCondition('file_id', $this->stickyGet('id'))->setOrder('accessed_at desc'));
50
51
		$grid->setModel(FileAccessLog::create(['read_only' => true])->addCondition('file_id', $this->fileId)->setOrder('accessed_at', 'desc'));
52
53
		$grid->addFilterColumn();
54
	}
55
}
56