Skip to content

Commit

Permalink
save wip
Browse files Browse the repository at this point in the history
  • Loading branch information
asika32764 committed Mar 21, 2024
1 parent cf0e4c0 commit cd7ecec
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Module/Api/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Windwalker\DI\Attributes\Autowire;
use Windwalker\DI\Attributes\Service;
use Windwalker\Filesystem\FileObject;
use Windwalker\Filesystem\Path;
use Windwalker\Filesystem\TempFileObject;
use Windwalker\Http\Response\AttachmentResponse;
use Windwalker\ORM\ORM;
Expand Down Expand Up @@ -74,7 +75,7 @@ public function items(

public function logoSearch(AppContext $app): array
{
$q = (string) $app->input('q');
$q = (string) $app->input('q') ?: 'key';
$color = (string) $app->input('color') ?: '#ffffff';

$dir = fs(WINDWALKER_ROOT . '/node_modules/@fortawesome/fontawesome-free/svgs');
Expand All @@ -85,30 +86,34 @@ public function logoSearch(AppContext $app): array

if ($directFile->exists()) {
$image = $this->readImageIcon($directFile, $color, $app);
$icon = $directFile->getBasename('.svg');

return compact('image');
return compact('image', 'icon');
}

$directFile = $dir->appendPath('/brands/' . $searchText . '.svg');

if ($directFile->exists()) {
$image = $this->readImageIcon($directFile, $color, $app);
$icon = $directFile->getBasename('.svg');

return compact('image');
return compact('image', 'icon');
}

foreach ($dir->files(true) as $file) {
$basename = 'fa-' . $file->getFilename();

if (str_contains($basename, $searchText)) {
$image = $this->readImageIcon($file, $color, $app);
$icon = $file->getBasename('.svg');

return compact('image');
return compact('image', 'icon');
}
}

return [
'image' => ''
'image' => '',
'icon' => '',
];
}

Expand Down Expand Up @@ -164,6 +169,11 @@ public function save(
);
$image = (string) $result?->getUri();

if (!Path::isAbsolute($image)) {
$systemUri = $app->getSystemUri();
$image = $systemUri->addUriBase($image, $systemUri->root);
}

$account->setImage($image);

$account = $orm->createOne(Account::class, $account);
Expand Down

0 comments on commit cd7ecec

Please sign in to comment.