File tree 1 file changed +29
-0
lines changed
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 21
21
use Symfony \Component \Console \Tester \CommandTester ;
22
22
use Symfony \Component \DependencyInjection \ContainerInterface ;
23
23
use Symfony \Component \Finder \Finder ;
24
+ use Symfony \Component \HttpKernel \DataCollector \DataCollectorInterface ;
24
25
use Symfony \Component \HttpKernel \Kernel ;
25
26
use Symfony \Component \HttpKernel \Profiler \Profile ;
26
27
use Symfony \Component \Routing \Exception \ResourceNotFoundException ;
@@ -665,6 +666,34 @@ protected function getProfile()
665
666
return null ;
666
667
}
667
668
669
+ /**
670
+ * Grabs a Symfony Data Collector
671
+ *
672
+ * @param string $collector
673
+ * @param string $function
674
+ * @param string|null $message
675
+ * @return DataCollectorInterface
676
+ */
677
+ protected function grabCollector (string $ collector , string $ function , $ message = null ): DataCollectorInterface
678
+ {
679
+ if (!$ profile = $ this ->getProfile ()) {
680
+ $ this ->fail (
681
+ sprintf ("The Profile is needed to use the '%s' function. " , $ function )
682
+ );
683
+ }
684
+
685
+ if (!$ profile ->hasCollector ($ collector )) {
686
+ if ($ message ) {
687
+ $ this ->fail ($ message );
688
+ }
689
+ $ this ->fail (
690
+ sprintf ("The '%s' collector is needed to use the '%s' function. " , $ collector , $ function )
691
+ );
692
+ }
693
+
694
+ return $ profile ->getCollector ($ collector );
695
+ }
696
+
668
697
/**
669
698
* @param $url
670
699
*/
You can’t perform that action at this time.
0 commit comments