瀏覽代碼

simplified Profiler method names

Fabien Potencier 14 年之前
父節點
當前提交
7e2f135245

+ 1 - 1
src/Symfony/Bundle/FrameworkBundle/Profiler.php

@@ -28,7 +28,7 @@ class Profiler extends BaseProfiler
         parent::__construct($storage, $logger);
 
         foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
-            $this->addCollector($container->get($id));
+            $this->add($container->get($id));
         }
     }
 }

+ 4 - 4
src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

@@ -44,7 +44,7 @@ class ProfilerController extends ContainerAware
             return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:index', array(
                 'token'     => $token,
                 'profiler'  => new SafeDecorator($profiler),
-                'collector' => $profiler->getCollector('request'),
+                'collector' => $profiler->get('request'),
                 'template'  => $this->getTemplate($profiler, '_panel', 'request'),
                 'panel'     => 'request',
             ));
@@ -164,7 +164,7 @@ class ProfilerController extends ContainerAware
         $this->container->get('profiler')->disable();
 
         $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));
         }
 
@@ -176,7 +176,7 @@ class ProfilerController extends ContainerAware
             return $this->container->get('templating')->renderResponse('WebProfilerBundle:Profiler:panel', array(
                 'token'     => $token,
                 'profiler'  => new SafeDecorator($profiler),
-                'collector' => new SafeDecorator($profiler->getCollector($panel)),
+                'collector' => new SafeDecorator($profiler->get($panel)),
                 'template'  => $this->getTemplate($profiler, '_panel', $panel),
                 'panel'     => $panel,
             ));
@@ -292,7 +292,7 @@ class ProfilerController extends ContainerAware
     {
         $templates = array();
         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)) {
                     continue;
                 }

+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/menu.php

@@ -4,7 +4,7 @@
             <?php if ($name == $panel): ?>class="selected"<?php endif; ?>
         >
             <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>
         </li>
     <?php endforeach; ?>

+ 1 - 1
src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.php

@@ -24,7 +24,7 @@
     <?php endif; ?>
 >
 <?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; ?>
 </div>
 <!-- END of Symfony 2 Web Debug Toolbar -->

+ 7 - 7
src/Symfony/Component/HttpKernel/Profiler/Profiler.php

@@ -142,7 +142,7 @@ class Profiler
 
         if (false !== $items = $this->storage->read($token)) {
             list($data, $this->ip, $this->url, $this->time) = $items;
-            $this->setCollectors(unserialize(pack('H*', $data)));
+            $this->set(unserialize(pack('H*', $data)));
 
             $this->empty = false;
         } else {
@@ -258,7 +258,7 @@ class Profiler
      *
      * @return array An array of collectors
      */
-    public function getCollectors()
+    public function all()
     {
         return $this->collectors;
     }
@@ -268,11 +268,11 @@ class Profiler
      *
      * @param array $collectors An array of collectors
      */
-    public function setCollectors(array $collectors = array())
+    public function set(array $collectors = array())
     {
         $this->collectors = array();
         foreach ($collectors as $name => $collector) {
-            $this->addCollector($collector);
+            $this->add($collector);
         }
     }
 
@@ -281,7 +281,7 @@ class Profiler
      *
      * @param DataCollectorInterface $collector A DataCollectorInterface instance
      */
-    public function addCollector(DataCollectorInterface $collector)
+    public function add(DataCollectorInterface $collector)
     {
         $this->collectors[$collector->getName()] = $collector;
     }
@@ -291,7 +291,7 @@ class Profiler
      *
      * @param string $name A collector name
      */
-    public function hasCollector($name)
+    public function has($name)
     {
         return isset($this->collectors[$name]);
     }
@@ -305,7 +305,7 @@ class Profiler
      *
      * @throws \InvalidArgumentException if the collector does not exist
      */
-    public function getCollector($name)
+    public function get($name)
     {
         if (!isset($this->collectors[$name])) {
             throw new \InvalidArgumentException(sprintf('Collector "%s" does not exist.', $name));