Files
michaelschiemer/src/Framework/Database/Criteria/Projection/ProjectionList.php
Michael Schiemer 55a330b223 Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug
- Add DISCOVERY_SHOW_PROGRESS=true
- Temporary changes for debugging InitializerProcessor fixes on production
2025-08-11 20:13:26 +02:00

48 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\Database\Criteria\Projection;
use App\Framework\Database\Criteria\Projection;
/**
* List of multiple projections
*/
final readonly class ProjectionList implements Projection
{
/** @var Projection[] */
public array $projections;
public function __construct(Projection ...$projections)
{
$this->projections = $projections;
}
public function add(Projection $projection): self
{
$newProjections = [...$this->projections, $projection];
return new self(...$newProjections);
}
public function toSql(): string
{
if (empty($this->projections)) {
return '*';
}
return implode(', ', array_map(fn ($p) => $p->toSql(), $this->projections));
}
public function getAliases(): array
{
$aliases = [];
foreach ($this->projections as $projection) {
$aliases = array_merge($aliases, $projection->getAliases());
}
return $aliases;
}
}