CS: PSR1/2

parent a061e847
......@@ -3,8 +3,8 @@
namespace Modules\Core\Console\Installers\Scripts;
use Illuminate\Console\Command;
use Illuminate\Encryption\Encrypter;
use Illuminate\Console\ConfirmableTrait;
use Illuminate\Encryption\Encrypter;
use Modules\Core\Console\Installers\SetupScript;
class SetAppKey implements SetupScript
......@@ -40,7 +40,7 @@ class SetAppKey implements SetupScript
*/
protected function generateRandomKey()
{
return 'base64:'.base64_encode(
return 'base64:' . base64_encode(
Encrypter::generateKey(config('app.cipher'))
);
}
......@@ -74,7 +74,7 @@ class SetAppKey implements SetupScript
{
file_put_contents(app()->environmentFilePath(), preg_replace(
$this->keyReplacementPattern(),
'APP_KEY='.$key,
'APP_KEY=' . $key,
file_get_contents(app()->environmentFilePath())
));
}
......@@ -86,7 +86,7 @@ class SetAppKey implements SetupScript
*/
protected function keyReplacementPattern()
{
$escaped = preg_quote('='.config('app.key'), '/');
$escaped = preg_quote('=' . config('app.key'), '/');
return "/^APP_KEY{$escaped}/m";
}
......
......@@ -50,7 +50,7 @@ class MoveFileOnDisk
$fromPath = $this->getFilenameFor($event->previousData['path'], $thumbnail);
$toPath = $this->getFilenameFor($event->file->path, $thumbnail);
$this->move($fromPath, $toPath);
$this->move($fromPath, $toPath);
}
}
......
......@@ -3,7 +3,6 @@
namespace Modules\Media\Http\Controllers\Frontend;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Facades\Image;
use Modules\Media\Repositories\FileRepository;
......@@ -29,7 +28,7 @@ class MediaController extends Controller
return Image::make($path)->response();
return response()->file($path, [
"Content-Type:$type"
"Content-Type:$type",
]);
}
}
......@@ -27,7 +27,7 @@ class UploadDropzoneMediaRequest extends FormRequest
$size = $this->getMaxFileSize();
return [
'file.max' => trans('media::media.file too large', ['size' => $size])
'file.max' => trans('media::media.file too large', ['size' => $size]),
];
}
......
......@@ -27,7 +27,7 @@ class UploadMediaRequest extends FormRequest
$size = $this->getMaxFileSize();
return [
'file.max' => trans('media::media.file too large', ['size' => $size])
'file.max' => trans('media::media.file too large', ['size' => $size]),
];
}
......
......@@ -14,13 +14,13 @@ use Modules\Media\Console\RefreshThumbnailCommand;
use Modules\Media\Contracts\DeletingMedia;
use Modules\Media\Contracts\StoringMedia;
use Modules\Media\Entities\File;
use Modules\Media\Events\FileStartedMoving;
use Modules\Media\Events\FolderIsDeleting;
use Modules\Media\Events\FolderWasCreated;
use Modules\Media\Events\FolderWasUpdated;
use Modules\Media\Events\Handlers\CreateFolderOnDisk;
use Modules\Media\Events\Handlers\DeleteAllChildrenOfFolder;
use Modules\Media\Events\Handlers\DeleteFolderOnDisk;
use Modules\Media\Events\FileStartedMoving;
use Modules\Media\Events\Handlers\HandleMediaStorage;
use Modules\Media\Events\Handlers\MoveFileOnDisk;
use Modules\Media\Events\Handlers\RegisterMediaSidebar;
......
......@@ -26,7 +26,7 @@ class NestedFoldersCollection extends Collection
public function nest()
{
$parentColumn = $this->parentColumn;
if ( ! $parentColumn) {
if (! $parentColumn) {
return $this;
}
// Set id as keys.
......@@ -34,7 +34,7 @@ class NestedFoldersCollection extends Collection
$keysToDelete = [];
// Add empty collection to each items.
$collection = $this->each(function ($item) {
if ( ! $item->items) {
if (! $item->items) {
$item->items = app(BaseCollection::class);
}
});
......@@ -43,6 +43,7 @@ class NestedFoldersCollection extends Collection
$collection = $this->reject(function ($item) use ($parentColumn) {
if ($item->$parentColumn) {
$missingAncestor = $this->anAncestorIsMissing($item);
return $missingAncestor;
}
});
......@@ -56,6 +57,7 @@ class NestedFoldersCollection extends Collection
}
// Delete moved items.
$this->items = array_values(array_except($collection->items, $keysToDelete));
return $this;
}
......@@ -71,7 +73,11 @@ class NestedFoldersCollection extends Collection
* @return array
*/
public function listsFlattened(
$column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null,
$column = 'title',
BaseCollection $collection = null,
$level = 0,
array &$flattened = [],
$indentChars = null,
$parent_string = null
) {
$collection = $collection ?: $this;
......@@ -84,10 +90,17 @@ class NestedFoldersCollection extends Collection
}
$flattened[$item->id] = $item_string;
if ($item->items) {
$this->listsFlattened($column, $item->items, $level + 1, $flattened, $indentChars,
($parent_string) ? $item_string : null);
$this->listsFlattened(
$column,
$item->items,
$level + 1,
$flattened,
$indentChars,
($parent_string) ? $item_string : null
);
}
}
return $flattened;
}
......@@ -101,7 +114,11 @@ class NestedFoldersCollection extends Collection
* @return array
*/
public function listsFlattenedQualified(
$column = 'title', BaseCollection $collection = null, $level = 0, array &$flattened = [], $indentChars = null
$column = 'title',
BaseCollection $collection = null,
$level = 0,
array &$flattened = [],
$indentChars = null
) {
return $this->listsFlattened($column, $collection, $level, $flattened, $indentChars, true);
}
......@@ -114,6 +131,7 @@ class NestedFoldersCollection extends Collection
public function setIndent(string $indentChars)
{
$this->indentChars = $indentChars;
return $this;
}
......@@ -124,6 +142,7 @@ class NestedFoldersCollection extends Collection
public function noCleaning()
{
$this->removeItemsWithMissingAncestor = false;
return $this;
}
......@@ -135,13 +154,14 @@ class NestedFoldersCollection extends Collection
public function anAncestorIsMissing($item)
{
$parentColumn = $this->parentColumn;
if ( ! $item->$parentColumn) {
if (! $item->$parentColumn) {
return false;
}
if ( ! $this->has($item->$parentColumn)) {
if (! $this->has($item->$parentColumn)) {
return true;
}
$parent = $this[$item->$parentColumn];
return $this->anAncestorIsMissing($parent);
}
......
......@@ -38,5 +38,5 @@ return [
'create resource' => 'Create media',
'edit resource' => 'Edit media',
'destroy resource' => 'Delete media',
'file too large' => 'File is too large. Must be below :size MB.'
'file too large' => 'File is too large. Must be below :size MB.',
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment