Skip to content

Added LfmItem property selection via config #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ composer.lock
/docs/Gemfile.lock
/docs/_site
.DS_Store
/.idea
3 changes: 2 additions & 1 deletion src/LfmItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ class LfmItem
private $isDirectory;
private $mimeType = null;

private $columns = ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'];
private $columns = [];
public $attributes = [];

public function __construct(LfmPath $lfm, Lfm $helper, $isDirectory = false)
{
$this->lfm = $lfm->thumb(false);
$this->helper = $helper;
$this->isDirectory = $isDirectory;
$this->columns = $helper->config('item_columns')??['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'];
}

public function __get($var_name)
Expand Down
3 changes: 3 additions & 0 deletions src/config/lfm.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@
// setting it to false show `error-file-exist` error and stop upload
'over_write_on_duplicate' => false,

// Item Columns
'item_columns' => ['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url'],

/*
|--------------------------------------------------------------------------
| Thumbnail
Expand Down
3 changes: 2 additions & 1 deletion tests/LfmItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function setUp()

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

public function tearDown()
Expand All @@ -30,7 +31,7 @@ public function tearDown()

public function testMagicGet()
{
$this->lfm_item = new LfmItem($this->lfm_path, m::mock(Lfm::class));
$this->lfm_item = new LfmItem($this->lfm_path, $this->lfm);

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

Expand Down
3 changes: 3 additions & 0 deletions tests/LfmPathTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function testFolders()
$helper->shouldReceive('getThumbFolderName')->andReturn('thumbs');
$helper->shouldReceive('isRunningOnWindows')->andReturn(false);
$helper->shouldReceive('ds')->andReturn('/');
$helper->shouldReceive('config')->with('item_columns')->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']);

$path = new LfmPath($helper);

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

$path = new LfmPath($helper);

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

$path = new LfmPath($helper);

Expand Down