mirror of
https://github.com/Karaka-Management/oms-Profile.git
synced 2026-01-27 14:38:41 +00:00
create default profile image
This commit is contained in:
parent
1cb4b68999
commit
4c28981f1f
20
Admin/Install/Media.install.json
Normal file
20
Admin/Install/Media.install.json
Normal 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
50
Admin/Install/Media.php
Normal 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'));
|
||||
}
|
||||
}
|
||||
BIN
Admin/Install/Media/default_profile.png
Normal file
BIN
Admin/Install/Media/default_profile.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user