diff --git a/src/Controller/AbstractExtendedController.php b/src/Controller/AbstractExtendedController.php index 0dd4f1d..74710a4 100644 --- a/src/Controller/AbstractExtendedController.php +++ b/src/Controller/AbstractExtendedController.php @@ -7,6 +7,7 @@ use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Stopwatch\Stopwatch; /** * Abstract class for generic controller @@ -14,6 +15,14 @@ abstract class AbstractExtendedController extends AbstractController { + /** @var Stopwatch Profiler stopwatch */ + protected $stopwatch = null; + + public function __construct(Stopwatch $stopwatch) + { + $this->stopwatch = $stopwatch; + } + /** * Create the json answer for an ajax form * - code : Http code @@ -49,9 +58,11 @@ */ protected function createNamedCustomForm(string $name, string $type, array $options = []): AbstractFormManager { + $this->stopwatch->start($name, 'form'); /** @var FormFactory $formFactory */ $formFactory = $this->container->get('form.factory'); $formBuilder = $formFactory->createNamedBuilder($name, FormType::class); + $this->stopwatch->stop($name); return new $type($formBuilder, $options, true); } @@ -65,12 +76,14 @@ */ protected function createNamedGetCustomForm(string $name, string $type, array $options = []): AbstractFormManager { + $this->stopwatch->start($name, 'form'); /** @var FormFactory $formFactory */ $formFactory = $this->container->get('form.factory'); $formBuilder = $formFactory->createNamedBuilder($name, FormType::class, [], [ 'csrf_protection' => false, ]); $formBuilder->setMethod('GET'); + $this->stopwatch->stop($name); return new $type($formBuilder, $options, false); } }