mirror of
https://github.com/Karaka-Management/oms-Comments.git
synced 2026-02-16 01:08:42 +00:00
phpstan and phpcs fixes
This commit is contained in:
parent
61636a9ee7
commit
dbef5427fa
|
|
@ -156,9 +156,19 @@ final class ApiController extends Controller
|
||||||
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Comment', 'Comment successfully created', $comment);
|
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Comment', 'Comment successfully created', $comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create media for comment
|
||||||
|
*
|
||||||
|
* @param Comment $comment Comment
|
||||||
|
* @param RequestAbstract $request Request data incl. files to upload
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function createCommentMedia(Comment $comment, RequestAbstract $request) : void
|
private function createCommentMedia(Comment $comment, RequestAbstract $request) : void
|
||||||
{
|
{
|
||||||
$path = $this->createCommentDir($comment);
|
$path = $this->createCommentDir($comment);
|
||||||
$account = AccountMapper::get()->where('id', $request->header->account)->execute();
|
$account = AccountMapper::get()->where('id', $request->header->account)->execute();
|
||||||
|
|
||||||
if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
|
if (!empty($uploadedFiles = $request->getFiles() ?? [])) {
|
||||||
|
|
@ -177,17 +187,18 @@ final class ApiController extends Controller
|
||||||
MediaMapper::create()->execute($media);
|
MediaMapper::create()->execute($media);
|
||||||
CommentMapper::writer()->createRelationTable('media', [$media->getId()], $comment->getId());
|
CommentMapper::writer()->createRelationTable('media', [$media->getId()], $comment->getId());
|
||||||
|
|
||||||
$ref = new Reference();
|
$accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login . '/Comments/' . $comment->createdAt->format('Y') . '/' . $comment->createdAt->format('m') . '/' . $comment->getId();
|
||||||
$ref->name = $media->name;
|
|
||||||
$ref->source = new NullMedia($media->getId());
|
$ref = new Reference();
|
||||||
|
$ref->name = $media->name;
|
||||||
|
$ref->source = new NullMedia($media->getId());
|
||||||
$ref->createdBy = new NullAccount($request->header->account);
|
$ref->createdBy = new NullAccount($request->header->account);
|
||||||
$ref->setVirtualPath($accountPath = '/Accounts/' . $account->getId() . ' ' . $account->login . '/Comments/' . $comment->createdAt->format('Y') . '/' . $comment->createdAt->format('m') . '/' . $comment->getId());
|
$ref->setVirtualPath($accountPath);
|
||||||
|
|
||||||
ReferenceMapper::create()->execute($ref);
|
ReferenceMapper::create()->execute($ref);
|
||||||
|
|
||||||
if ($collection === null) {
|
if ($collection === null) {
|
||||||
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
||||||
'/Modules/Media/Files',
|
|
||||||
$accountPath,
|
$accountPath,
|
||||||
$request->header->account,
|
$request->header->account,
|
||||||
__DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/Comments/' . $comment->createdAt->format('Y') . '/' . $comment->createdAt->format('m') . '/' . $comment->getId()
|
__DIR__ . '/../../../Modules/Media/Files/Accounts/' . $account->getId() . '/Comments/' . $comment->createdAt->format('Y') . '/' . $comment->createdAt->format('m') . '/' . $comment->getId()
|
||||||
|
|
@ -205,9 +216,9 @@ final class ApiController extends Controller
|
||||||
$media = MediaMapper::get()->where('id', (int) $file)->limit(1)->execute();
|
$media = MediaMapper::get()->where('id', (int) $file)->limit(1)->execute();
|
||||||
CommentMapper::writer()->createRelationTable('media', [$media->getId()], $comment->getId());
|
CommentMapper::writer()->createRelationTable('media', [$media->getId()], $comment->getId());
|
||||||
|
|
||||||
$ref = new Reference();
|
$ref = new Reference();
|
||||||
$ref->name = $media->name;
|
$ref->name = $media->name;
|
||||||
$ref->source = new NullMedia($media->getId());
|
$ref->source = new NullMedia($media->getId());
|
||||||
$ref->createdBy = new NullAccount($request->header->account);
|
$ref->createdBy = new NullAccount($request->header->account);
|
||||||
$ref->setVirtualPath($path);
|
$ref->setVirtualPath($path);
|
||||||
|
|
||||||
|
|
@ -215,7 +226,6 @@ final class ApiController extends Controller
|
||||||
|
|
||||||
if ($collection === null) {
|
if ($collection === null) {
|
||||||
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
$collection = $this->app->moduleManager->get('Media')->createRecursiveMediaCollection(
|
||||||
'/Modules/Media/Files',
|
|
||||||
$path,
|
$path,
|
||||||
$request->header->account,
|
$request->header->account,
|
||||||
__DIR__ . '/../../../Modules/Media/Files' . $path
|
__DIR__ . '/../../../Modules/Media/Files' . $path
|
||||||
|
|
@ -227,6 +237,15 @@ final class ApiController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create media directory path
|
||||||
|
*
|
||||||
|
* @param Comment $comment Comment
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
private function createCommentDir(Comment $comment) : string
|
private function createCommentDir(Comment $comment) : string
|
||||||
{
|
{
|
||||||
return '/Modules/Comments/'
|
return '/Modules/Comments/'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user