@@ -537,6 +537,58 @@ public function getParams(): array
537
537
return $ this ->params ;
538
538
}
539
539
540
+ /**
541
+ * Get services filtered by exclusion rules
542
+ *
543
+ * @return array
544
+ */
545
+ protected function getFilteredServices (): array
546
+ {
547
+ $ allServices = $ this ->spec ->getServices ();
548
+ $ filteredServices = [];
549
+
550
+ // Extract exclusion rules for services
551
+ $ excludeServices = [];
552
+ $ excludeFeatures = [];
553
+ foreach ($ this ->excludeRules ['services ' ] ?? [] as $ service ) {
554
+ if (isset ($ service ['name ' ])) {
555
+ $ excludeServices [] = $ service ['name ' ];
556
+ }
557
+ if (isset ($ service ['feature ' ])) {
558
+ $ excludeFeatures [] = $ service ['feature ' ];
559
+ }
560
+ }
561
+
562
+ foreach ($ allServices as $ serviceName => $ service ) {
563
+ // Check if service is excluded by name
564
+ if (in_array ($ serviceName , $ excludeServices )) {
565
+ continue ;
566
+ }
567
+
568
+ // Check if service is excluded by feature
569
+ $ methods = $ this ->spec ->getMethods ($ serviceName );
570
+ $ serviceFeatures = [
571
+ 'upload ' => $ this ->hasUploads ($ methods ),
572
+ 'location ' => $ this ->hasLocation ($ methods ),
573
+ 'webAuth ' => $ this ->hasWebAuth ($ methods ),
574
+ ];
575
+
576
+ $ shouldExclude = false ;
577
+ foreach ($ excludeFeatures as $ feature ) {
578
+ if ($ serviceFeatures [$ feature ] ?? false ) {
579
+ $ shouldExclude = true ;
580
+ break ;
581
+ }
582
+ }
583
+
584
+ if (!$ shouldExclude ) {
585
+ $ filteredServices [$ serviceName ] = $ service ;
586
+ }
587
+ }
588
+
589
+ return $ filteredServices ;
590
+ }
591
+
540
592
/**
541
593
* @param string $target
542
594
* @throws Throwable
@@ -561,7 +613,7 @@ public function generate(string $target): void
561
613
'contactName ' => $ this ->spec ->getContactName (),
562
614
'contactURL ' => $ this ->spec ->getContactURL (),
563
615
'contactEmail ' => $ this ->spec ->getContactEmail (),
564
- 'services ' => $ this ->spec -> getServices (),
616
+ 'services ' => $ this ->getFilteredServices (),
565
617
'enums ' => $ this ->spec ->getEnums (),
566
618
'definitions ' => $ this ->spec ->getDefinitions (),
567
619
'global ' => [
@@ -595,7 +647,7 @@ public function generate(string $target): void
595
647
copy (realpath (__DIR__ . '/../../templates/ ' . $ file ['template ' ]), $ destination );
596
648
break ;
597
649
case 'service ' :
598
- foreach ($ this ->spec -> getServices () as $ key => $ service ) {
650
+ foreach ($ this ->getFilteredServices () as $ key => $ service ) {
599
651
$ methods = $ this ->spec ->getMethods ($ key );
600
652
$ params ['service ' ] = [
601
653
'globalParams ' => $ service ['globalParams ' ] ?? [],
@@ -628,7 +680,7 @@ public function generate(string $target): void
628
680
}
629
681
break ;
630
682
case 'method ' :
631
- foreach ($ this ->spec -> getServices () as $ key => $ service ) {
683
+ foreach ($ this ->getFilteredServices () as $ key => $ service ) {
632
684
$ methods = $ this ->spec ->getMethods ($ key );
633
685
$ params ['service ' ] = [
634
686
'name ' => $ key ,
0 commit comments