simplified Profiler method names
This commit is contained in:
parent
15cd2643c0
commit
7e2f135245
@ -28,7 +28,7 @@ class Profiler extends BaseProfiler
|
|||||||
parent::__construct($storage, $logger);
|
parent::__construct($storage, $logger);
|
||||||
|
|
||||||
foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
|
foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
|
||||||
$this->addCollector($container->get($id));
|
$this->add($container->get($id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class ProfilerController extends ContainerAware
|
|||||||
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:index', array(
|
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:index', array(
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'profiler' => new SafeDecorator($profiler),
|
'profiler' => new SafeDecorator($profiler),
|
||||||
'collector' => $profiler->getCollector('request'),
|
'collector' => $profiler->get('request'),
|
||||||
'template' => $this->getTemplate($profiler, '_panel', 'request'),
|
'template' => $this->getTemplate($profiler, '_panel', 'request'),
|
||||||
'panel' => 'request',
|
'panel' => 'request',
|
||||||
));
|
));
|
||||||
@ -164,7 +164,7 @@ class ProfilerController extends ContainerAware
|
|||||||
$this->container->get('profiler')->disable();
|
$this->container->get('profiler')->disable();
|
||||||
|
|
||||||
$profiler = $this->container->get('profiler')->loadFromToken($token);
|
$profiler = $this->container->get('profiler')->loadFromToken($token);
|
||||||
if (!$profiler->hasCollector($panel)) {
|
if (!$profiler->has($panel)) {
|
||||||
throw new NotFoundHttpException(sprintf('Panel "%s" is not registered.', $panel));
|
throw new NotFoundHttpException(sprintf('Panel "%s" is not registered.', $panel));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class ProfilerController extends ContainerAware
|
|||||||
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:panel', array(
|
return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:panel', array(
|
||||||
'token' => $token,
|
'token' => $token,
|
||||||
'profiler' => new SafeDecorator($profiler),
|
'profiler' => new SafeDecorator($profiler),
|
||||||
'collector' => new SafeDecorator($profiler->getCollector($panel)),
|
'collector' => new SafeDecorator($profiler->get($panel)),
|
||||||
'template' => $this->getTemplate($profiler, '_panel', $panel),
|
'template' => $this->getTemplate($profiler, '_panel', $panel),
|
||||||
'panel' => $panel,
|
'panel' => $panel,
|
||||||
));
|
));
|
||||||
@ -292,7 +292,7 @@ class ProfilerController extends ContainerAware
|
|||||||
{
|
{
|
||||||
$templates = array();
|
$templates = array();
|
||||||
foreach ($this->container->getParameter('data_collector.templates') as $name => $template) {
|
foreach ($this->container->getParameter('data_collector.templates') as $name => $template) {
|
||||||
if ($profiler->hasCollector($name)) {
|
if ($profiler->has($name)) {
|
||||||
if (!$this->container->get('templating')->exists($template.$suffix)) {
|
if (!$this->container->get('templating')->exists($template.$suffix)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<?php if ($name == $panel): ?>class="selected"<?php endif; ?>
|
<?php if ($name == $panel): ?>class="selected"<?php endif; ?>
|
||||||
>
|
>
|
||||||
<a href="<?php echo $view->get('router')->generate('_profiler_panel', array('token' => $token, 'panel' => $name)) ?>">
|
<a href="<?php echo $view->get('router')->generate('_profiler_panel', array('token' => $token, 'panel' => $name)) ?>">
|
||||||
<?php echo $view->render($template, array('data' => $profiler->getCollector($name))) ?>
|
<?php echo $view->render($template, array('data' => $profiler->get($name))) ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
>
|
>
|
||||||
<?php foreach ($templates as $name => $template): ?>
|
<?php foreach ($templates as $name => $template): ?>
|
||||||
<?php echo $view->render($template, array('data' => $profiler->getCollector($name))) ?>
|
<?php echo $view->render($template, array('data' => $profiler->get($name))) ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
<!-- END of Symfony 2 Web Debug Toolbar -->
|
<!-- END of Symfony 2 Web Debug Toolbar -->
|
||||||
|
@ -142,7 +142,7 @@ class Profiler
|
|||||||
|
|
||||||
if (false !== $items = $this->storage->read($token)) {
|
if (false !== $items = $this->storage->read($token)) {
|
||||||
list($data, $this->ip, $this->url, $this->time) = $items;
|
list($data, $this->ip, $this->url, $this->time) = $items;
|
||||||
$this->setCollectors(unserialize(pack('H*', $data)));
|
$this->set(unserialize(pack('H*', $data)));
|
||||||
|
|
||||||
$this->empty = false;
|
$this->empty = false;
|
||||||
} else {
|
} else {
|
||||||
@ -258,7 +258,7 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @return array An array of collectors
|
* @return array An array of collectors
|
||||||
*/
|
*/
|
||||||
public function getCollectors()
|
public function all()
|
||||||
{
|
{
|
||||||
return $this->collectors;
|
return $this->collectors;
|
||||||
}
|
}
|
||||||
@ -268,11 +268,11 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @param array $collectors An array of collectors
|
* @param array $collectors An array of collectors
|
||||||
*/
|
*/
|
||||||
public function setCollectors(array $collectors = array())
|
public function set(array $collectors = array())
|
||||||
{
|
{
|
||||||
$this->collectors = array();
|
$this->collectors = array();
|
||||||
foreach ($collectors as $name => $collector) {
|
foreach ($collectors as $name => $collector) {
|
||||||
$this->addCollector($collector);
|
$this->add($collector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +281,7 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @param DataCollectorInterface $collector A DataCollectorInterface instance
|
* @param DataCollectorInterface $collector A DataCollectorInterface instance
|
||||||
*/
|
*/
|
||||||
public function addCollector(DataCollectorInterface $collector)
|
public function add(DataCollectorInterface $collector)
|
||||||
{
|
{
|
||||||
$this->collectors[$collector->getName()] = $collector;
|
$this->collectors[$collector->getName()] = $collector;
|
||||||
}
|
}
|
||||||
@ -291,7 +291,7 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @param string $name A collector name
|
* @param string $name A collector name
|
||||||
*/
|
*/
|
||||||
public function hasCollector($name)
|
public function has($name)
|
||||||
{
|
{
|
||||||
return isset($this->collectors[$name]);
|
return isset($this->collectors[$name]);
|
||||||
}
|
}
|
||||||
@ -305,7 +305,7 @@ class Profiler
|
|||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException if the collector does not exist
|
* @throws \InvalidArgumentException if the collector does not exist
|
||||||
*/
|
*/
|
||||||
public function getCollector($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
if (!isset($this->collectors[$name])) {
|
if (!isset($this->collectors[$name])) {
|
||||||
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
|
throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));
|
||||||
|
Reference in New Issue
Block a user