You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xshop/app/Console/Commands/clientAssetGenerator.php

62 lines
1.8 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class clientAssetGenerator extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'client';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Execute the console command.
*/
public function handle()
{
// make gfx variable
$gfxes = gfx();
$vars['xshop-background'] = $gfxes['background'] ?? '#000000';
$vars['xshop-primary'] = $gfxes['primary'] ?? '#6e0000';
$vars['xshop-secondary'] = $gfxes['secondary'] ?? '#ff0000';
$vars['xshop-text'] = $gfxes['text'] ?? '#111111';
$vars['border-radius'] = $gfxes['border-radius'] ?? '7px';
$vars['xshop-shadow'] = $gfxes['shadow'] ?? '2px 2px 4px #777777';
// prepare client.scss and add gfx variable
$variables = "// PLEASE DO NOT EDIT THIS FILE, \n// IF YOU WANT ADD ANY CODE CREATE NEW SCSS INTO client-custom" . PHP_EOL;
$variables .= ":root{" . PHP_EOL;
foreach ($vars as $k => $var) {
$variables .= "--$k:$var;" . PHP_EOL;
}
$variables .= "}" . PHP_EOL . PHP_EOL;
// add custom scss
$files = File::allFiles(resource_path() . '/sass/client-custom');
foreach ($files as $file) {
if ($file->getType() == 'file' && $file->getExtension() == 'scss'){
$variables .= '@import "client-custom/'.
substr(trim($file->getBasename(),'_'),0,-5)
.'";'.PHP_EOL;
}
}
// save scss
file_put_contents(resource_path() . '/sass/client.scss', $variables);
}
}