-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSchemaConfig.php
53 lines (46 loc) · 2.33 KB
/
SchemaConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
namespace Wakebit\CycleBridge\Schema\Config;
use Cycle\Schema\GeneratorInterface;
use Spiral\Core\InjectableConfig;
use Wakebit\CycleBridge\Contracts\Schema\GeneratorQueueInterface;
final class SchemaConfig extends InjectableConfig
{
public function getCacheStore(): mixed
{
return $this->config['cache']['store'] ?? 'file';
}
public function getManuallyDefinedSchema(): mixed
{
return $this->config['map'] ?? null;
}
/**
* @return array<array<GeneratorInterface|class-string<GeneratorInterface>>>
*/
public function getGenerators(): array
{
$defaultGeneratorQueue = [
GeneratorQueueInterface::GROUP_INDEX => [
\Cycle\Annotated\Embeddings::class, // register embeddable entities
\Cycle\Annotated\Entities::class, // register annotated entities
\Cycle\Annotated\TableInheritance::class, // register STI/JTI
\Cycle\Annotated\MergeColumns::class, // add @Table column declarations
],
GeneratorQueueInterface::GROUP_RENDER => [
\Cycle\Schema\Generator\ResetTables::class, // re-declared table schemas (remove columns)
\Cycle\Schema\Generator\GenerateRelations::class, // generate entity relations
\Cycle\Schema\Generator\GenerateModifiers::class, // generate changes from schema modifiers
\Cycle\Schema\Generator\ValidateEntities::class, // make sure all entity schemas are correct
\Cycle\Schema\Generator\RenderTables::class, // declare table schemas
\Cycle\Schema\Generator\RenderRelations::class, // declare relation keys and indexes
\Cycle\Schema\Generator\RenderModifiers::class, // render all schema modifiers
\Cycle\Annotated\MergeIndexes::class, // add @Table column declarations
],
GeneratorQueueInterface::GROUP_POSTPROCESS => [
\Cycle\Schema\Generator\GenerateTypecast::class, // typecast non string columns
],
];
/** @var array<array<GeneratorInterface|class-string<GeneratorInterface>>> */
return $this->config['generators'] ?? $defaultGeneratorQueue;
}
}