Skip to content
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

Refactor Files module #1636

Merged
merged 1 commit into from
Dec 31, 2018
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
10 changes: 0 additions & 10 deletions system/Files/Exceptions/FileException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,4 @@ public static function forUnableToMove(string $from = null, string $to = null, s
return new static(lang('Files.cannotMove', [$from, $to, $error]));
}

public static function forInvalidFilename(string $to = null)
{
return new self(lang('Files.invalidFilename', [$to]));
}

public static function forCopyError(string $to = null)
{
return new self(lang('Files.cannotCopy', [$to]));
}

}
17 changes: 5 additions & 12 deletions system/Files/File.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php namespace CodeIgniter\Files;
<?php
namespace CodeIgniter\Files;

/**
* CodeIgniter
Expand Down Expand Up @@ -127,17 +128,9 @@ public function guessExtension(): ?string
*/
public function getMimeType(): string
{
if (function_exists('finfo_file'))
{
$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $this->getRealPath());
finfo_close($finfo);
}
else
{
$mimeType = mime_content_type($this->getRealPath());
}

$finfo = finfo_open(FILEINFO_MIME_TYPE);
$mimeType = finfo_file($finfo, $this->getRealPath());
finfo_close($finfo);
return $mimeType;
}

Expand Down
6 changes: 2 additions & 4 deletions system/Language/en/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
*/

return [
'fileNotFound' => 'File not found: {0}',
'cannotMove' => 'Could not move file {0} to {1} ({2})',
'invalidFilename' => 'Target filename missing or invalid: {0}',
'cannotCopy' => 'Could not copy to {0} - make sure the folder is writeable',
'fileNotFound' => 'File not found: {0}',
'cannotMove' => 'Could not move file {0} to {1} ({2})',
];