create default profile image

This commit is contained in:
Dennis Eichhorn 2021-08-06 19:29:00 +02:00
parent 1cb4b68999
commit 4c28981f1f
4 changed files with 83 additions and 1 deletions

View File

@ -0,0 +1,20 @@
[
{
"type": "collection",
"create_directory": true,
"name": "Profile",
"virtualPath": "/Modules",
"user": 1
},
{
"type": "upload",
"create_collection": false,
"name": "Default Profile Image",
"virtualPath": "/Modules/Profile",
"path": "/Modules/Media/Files/Modules/Profile",
"files": [
"/Modules/Profile/Admin/Install/Media/default_profile.png"
],
"user": 1
}
]

50
Admin/Install/Media.php Normal file
View File

@ -0,0 +1,50 @@
<?php
/**
* Orange Management
*
* PHP Version 8.0
*
* @package Modules\Profile\Admin\Install
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace Modules\Profile\Admin\Install;
use Model\Setting;
use Model\SettingMapper;
use phpOMS\Application\ApplicationAbstract;
/**
* Media class.
*
* @package Modules\Profile\Admin\Install
* @license OMS License 1.0
* @link https://orange-management.org
* @since 1.0.0
*/
class Media
{
/**
* Install media providing
*
* @param string $path Module path
* @param ApplicationAbstract $app Application
*
* @return void
*
* @since 1.0.0
*/
public static function install(string $path, ApplicationAbstract $app) : void
{
$media = \Modules\Media\Admin\Installer::installExternal($app, ['path' => __DIR__ . '/Media.install.json']);
$defaultProfileImage = \reset($media['upload'][0]);
$setting = new Setting();
SettingMapper::create($setting->with(0, 'default_profile_image', (string) $defaultProfileImage->getId(), 'Profile'));
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

View File

@ -39,7 +39,19 @@ final class Installer extends InstallerAbstract
{
parent::install($dbPool, $info, $cfgHandler);
$profile = new Profile(AccountMapper::get(1));
self::createProfiles();
}
/**
* Create profiles for already installed accounts
*
* @return void
*
* @since 1.0.0
*/
private static function createProfiles() : void
{
$profile = new Profile(AccountMapper::get(1));
ProfileMapper::create($profile);
}
}