Files
kupshop/bundles/KupShop/ComponentsBundle/Utils/ComponentsLocator.php
2025-08-02 16:30:27 +02:00

52 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\ComponentsBundle\Utils;
class ComponentsLocator
{
public function __construct(
protected array $components,
protected array $unusedComponents,
) {
}
public function getComponents(): array
{
return $this->components;
}
public function getComponent(string $class): ?array
{
return $this->components[$class] ?? null;
}
public function findComponentByName($name): ?array
{
foreach ($this->components as $component) {
if ($component['name'] === $name) {
return $component;
}
}
return null;
}
public function getUnusedComponents(): array
{
return $this->unusedComponents;
}
public function findUnusedComponentByName($name): ?array
{
foreach ($this->unusedComponents as $component) {
if ($component['name'] === $name) {
return $component;
}
}
return null;
}
}