8000 refactor isDirectory() & pretty() in LfmPath.php · git99969/laravel-filemanager@c043d02 · GitHub
[go: up one dir, main page]

Skip to content

Commit c043d02

Browse files
committed
refactor isDirectory() & pretty() in LfmPath.php
1 parent 8d728a4 commit c043d02

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

src/LfmPath.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ public function files()
118118

119119
public function pretty($item_path)
120120
{
121-
$lfm_path = clone $this;
122-
$lfm_path = $lfm_path->setName($this->helper->getNameFromPath($item_path));
123-
124-
return Container::getInstance()->makeWith(LfmItem::class, ['lfm' => $lfm_path, 'helper' => $this->helper]);
121+
return Container::getInstance()->makeWith(LfmItem::class, [
122+
'lfm' => (clone $this)->setName($this->helper->getNameFromPath($item_path)),
123+
'helper' => $this->helper
124+
]);
125125
}
126126

127127
public function delete()
@@ -153,18 +153,11 @@ public function isDirectory()
153153
$working_dir = $this->path('working_dir');
154154
$parent_dir = substr($working_dir, 0, strrpos($working_dir, '/'));
155155

156-
$parent_path = app(static::class);
157-
$parent_path->dir($parent_dir)->setName(null);
158-
159-
$directories = $parent_path->directories();
160-
161-
$that = $this;
162-
163-
$directories = array_map(function ($directory_path) use ($that) {
164-
return $this->translateToLfmPath($directory_path);
165-
}, $directories);
156+
$parent_directories = array_map(function ($directory_path) {
157+
return app(static::class)->translateToLfmPath($directory_path);
158+
}, app(static::class)->dir($parent_dir)->directories());
166159

167-
return in_array($this->path('url'), $directories);
160+
return in_array($this->path('url'), $parent_directories);
168161
}
169162

170163
/**

0 commit comments

Comments
 (0)
0