mirror of
https://github.com/flarum/core.git
synced 2025-10-21 11:46:05 +02:00
Add simple implementation (command handler) for avatar upload.
This commit is contained in:
30
src/Core/Commands/UploadAvatarCommand.php
Normal file
30
src/Core/Commands/UploadAvatarCommand.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php namespace Flarum\Core\Commands;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class UploadAvatarCommand
|
||||
{
|
||||
public $userId;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpFoundation\File\UploadedFile
|
||||
*/
|
||||
public $file;
|
||||
|
||||
public $actor;
|
||||
|
||||
public function __construct($userId, $file, $actor)
|
||||
{
|
||||
if (empty($userId) || !intval($userId)) {
|
||||
throw new RuntimeException('No valid user ID specified.');
|
||||
}
|
||||
|
||||
if (is_null($file)) {
|
||||
throw new RuntimeException('No file to upload');
|
||||
}
|
||||
|
||||
$this->userId = $userId;
|
||||
$this->file = $file;
|
||||
$this->actor = $actor;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user