Skip to content

Commit d3bac1f

Browse files
authored
Merge pull request #994 from yousuf-hossain-shanto/master
Added LfmItem property selection via config
2 parents a4223ee + 0a9aac3 commit d3bac1f

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ composer.lock
33
/docs/Gemfile.lock
44
/docs/_site
55
.DS_Store
6+
/.idea

src/LfmItem.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ class LfmItem
1212
private $isDirectory;
1313
private $mimeType = null;
1414

15-
private $columns = ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'];
15+
private $columns = [];
1616
public $attributes = [];
1717

1818
public function __construct(LfmPath $lfm, Lfm $helper, $isDirectory = false)
1919
{
2020
$this->lfm = $lfm->thumb(false);
2121
$this->helper = $helper;
2222
$this->isDirectory = $isDirectory;
23+
$this->columns = $helper->config('item_columns')??['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'];
2324
}
2425

2526
public function __get($var_name)

src/config/lfm.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@
109109
// setting it to false show `error-file-exist` error and stop upload
110110
'over_write_on_duplicate' => false,
111111

112+
// Item Columns
113+
'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'],
114+
112115
/*
113116
|--------------------------------------------------------------------------
114117
| Thumbnail

tests/LfmItemTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function setUp()
1919

2020
$this->lfm_path = m::mock(LfmPath::class);
2121
$this->lfm_path->shouldReceive('thumb')->andReturn($this->lfm_path);
22+
$this->lfm->shouldReceive('config')->with('item_columns')->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);
2223
}
2324

2425
public function tearDown()
@@ -30,7 +31,7 @@ public function tearDown()
3031

3132
public function testMagicGet()
3233
{
33-
$this->lfm_item = new LfmItem($this->lfm_path, m::mock(Lfm::class));
34+
$this->lfm_item = new LfmItem($this->lfm_path, $this->lfm);
3435

3536
$this->lfm_item->attributes['foo'] = 'bar';
3637

tests/LfmPathTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function testFolders()
126126
$helper->shouldReceive('getThumbFolderName')->andReturn('thumbs');
127127
$helper->shouldReceive('isRunningOnWindows')->andReturn(false);
128128
$helper->shouldReceive('ds')->andReturn('/');
129+
$helper->shouldReceive('config')->with('item_columns')->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);
129130

130131
$path = new LfmPath($helper);
131132

@@ -145,6 +146,7 @@ public function testFiles()
145146
$helper->shouldReceive('getNameFromPath')->andReturn('bar');
146147
$helper->shouldReceive('isRunningOnWindows')->andReturn(false);
147148
$helper->shouldReceive('ds')->andReturn('/');
149+
$helper->shouldReceive('config')->with('item_columns')->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);
148150

149151
$path = new LfmPath($helper);
150152

@@ -156,6 +158,7 @@ public function testPretty()
156158
$helper = m::mock(Lfm::class);
157159
$helper->shouldReceive('getNameFromPath')->andReturn('bar');
158160
$helper->shouldReceive('isRunningOnWindows')->andReturn(false);
161+
$helper->shouldReceive('config')->with('item_columns')->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);
159162

160163
$path = new LfmPath($helper);
161164

0 commit comments

Comments
 (0)