package installer
This commit is contained in:
79
app/Helpers/Installer/FinalInstallManager.php
Normal file
79
app/Helpers/Installer/FinalInstallManager.php
Normal file
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\Installer;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
|
||||
class FinalInstallManager
|
||||
{
|
||||
/**
|
||||
* Run final commands.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function runFinal()
|
||||
{
|
||||
$outputLog = new BufferedOutput;
|
||||
|
||||
$this->generateKey($outputLog);
|
||||
$this->publishVendorAssets($outputLog);
|
||||
|
||||
return $outputLog->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate New Application Key.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Output\BufferedOutput $outputLog
|
||||
* @return \Symfony\Component\Console\Output\BufferedOutput|array
|
||||
*/
|
||||
private static function generateKey(BufferedOutput $outputLog)
|
||||
{
|
||||
try {
|
||||
if (config('installer.final.key')) {
|
||||
Artisan::call('key:generate', ['--force'=> true], $outputLog);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return static::response($e->getMessage(), $outputLog);
|
||||
}
|
||||
|
||||
return $outputLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish vendor assets.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Output\BufferedOutput $outputLog
|
||||
* @return \Symfony\Component\Console\Output\BufferedOutput|array
|
||||
*/
|
||||
private static function publishVendorAssets(BufferedOutput $outputLog)
|
||||
{
|
||||
try {
|
||||
if (config('installer.final.publish')) {
|
||||
Artisan::call('vendor:publish', ['--all' => true], $outputLog);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return static::response($e->getMessage(), $outputLog);
|
||||
}
|
||||
|
||||
return $outputLog;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a formatted error messages.
|
||||
*
|
||||
* @param $message
|
||||
* @param \Symfony\Component\Console\Output\BufferedOutput $outputLog
|
||||
* @return array
|
||||
*/
|
||||
private static function response($message, BufferedOutput $outputLog)
|
||||
{
|
||||
return [
|
||||
'status' => 'error',
|
||||
'message' => $message,
|
||||
'dbOutputLog' => $outputLog->fetch(),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user