File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 2121use Symfony \Component \Console \Tester \CommandTester ;
2222use Symfony \Component \DependencyInjection \ContainerInterface ;
2323use Symfony \Component \Finder \Finder ;
24+ use Symfony \Component \HttpKernel \DataCollector \DataCollectorInterface ;
2425use Symfony \Component \HttpKernel \Kernel ;
2526use Symfony \Component \HttpKernel \Profiler \Profile ;
2627use Symfony \Component \Routing \Exception \ResourceNotFoundException ;
@@ -665,6 +666,34 @@ protected function getProfile()
665666 return null ;
666667 }
667668
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+
668697 /**
669698 * @param $url
670699 */
You can’t perform that action at this time.
0 commit comments