1111use Doctrine \ORM \EntityManagerInterface ;
1212use Doctrine \ORM \Exception \ORMException ;
1313use Doctrine \ORM \Mapping \ClassMetadata ;
14- use Doctrine \ORM \Tools \SchemaTool ;
14+ use Doctrine \ORM \Tools \SchemaTool as DoctrineSchemaTool ;
1515use DOMDocument ;
16- use Fabiang \Doctrine \Migrations \Liquibase \Output \LiquibaseDOMDocumentOutput ;
17- use Fabiang \Doctrine \Migrations \Liquibase \Output \LiquibaseOutputInterface ;
18- use Fabiang \Doctrine \Migrations \Liquibase \Output \LiquibaseOutputOptions ;
16+ use Fabiang \Doctrine \Migrations \Liquibase \Output \DOMDocumentOutput ;
17+ use Fabiang \Doctrine \Migrations \Liquibase \Output \OutputInterface ;
1918
20- use function array_merge ;
2119use function strcmp ;
2220use function usort ;
2321
2422/**
2523 * @psalm-suppress UnusedClass
2624 */
27- class LiquibaseSchemaTool extends SchemaTool
25+ class SchemaTool extends DoctrineSchemaTool
2826{
29- private const array LIQUIBASE_TABLES = [ ' liquibase ' , ' liquibase_lock ' ] ;
27+ private Options $ options ;
3028
31- /**
32- * @param string[] $ignoreTables
33- */
34- public function __construct (private EntityManagerInterface $ em , private array $ ignoreTables = [])
35- {
29+ public function __construct (
30+ private EntityManagerInterface $ em ,
31+ ?Options $ options = null
32+ ) {
3633 parent ::__construct ($ em );
34+
35+ if ($ options === null ) {
36+ $ options = new Options ();
37+ }
38+
39+ $ this ->options = $ options ;
3740 }
3841
3942 /**
@@ -42,7 +45,7 @@ public function __construct(private EntityManagerInterface $em, private array $i
4245 * @throws ORMException
4346 */
4447 public function diffChangeLog (
45- LiquibaseOutputInterface | LiquibaseOutputOptions | null $ output = null ,
48+ ? OutputInterface $ output = null ,
4649 ?array $ metadata = null
4750 ): DOMDocument {
4851 $ soutput = $ this ->sanitizeOutputParameter ($ output );
@@ -70,7 +73,7 @@ public function diffChangeLog(
7073 * @throws ORMException
7174 */
7275 public function changeLog (
73- LiquibaseOutputInterface | LiquibaseOutputOptions | null $ output = null ,
76+ ? OutputInterface $ output = null ,
7477 ?array $ metadata = null
7578 ): DOMDocument {
7679 $ soutput = $ this ->sanitizeOutputParameter ($ output );
@@ -93,7 +96,7 @@ public function changeLog(
9396 */
9497 public function diffChangeLogFromSchemaDiff (
9598 SchemaDiff $ schemaDiff ,
96- LiquibaseOutputInterface | LiquibaseOutputOptions | null $ output = null
99+ ? OutputInterface $ output = null
97100 ): DOMDocument {
98101 $ soutput = $ this ->sanitizeOutputParameter ($ output );
99102
@@ -148,7 +151,7 @@ public function diffChangeLogFromSchemaDiff(
148151
149152 private function removeLiquibaseTables (Schema $ fromSchema ): void
150153 {
151- $ tables = array_merge ( self :: LIQUIBASE_TABLES , $ this ->ignoreTables );
154+ $ tables = $ this ->options -> getIgnoreTables ( );
152155
153156 foreach ($ tables as $ table ) {
154157 if ($ fromSchema ->hasTable ($ table )) {
@@ -157,16 +160,13 @@ private function removeLiquibaseTables(Schema $fromSchema): void
157160 }
158161 }
159162
160- private function sanitizeOutputParameter (
161- LiquibaseOutputInterface |LiquibaseOutputOptions |null $ output = null
162- ): LiquibaseOutputInterface {
163- if ($ output instanceof LiquibaseOutputOptions) {
164- return new LiquibaseDOMDocumentOutput ($ output );
165- } elseif ($ output instanceof LiquibaseOutputInterface) {
163+ private function sanitizeOutputParameter (?OutputInterface $ output = null ): OutputInterface
164+ {
165+ if ($ output instanceof OutputInterface) {
166166 return $ output ;
167167 }
168168
169- return new LiquibaseDOMDocumentOutput ( );
169+ return new DOMDocumentOutput ( $ this -> options );
170170 }
171171
172172 /**
0 commit comments