From c5759af2aa8681b789ec7ef001c0e81d4a3920cc Mon Sep 17 00:00:00 2001 From: Yousuf Hossain Date: Tue, 15 Sep 2020 12:12:51 +0600 Subject: [PATCH 1/2] Added LfmItem columns config --- src/LfmItem.php | 3 ++- src/config/lfm.php | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/LfmItem.php b/src/LfmItem.php index b2962150..de0c0979 100644 --- a/src/LfmItem.php +++ b/src/LfmItem.php @@ -12,7 +12,7 @@ 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) @@ -20,6 +20,7 @@ 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) diff --git a/src/config/lfm.php b/src/config/lfm.php index d30e1803..c831d069 100644 --- a/src/config/lfm.php +++ b/src/config/lfm.php @@ -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 From 0a9aac37b47d2da5a1cc4953c34532cc752a380e Mon Sep 17 00:00:00 2001 From: Yousuf Hossain Date: Sun, 20 Sep 2020 07:22:16 +0600 Subject: [PATCH 2/2] Added LfmItem property selection via config --- .gitignore | 1 + tests/LfmItemTest.php | 3 ++- tests/LfmPathTest.php | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8a98ea1a..d8fe48fe 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock /docs/Gemfile.lock /docs/_site .DS_Store +/.idea diff --git a/tests/LfmItemTest.php b/tests/LfmItemTest.php index 9b6e2444..0c37532e 100644 --- a/tests/LfmItemTest.php +++ b/tests/LfmItemTest.php @@ -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() @@ -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'; diff --git a/tests/LfmPathTest.php b/tests/LfmPathTest.php index aa1db036..b358f121 100644 --- a/tests/LfmPathTest.php +++ b/tests/LfmPathTest.php @@ -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); @@ -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); @@ -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);