diff --git a/Admin/Install/Media.install.json b/Admin/Install/Media.install.json new file mode 100644 index 0000000..124191e --- /dev/null +++ b/Admin/Install/Media.install.json @@ -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 + } +] \ No newline at end of file diff --git a/Admin/Install/Media.php b/Admin/Install/Media.php new file mode 100644 index 0000000..3791694 --- /dev/null +++ b/Admin/Install/Media.php @@ -0,0 +1,50 @@ + __DIR__ . '/Media.install.json']); + + $defaultProfileImage = \reset($media['upload'][0]); + + $setting = new Setting(); + SettingMapper::create($setting->with(0, 'default_profile_image', (string) $defaultProfileImage->getId(), 'Profile')); + } +} diff --git a/Admin/Install/Media/default_profile.png b/Admin/Install/Media/default_profile.png new file mode 100644 index 0000000..77eb6f4 Binary files /dev/null and b/Admin/Install/Media/default_profile.png differ diff --git a/Admin/Installer.php b/Admin/Installer.php index 841fffe..0da7612 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -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); } }