mirror of
https://github.com/Karaka-Management/oms-Media.git
synced 2026-02-18 02:08:40 +00:00
fix phpstan/phpcs
This commit is contained in:
parent
5e016b028f
commit
ba52dcaa8b
|
|
@ -42,7 +42,7 @@ final class Installer extends InstallerAbstract
|
|||
* Install data from providing modules.
|
||||
*
|
||||
* @param ApplicationAbstract $app Application
|
||||
* @param array $data Module info
|
||||
* @param array $data Additional data
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
|
|
@ -116,7 +116,7 @@ final class Installer extends InstallerAbstract
|
|||
$path = '/Modules/Media/Files' . ($data['virtualPath'] ?? '') . '/' . ($data['name'] ?? '');
|
||||
} else {
|
||||
$dirPath = $data['path'] . '/' . ($data['name'] ?? '');
|
||||
$path = $data['path'] ?? '/Modules/Media/Files' . '/' . ($data['name'] ?? '');
|
||||
$path = $data['path'] ?? '/Modules/Media/Files/' . ($data['name'] ?? '');
|
||||
}
|
||||
|
||||
$collection = new Collection();
|
||||
|
|
@ -193,7 +193,7 @@ final class Installer extends InstallerAbstract
|
|||
$media = new Media();
|
||||
|
||||
$media->setPath(ApiController::normalizeDbPath($data['path']) . '/' . $uFile['filename']);
|
||||
$media->name = $uFile['name'];
|
||||
$media->name = $uFile['filename'];
|
||||
$media->size = $uFile['size'];
|
||||
$media->createdBy = new NullAccount((int) $data['user'] ?? 1);
|
||||
$media->extension = $uFile['extension'];
|
||||
|
|
|
|||
|
|
@ -172,6 +172,17 @@ final class ApiController extends Controller
|
|||
return $this->createDbEntries($status, $account, $virtualPath, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a file to a destination
|
||||
*
|
||||
* @param array $files Files to upload
|
||||
* @param string $name Name of the file (only if a single file is provided)
|
||||
* @param string $path Upload path
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static function uploadFilesToDestination(
|
||||
array $files,
|
||||
string $name = '',
|
||||
|
|
@ -266,7 +277,7 @@ final class ApiController extends Controller
|
|||
$media = new Media();
|
||||
|
||||
$media->setPath(self::normalizeDbPath($status['path']) . '/' . $status['filename']);
|
||||
$media->name = $status['name'];
|
||||
$media->name = empty($status['name']) ? $status['filename'] : $status['name'];
|
||||
$media->size = $status['size'];
|
||||
$media->createdBy = new NullAccount($account);
|
||||
$media->extension = $status['extension'];
|
||||
|
|
|
|||
|
|
@ -88,6 +88,15 @@ class Collection extends Media implements \Iterator
|
|||
return $this->sources;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get media element by its name.
|
||||
*
|
||||
* @param string $name Name of the media element
|
||||
*
|
||||
* @return Media
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getSourceByName(string $name) : Media
|
||||
{
|
||||
foreach ($this->sources as $source) {
|
||||
|
|
|
|||
|
|
@ -100,11 +100,11 @@ final class CollectionMapper extends MediaMapper
|
|||
{
|
||||
$depth = 3;
|
||||
$query = self::getQuery();
|
||||
$query->where(self::$table . '_' . $depth . '.media_virtual', '=', $virtualPath);
|
||||
$query->where(self::$table . '_' . $depth . '.media_collection', '=', 1);
|
||||
$query->where(self::$table . '_d' . $depth . '.media_virtual', '=', $virtualPath);
|
||||
$query->where(self::$table . '_d' . $depth . '.media_collection', '=', 1);
|
||||
|
||||
if ($hidden === false) {
|
||||
$query->andWhere(self::$table . '_' . $depth . '.media_hidden', '=', (int) $hidden);
|
||||
$query->andWhere(self::$table . '_d' . $depth . '.media_hidden', '=', (int) $hidden);
|
||||
}
|
||||
|
||||
return self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
|
|
|
|||
|
|
@ -141,10 +141,10 @@ class MediaMapper extends DataMapperAbstract
|
|||
{
|
||||
$depth = 3;
|
||||
$query = self::getQuery();
|
||||
$query->where(self::$table . '_' . $depth . '.media_virtual', '=', $virtualPath);
|
||||
$query->where(self::$table . '_d' . $depth . '.media_virtual', '=', $virtualPath);
|
||||
|
||||
if ($hidden === false) {
|
||||
$query->andWhere(self::$table . '_' . $depth . '.media_hidden', '=', (int) $hidden);
|
||||
$query->andWhere(self::$table . '_d' . $depth . '.media_hidden', '=', (int) $hidden);
|
||||
}
|
||||
|
||||
return self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
|
|
@ -166,8 +166,8 @@ class MediaMapper extends DataMapperAbstract
|
|||
|
||||
$depth = 3;
|
||||
$query = self::getQuery();
|
||||
$query->where(self::$table. '_' . $depth . '.media_virtual', '=', $virtualPath)
|
||||
->andWhere(self::$table. '_' . $depth . '.media_name', '=', $name);
|
||||
$query->where(self::$table. '_d' . $depth . '.media_virtual', '=', $virtualPath)
|
||||
->andWhere(self::$table. '_d' . $depth . '.media_name', '=', $name);
|
||||
|
||||
$objs = self::getAllByQuery($query, RelationType::ALL, $depth);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ class UploadFile
|
|||
$files = [$files];
|
||||
}
|
||||
|
||||
$fileCount = \count($files);
|
||||
|
||||
if (!$absolute && \count($files) > 1) {
|
||||
$this->outputDir = $this->findOutputDir();
|
||||
}
|
||||
|
|
@ -158,7 +160,7 @@ class UploadFile
|
|||
$result[$key]['filename'] = $name;
|
||||
}
|
||||
|
||||
if (empty($name) || \is_file($path . '/' . $name)) {
|
||||
if (!$this->preserveFileName || $fileCount !== 1 || empty($name) || \is_file($path . '/' . $name)) {
|
||||
try {
|
||||
$name = $this->createFileName($path, $f['tmp_name'], $extension);
|
||||
$result[$key]['filename'] = $name;
|
||||
|
|
@ -170,6 +172,8 @@ class UploadFile
|
|||
}
|
||||
}
|
||||
|
||||
$result[$key]['name'] = empty($name) ? $result[$key]['filename'] : $name;
|
||||
|
||||
if (!\is_dir($path)) {
|
||||
$created = Directory::create($path, 0755, true);
|
||||
|
||||
|
|
|
|||
|
|
@ -39,14 +39,6 @@ class ElementView extends MediaView
|
|||
*/
|
||||
protected Media $media;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(L11nManager $l11n = null, RequestAbstract $request, ResponseAbstract $response)
|
||||
{
|
||||
parent::__construct($l11n, $request, $response);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
],
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": ">=9.4",
|
||||
"friendsofphp/php-cs-fixer": ">=2.18",
|
||||
"friendsofphp/php-cs-fixer": ">=3.0",
|
||||
"squizlabs/php_codesniffer": ">=3.5",
|
||||
"phpmd/phpmd": ">=2.9",
|
||||
"phpstan/phpstan": ">=0.12.58",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user