mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-13 05:39:33 +00:00
30 lines
No EOL
641 B
PHP
30 lines
No EOL
641 B
PHP
<?php
|
|
|
|
namespace App\Twig;
|
|
|
|
use App\Entity\AssemblySystem\AssemblyBOMEntry;
|
|
use Twig\Extension\AbstractExtension;
|
|
use Twig\TwigFunction;
|
|
|
|
class AssemblyTwigExtension extends AbstractExtension
|
|
{
|
|
public function getFunctions(): array
|
|
{
|
|
return [
|
|
new TwigFunction('has_project', [$this, 'hasProject']),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param AssemblyBOMEntry[] $bomEntries
|
|
*/
|
|
public function hasProject(array $bomEntries): bool
|
|
{
|
|
foreach ($bomEntries as $entry) {
|
|
if ($entry->getProject() !== null) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
} |