Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Trying to get profiler working
Browse files Browse the repository at this point in the history
  • Loading branch information
umpirsky committed Nov 8, 2014
1 parent 4418b66 commit b27924c
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 7 deletions.
2 changes: 2 additions & 0 deletions behat.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ default:
mailer:
username: smtp.knplabs@gmail.com
password: loremipsum
symfony_kernel:
bootstrap: features/fixtures/index.php
Behat\MinkExtension:
base_url: 'http://localhost:8080/'
goutte: ~
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
"require-dev": {
"symfony/http-kernel": "~2.0",
"symfony/framework-bundle": "~2.0",
"doctrine/common": "~2.0",
"symfony/web-profiler-bundle": "~2.0",
"symfony/twig-bundle": "~2.0",
"symfony/form": "~2.0",
"doctrine/doctrine-bundle": "~1.2",
"doctrine/data-fixtures": "~1.0",
"doctrine/orm": "~2.0",
"doctrine/inflector": "~1.0",
"behat/mink-extension": "~2.0",
"behat/mink-goutte-driver": "~1.0",
"behat/mink-selenium2-driver": "~1.0",
Expand Down
2 changes: 1 addition & 1 deletion features/Context/ServerContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static function start()
{
self::$proc = sprintf('/tmp/%s', md5(time() . uniqid()));
$command = sprintf(
'php -S %s -t %s/../',
'php -S %s -t %s/../fixtures',
self::SERVER_ADDRESS,
__DIR__
);
Expand Down
14 changes: 14 additions & 0 deletions features/fixtures/App/Controller/DefaultController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;

class DefaultController extends Controller
{
public function indexAction()
{
return new Response();
}
}
4 changes: 4 additions & 0 deletions features/fixtures/App/Resources/config/routing.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
homepage:
pattern: /
defaults: { _controller: 'App:Default:index' }

mailer_no_emails:
pattern: /mailer/no-emails
defaults: { _controller: 'App:Mailer:noEmails' }
15 changes: 13 additions & 2 deletions features/fixtures/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ class AppKernel extends Kernel
public function registerBundles()
{
return array(
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle,
new \App\App
new Symfony\Bundle\FrameworkBundle\FrameworkBundle,
new Symfony\Bundle\TwigBundle\TwigBundle,
new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle,
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle,
new App\App
);
}

Expand All @@ -18,8 +21,16 @@ public function registerContainerConfiguration(LoaderInterface $loader)
$loader->load(function($container) {
$container->loadFromExtension('framework', array(
'router' => array('resource' => __DIR__.'/App/Resources/config/routing.yml'),
'templating' => array(
'engines' => array('twig'),
),
'profiler' => array('enabled' => true),
));

$container->loadFromExtension('doctrine', array(
'orm' => array(),
'dbal' => array(),
));
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Knp/FriendlyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Knp\FriendlyExtension\DependencyInjection\Compiler\RemoveUnavailableServicesPass;
use Knp\FriendlyExtension\DependencyInjection\Compiler\SetArgumentToNullPass;
use Knp\FriendlyExtension\DependencyInjection\Compiler\SymfonyServicePass;
use Knp\FriendlyExtension\DependencyInjection\Compiler\KernelPass;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -28,7 +29,6 @@ public function getConfigKey()

public function initialize(ExtensionManager $extensionManager)
{

}

public function configure(ArrayNodeDefinition $builder)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Knp\FriendlyExtension\DependencyInjection\Compiler;

use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;

class KernelPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$this->loadFileFromParameter($container, 'friendly.symfony_kernel.bootstrap');
$this->loadFileFromParameter($container, 'friendly.symfony_kernel.path');

if (null !== $class = $this->getKernelClass($container)) {
$definition = new Definition($class);
$definition
->addArgument($container->getParameter('friendly.symfony_kernel.env'))
->addArgument($container->getParameter('friendly.symfony_kernel.debug'))
;
$container->setDefinition('friendly.symfony.kernel', $definition);
}
}

protected function loadFileFromParameter(ContainerBuilder $container, $parameter)
{
$base = $container->getParameter('paths.base');
$param = $container->getParameter($parameter);
if (file_exists($file = $base.DIRECTORY_SEPARATOR.$param)) {
require_once($file);
} elseif (file_exists($param)) {
require_once($param);
}
}

protected function getKernelClass(ContainerBuilder $container)
{
$class = $container->getParameter('friendly.symfony_kernel.class');

return class_exists($class) ? $class : null;
}
}
5 changes: 5 additions & 0 deletions src/Knp/FriendlyExtension/Resources/config/symfony.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ services:
- { name: friendly.symfony.service, class: Doctrine\Common\Persistence\AbstractManagerRegistry }
- { name: remove-when-missing, service: friendly.symfony.kernel }

profiler:
synthetic: true
tags:
- { name: friendly.symfony.service, class: Symfony\Component\HttpKernel\Profiler\Profiler }
- { name: remove-when-missing, service: friendly.symfony.kernel }

0 comments on commit b27924c

Please sign in to comment.