Aggregate.php
2 days ago
BaseFactory.php
2 days ago
CommentFactory.php
2 days ago
IntegrationFactory.php
2 days ago
MediaFactory.php
2 days ago
OriginalFactory.php
2 days ago
PostFactory.php
2 days ago
ThirdPartyFactory.php
2 days ago
UserFactory.php
2 days ago
Aggregate.php
49 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\ColumnFactories; |
| 6 | |
| 7 | use AC\Collection\ColumnFactories; |
| 8 | use AC\ColumnFactoryCollectionFactory; |
| 9 | use AC\TableScreen; |
| 10 | |
| 11 | class Aggregate |
| 12 | { |
| 13 | /** |
| 14 | * @var ColumnFactoryCollectionFactory[] |
| 15 | */ |
| 16 | private static array $factories = []; |
| 17 | |
| 18 | public static function add(ColumnFactoryCollectionFactory $factory): void |
| 19 | { |
| 20 | self::$factories[] = $factory; |
| 21 | } |
| 22 | |
| 23 | public function create(TableScreen $table_screen): ColumnFactories |
| 24 | { |
| 25 | static $factories; |
| 26 | |
| 27 | $id = (string)$table_screen->get_id(); |
| 28 | |
| 29 | if (! isset($factories[$id])) { |
| 30 | $factories[$id] = $this->get($table_screen); |
| 31 | } |
| 32 | |
| 33 | return $factories[$id]; |
| 34 | } |
| 35 | |
| 36 | private function get(TableScreen $table_screen): ColumnFactories |
| 37 | { |
| 38 | $collection = new ColumnFactories(); |
| 39 | |
| 40 | foreach (self::$factories as $collection_factory) { |
| 41 | foreach ($collection_factory->create($table_screen) as $factory) { |
| 42 | $collection->add($factory); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | return $collection; |
| 47 | } |
| 48 | } |
| 49 |