-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ApplicationIconCompiler and IconResolver services (#224)
Introduced new services, `ApplicationIconCompiler` and `IconResolver`, for better structure. Updated related paths and dependencies. Modified existing services and tests for consistency and improved functionality with the new services.
- Loading branch information
Showing
21 changed files
with
358 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SpomkyLabs\PwaBundle\Service; | ||
|
||
use SpomkyLabs\PwaBundle\Dto\Manifest; | ||
use Symfony\Component\DependencyInjection\Attribute\Autowire; | ||
use function count; | ||
|
||
final readonly class ApplicationIconCompiler implements FileCompilerInterface | ||
{ | ||
public function __construct( | ||
private IconResolver $iconResolver, | ||
private Manifest $manifest, | ||
#[Autowire(param: 'kernel.debug')] | ||
public bool $debug, | ||
) { | ||
} | ||
|
||
/** | ||
* @return iterable<Data> | ||
*/ | ||
public function getFiles(): iterable | ||
{ | ||
$icons = []; | ||
if ($this->manifest->enabled === false) { | ||
yield from $icons; | ||
return; | ||
} | ||
if (count($this->manifest->icons) !== 0) { | ||
$icons = array_merge($icons, $this->manifest->icons); | ||
} | ||
if (count($this->manifest->shortcuts) !== 0) { | ||
foreach ($this->manifest->shortcuts as $shortcut) { | ||
$icons = array_merge($icons, $shortcut->icons); | ||
} | ||
} | ||
if (count($this->manifest->widgets) !== 0) { | ||
foreach ($this->manifest->widgets as $widget) { | ||
$icons = array_merge($icons, $widget->icons); | ||
} | ||
} | ||
|
||
foreach ($icons as $icon) { | ||
yield $this->iconResolver->getIcon($icon); | ||
} | ||
} | ||
} |
Oops, something went wrong.