@@ -579,6 +579,10 @@ public function generate($target)
579
579
'methods ' => $ methods ,
580
580
];
581
581
582
+ if ($ this ->exclude ($ file , $ params )) {
583
+ continue ;
584
+ }
585
+
582
586
$ this ->render ($ template , $ destination , $ block , $ params , $ minify );
583
587
}
584
588
break ;
@@ -587,6 +591,10 @@ public function generate($target)
587
591
588
592
$ params ['definition ' ] = $ definition ;
589
593
594
+ if ($ this ->exclude ($ file , $ params )) {
595
+ continue ;
596
+ }
597
+
590
598
$ this ->render ($ template , $ destination , $ block , $ params , $ minify );
591
599
}
592
600
break ;
@@ -606,6 +614,11 @@ public function generate($target)
606
614
607
615
foreach ($ methods as $ method ) {
608
616
$ params ['method ' ] = $ method ;
617
+
618
+ if ($ this ->exclude ($ file , $ params )) {
619
+ continue ;
620
+ }
621
+
609
622
$ this ->render ($ template , $ destination , $ block , $ params , $ minify );
610
623
}
611
624
}
@@ -614,6 +627,76 @@ public function generate($target)
614
627
}
615
628
}
616
629
630
+ /**
631
+ * Determine if a file should be excluded from generation.
632
+ *
633
+ * Allows for files to be excluded based on:
634
+ * - Service name or feature
635
+ * - Method name or type
636
+ * - Definition name
637
+ *
638
+ * @param $file
639
+ * @param $params
640
+ * @return bool
641
+ */
642
+ protected function exclude ($ file , $ params ): bool
643
+ {
644
+ $ exclude = $ file ['exclude ' ] ?? [];
645
+
646
+ $ services = [];
647
+ $ features = [];
648
+ foreach ($ exclude ['services ' ] ?? [] as $ service ) {
649
+ if (isset ($ service ['name ' ])) {
650
+ $ services [] = $ service ['name ' ];
651
+ }
652
+ if (isset ($ service ['feature ' ])) {
653
+ $ features [] = $ service ['feature ' ];
654
+ }
655
+ }
656
+
657
+ $ methods = [];
658
+ $ types = [];
659
+ foreach ($ exclude ['methods ' ] ?? [] as $ method ) {
660
+ if (isset ($ method ['name ' ])) {
661
+ $ methods [] = $ method ['name ' ];
662
+ }
663
+ if (isset ($ method ['type ' ])) {
664
+ $ types [] = $ method ['type ' ];
665
+ }
666
+ }
667
+
668
+ $ definitions = [];
669
+ foreach ($ exclude ['definitions ' ] ?? [] as $ definition ) {
670
+ if (isset ($ definition ['name ' ])) {
671
+ $ definitions [] = $ definition ['name ' ];
672
+ }
673
+ }
674
+
675
+ if (\in_array ($ params ['service ' ]['name ' ] ?? '' , $ services )) {
676
+ return true ;
677
+ }
678
+
679
+ foreach ($ features as $ feature ) {
680
+ if ($ params ['service ' ]['features ' ][$ feature ] ?? false ) {
681
+ return true ;
682
+ }
683
+ }
684
+
685
+ if (\in_array ($ params ['method ' ]['name ' ] ?? '' , $ methods )) {
686
+ return true ;
687
+ }
688
+
689
+ if (\in_array ($ params ['method ' ]['type ' ] ?? '' , $ types )) {
690
+ return true ;
691
+ }
692
+
693
+ if (\in_array ($ params ['definition ' ]['name ' ] ?? '' , $ definitions )) {
694
+ return true ;
695
+ }
696
+
697
+ return false ;
698
+ }
699
+
617
700
/**
618
701
* @return bool
619
702
*/
0 commit comments