Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Zend developer tools integration #52

Merged
merged 6 commits into from

2 participants

@jhuet

No description provided.

src/DoctrineMongoODMModule/Module.php
@@ -50,6 +50,14 @@ public function onBootstrap(EventInterface $event)
// Attach to helper set event and load the document manager helper.
$sharedManager->attach('doctrine', 'loadCli.post', array($this, 'loadCli'));
+
+ $config = $app->getServiceManager()->get('Configuration');
@Ocramius Owner
Ocramius added a note

There's open issues for this at doctrine/DoctrineORMModule#106 and doctrine/DoctrineORMModule#112. Are you able to take care of those? (shouldn't use config here, as of 106).

@Ocramius Owner

doctrine/DoctrineORMModule#151 merged, added comments on doctrine/DoctrineORMModule#150

Awesome work so far! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ocramius
Owner

Looks good to me, needs to get those points I commented fixed.

@Ocramius Ocramius commented on the diff
view/zend-developer-tools/toolbar/doctrine-odm.phtml
((157 lines not shown))
+ </span>
+ <span class="clear"></span>
+ <span class="zdt-detail-label">Args</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php foreach($query['args'] as $key => $value): ?>
+ &nbsp;&nbsp;&nbsp;&nbsp;<?php echo $key ?> => <?php \Doctrine\Common\Util\Debug::dump($value) ?><br/>
+ <?php endforeach ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+ <?php endforeach ?>
+ </span>
+ </div>
+</div>
+<style>
+.zdt-toolbar-entry .zdt-toolbar-detail .ddt-toolbar-info {
@Ocramius Owner

I think these should probably be different from those in DoctrineORMModule

@jhuet
jhuet added a note

I'm not sure what you mean here ?

@Ocramius Owner

The CSS classes are copied over from DoctrineORMModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
view/zend-developer-tools/toolbar/doctrine-odm.phtml
@@ -0,0 +1,206 @@
+<div class="zdt-toolbar-entry">
+ <div class="zdt-toolbar-preview">
+ <img src="data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAA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+yc3NTS8chPh8Pg/2BP3rYExlSqVSKxQK9XjgRorXSCSSrCyLkYlyVU6JGgfUiI5Q/E7S7hD6KNU88DeJRj2kB/4HfX19X5OO4cxptVrVaNQcCF8mk2WftLoY2xA43+ns7HTabLYn8LfEjI+Pk5qaGiEW15B+FQi+jCKJ8EcWw3kWUmGOp4biRcFtEL87v9PpXMEIvoP5NffLIz8FGAAqeUQbl180BwAAAABJRU5ErkJggg==" alt="Database (Zend\Db)">
@Ocramius Owner

Maybe too much, but do you think a green mongo leaf may be good here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Ocramius
Owner

@jhuet wanna fix those two or do you prefer having me to merge this now?

@Ocramius Ocramius merged commit f7e9379 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 1, 2012
  1. @jhuet

    Adding LoggerChain.

    jhuet authored
  2. @jhuet

    Adding EchoLogger.

    jhuet authored
  3. @jhuet
Commits on Dec 9, 2012
  1. @jhuet

    Adding collector name.

    jhuet authored
Commits on Dec 10, 2012
  1. @jhuet
Commits on Dec 15, 2012
  1. @jhuet

    New icon with MongoDB leaf.

    jhuet authored
This page is out of date. Refresh to see the latest.
View
25 config/module.config.php
@@ -54,6 +54,10 @@
)
),
+ 'mongo_logger_collector' => array(
+ 'odm_default' => array(),
+ ),
+
'authentication' => array(
'odm_default' => array(
'objectManager' => 'doctrine.documentmanager.odm_default',
@@ -63,4 +67,25 @@
),
),
),
+
+ // zendframework/zend-developer-tools specific settings
+
+ 'view_manager' => array(
+ 'template_map' => array(
+ 'zend-developer-tools/toolbar/doctrine-odm' => __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-odm.phtml',
+ ),
+ ),
+
+ 'zenddevelopertools' => array(
+ 'profiler' => array(
+ 'collectors' => array(
+ 'odm_default' => 'doctrine.mongo_logger_collector.odm_default',
+ ),
+ ),
+ 'toolbar' => array(
+ 'entries' => array(
+ 'odm_default' => 'zend-developer-tools/toolbar/doctrine-odm',
+ ),
+ ),
+ ),
);
View
117 src/DoctrineMongoODMModule/Collector/MongoLoggerCollector.php
@@ -0,0 +1,117 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+namespace DoctrineMongoODMModule\Collector;
+
+
+use ZendDeveloperTools\Collector\CollectorInterface;
+use ZendDeveloperTools\Collector\AutoHideInterface;
+
+use Zend\Mvc\MvcEvent;
+
+use DoctrineMongoODMModule\Logging\DebugStack;
+
+/**
+ * Collector to be used in ZendDeveloperTools to record and display Mongo
+ * queries
+ *
+ * @license MIT
+ * @link www.doctrine-project.org
+ */
+class MongoLoggerCollector implements CollectorInterface, AutoHideInterface
+{
+ /**
+ * Collector priority
+ */
+ const PRIORITY = 10;
+
+ /**
+ * @var DebugStack
+ */
+ protected $mongoLogger;
+
+ /**
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * @param DebugStack $mongoLogger
+ * @param string $name
+ */
+ public function __construct(DebugStack $mongoLogger, $name)
+ {
+ $this->mongoLogger = $mongoLogger;
+ $this->name = (string) $name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPriority()
+ {
+ return static::PRIORITY;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function collect(MvcEvent $mvcEvent)
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function canHide()
+ {
+ return empty($this->mongoLogger->queries);
+ }
+
+ /**
+ * @return int
+ */
+ public function getQueryCount()
+ {
+ return count($this->mongoLogger->queries);
+ }
+
+ /**
+ * @return array
+ */
+ public function getQueries()
+ {
+ return $this->mongoLogger->queries;
+ }
+
+ /**
+ * @return float
+ */
+ public function getQueryTime()
+ {
+ return 0.0;
+ }
+}
View
38 src/DoctrineMongoODMModule/Logging/EchoLogger.php
@@ -0,0 +1,38 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+namespace DoctrineMongoODMModule\Logging;
+
+/**
+ * A logger that logs to the standard output using echo/var_dump.
+ *
+ * @license MIT
+ * @link www.doctrine-project.org
+ */
+class EchoLogger implements Logger
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function log(array $logs)
+ {
+ if ($logs) {
+ var_dump($logs);
+ }
+ }
+}
View
51 src/DoctrineMongoODMModule/Logging/LoggerChain.php
@@ -0,0 +1,51 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+namespace DoctrineMongoODMModule\Logging;
+
+/**
+ * Chains multiple Logger
+ *
+ * @license MIT
+ * @link www.doctrine-project.org
+ */
+class LoggerChain implements Logger
+{
+ private $loggers = array();
+
+ /**
+ * Adds a logger in the chain
+ *
+ * @param Logger $logger
+ */
+ public function addLogger(Logger $logger)
+ {
+ $this->loggers[] = $logger;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function log(array $logs)
+ {
+ foreach ($this->loggers as $logger) {
+ $logger->log($logs);
+ }
+ }
+}
+
View
26 src/DoctrineMongoODMModule/Module.php
@@ -21,11 +21,14 @@
use DoctrineModule\Service as CommonService;
use DoctrineMongoODMModule\Service as ODMService;
+
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
+use Zend\ModuleManager\Feature\InitProviderInterface;
+use Zend\ModuleManager\ModuleManagerInterface;
use Zend\Loader\AutoloaderFactory;
use Zend\Loader\StandardAutoloader;
@@ -37,8 +40,24 @@
* @since 0.1.0
* @author Tim Roediger <superdweebie@gmail.com>
*/
-class Module implements BootstrapListenerInterface, AutoloaderProviderInterface, ConfigProviderInterface, ServiceProviderInterface
+class Module implements
+ BootstrapListenerInterface,
+ AutoloaderProviderInterface,
+ ConfigProviderInterface,
+ ServiceProviderInterface,
+ InitProviderInterface
{
+ /**
+ * {@inheritDoc}
+ */
+ public function init(ModuleManagerInterface $manager)
+ {
+ $events = $manager->getEventManager();
+ // Initialize logger collector once the profiler is initialized itself
+ $events->attach('profiler_init', function(EventInterface $e) use ($manager) {
+ $manager->getEvent()->getParam('ServiceManager')->get('doctrine.mongo_logger_collector.odm_default');
+ });
+ }
/**
* {@inheritDoc}
@@ -103,7 +122,9 @@ public function getServiceConfig()
{
return array(
'invokables' => array(
- 'DoctrineMongoODMModule\Logging\DebugStack' => 'DoctrineMongoODMModule\Logging\DebugStack',
+ 'DoctrineMongoODMModule\Logging\DebugStack' => 'DoctrineMongoODMModule\Logging\DebugStack',
+ 'DoctrineMongoODMModule\Logging\LoggerChain' => 'DoctrineMongoODMModule\Logging\LoggerChain',
+ 'DoctrineMongoODMModule\Logging\EchoLogger' => 'DoctrineMongoODMModule\Logging\EchoLogger',
),
'aliases' => array(
'Doctrine\ODM\Mongo\DocumentManager' => 'doctrine.documentmanager.odm_default',
@@ -117,6 +138,7 @@ public function getServiceConfig()
'doctrine.driver.odm_default' => new CommonService\DriverFactory('odm_default'),
'doctrine.documentmanager.odm_default' => new ODMService\DocumentManagerFactory('odm_default'),
'doctrine.eventmanager.odm_default' => new CommonService\EventManagerFactory('odm_default'),
+ 'doctrine.mongo_logger_collector.odm_default' => new ODMService\MongoLoggerCollectorFactory('odm_default'),
)
);
}
View
100 src/DoctrineMongoODMModule/Options/MongoLoggerCollector.php
@@ -0,0 +1,100 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineMongoODMModule\Options;
+
+use Zend\Stdlib\AbstractOptions;
+
+/**
+ * Configuration options for a collector
+ *
+ * @license MIT
+ * @link http://www.doctrine-project.org/
+ */
+class MongoLoggerCollector extends AbstractOptions
+{
+ /**
+ * @var string name to be assigned to the collector
+ */
+ protected $name = 'odm_default';
+
+ /**
+ * @var string|null service name of the configuration where the logger has to be put
+ */
+ protected $configuration;
+
+ /**
+ * @var string|null service name of the Logger to be used
+ */
+ protected $mongoLogger;
+
+ /**
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = (string) $name;
+ }
+
+ /**
+ * Name of the collector
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @param string|null $configuration
+ */
+ public function setConfiguration($configuration)
+ {
+ $this->configuration = $configuration ? (string) $configuration : null;
+ }
+
+ /**
+ * Configuration service name (where to set the logger)
+ *
+ * @return string
+ */
+ public function getConfiguration()
+ {
+ return $this->configuration ? $this->configuration : 'doctrine.configuration.odm_default';
+ }
+
+ /**
+ * @param string|null $mongoLogger
+ */
+ public function setMongoLogger($mongoLogger)
+ {
+ $this->mongoLogger = $mongoLogger ? (string) $mongoLogger : null;
+ }
+
+ /**
+ * Logger service name
+ *
+ * @return string|null
+ */
+ public function getMongoLogger()
+ {
+ return $this->mongoLogger;
+ }
+}
View
89 src/DoctrineMongoODMModule/Service/MongoLoggerCollectorFactory.php
@@ -0,0 +1,89 @@
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineMongoODMModule\Service;
+
+use DoctrineModule\Service\AbstractFactory;
+
+use Zend\ServiceManager\ServiceLocatorInterface;
+
+use DoctrineMongoODMModule\Collector\MongoLoggerCollector;
+
+use DoctrineMongoODMModule\Logging\DebugStack;
+use DoctrineMongoODMModule\Logging\LoggerChain;
+
+/**
+ * Mongo Logger Configuration ServiceManager factory
+ *
+ * @license MIT
+ * @link http://www.doctrine-project.org/
+ */
+class MongoLoggerCollectorFactory extends AbstractFactory
+{
+ /**
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * @param $name
+ */
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function createService(ServiceLocatorInterface $serviceLocator)
+ {
+ /** @var $options \DoctrineMongoODMModule\Options\MongoLoggerCollector */
+ $options = $this->getOptions($serviceLocator, 'mongo_logger_collector');
+
+ if ($options->getMongoLogger()) {
+ $debugStackLogger = $serviceLocator->get($options->getMongoLogger());
+ } else {
+ $debugStackLogger = new DebugStack();
+ }
+
+ /** @var $options \Doctrine\ODM\MongoDB\Configuration */
+ $configuration = $serviceLocator->get($options->getConfiguration());
+
+ if (null !== $configuration->getLoggerCallable()) {
+ $logger = new LoggerChain();
+ $logger->addLogger($debugStackLogger);
+ $callable = $configuration->getLoggerCallable();
+ $logger->addLogger($callable[0]);
+ $configuration->setLoggerCallable(array($logger, 'log'));
+ } else {
+ $configuration->setLoggerCallable(array($debugStackLogger, 'log'));
+ }
+
+ return new MongoLoggerCollector($debugStackLogger, $options->getName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getOptionsClass()
+ {
+ return 'DoctrineMongoODMModule\Options\MongoLoggerCollector';
+ }
+}
View
206 view/zend-developer-tools/toolbar/doctrine-odm.phtml
@@ -0,0 +1,206 @@
+<div class="zdt-toolbar-entry">
+ <div class="zdt-toolbar-preview">
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sb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1JSTyWT2UPBX683NOW7Ef5WOH7SrB4miyKuE09PT/qqqqkdlZAap+eHFobuXaWxrjGQ5SW3T58gg6Kk6r5JwWyIoFPHBYJC8Xu/RsrIyo16vZ0Wix+FOxENfrvaRyPMUT0i0Ed6iW/dcFLu1tfZpx9krzc3N3/BDQ0MfwNnT1NTkHR0djeGaSOyqaLVajU6n+8cBn3u+otBekLQqYZJC2xGKJqM0F7jt+uLkubjFYvlacLlcR2pqahzj4+MT8/PzfW1tbfzMzMwBg8FQBg3zoK+i0Wg47SG9oeTk4WeztftIguayIuMQQOaIt+rsES6qSiLE43FKF8VRWVnp6O1ld5TuYs0JuPEeYX7nff3PXA1fU8kk6KfuUVK6xqU9urJ2XXnx2HESNjc3t1C5h7XPZ0CEL2cWgon7lEBECZBJskRJNcLUTefAfG1jRvXTdHR0XBwcHPSzE/8NvtgGSWBQge+kLKu6kqovGjvg3lMJ+/r68hcWFn5qaGiY6OzsXHK73fcjkYjEon4QYWkXESpqlJKClClFKKfBoX6MkOvv7x9DCz23s7Nztr29fXFiYuIwCG1oRXNubq6Igqh+nrf5Kq2J1+YIAu0XtSTH0UqBMKlzA4Q5oolmTwxzQiAQ4IqKigh38P3W1lZ2qhdOU6FQaGRtbc0P8hjP85pPdJdOxJXYk6ko06nKChNQ7U4Dn5p0AlpGSlc5YzaQ2hAdMWTsVTTAd6HLKEoqbQ0jy5SZjR9jYaooPT09I5h/u/9VlBeM1cTjJ7FKp6utBgpig0ZPwo3oHVUbNjmysrI+bmxstDscjgPl5eU5jxtX5//6gUa2r1O2KJJmN0liWKdYYuYd3yXXkvOPuTZk9i03PDxMtbW1Wvi/hvRfstvtz6NIejS6wWw274N+XIZwl4tz/eLvxpL1/eHIzVBwaXZhESPsN/z1I8jYyKO/BRgA1r1+Kb0HhFQAAAAASUVORK5CYII=" alt="MongoDB (DoctrineMongoODMModule)">
+ <span class="zdt-toolbar-info">
+ <?php echo $this->collector->getQueryCount(); ?> queries
+ </span>
+ </div>
+ <div class="zdt-toolbar-detail">
+ <span class="zdt-toolbar-info zdt-toolbar-info-heading">Details</span>
+ <span class="zdt-toolbar-info">
+ <span class="zdt-detail-label">Help us!</span>
+ <span class="zdt-detail-value zdt-detail-value-right">
+ Please help us improve
+ <br/>
+ profiling by forking and
+ <br/>
+ contributing to
+ <br/>
+ <a href="https://github.com/doctrine/DoctrineMongoODMModule/fork_select" target="_blank">
+ DoctrineMongoODMModule
+ </a>
+ </span>
+ </span>
+
+ <span class="zdt-toolbar-info zdt-toolbar-info-heading">Queries <span class="ddt-toolbar-info">for <?php echo $this->collector->getName() ?></span></span>
+ <span class="zdt-toolbar-info ddt-toolbar-info">
+ <?php foreach ($this->collector->getQueries() as $query): ?>
+ <hr/>
+
+ <?php if (isset($query['db'])): ?>
+ <span class="zdt-detail-label">Database</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['db']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['collection'])): ?>
+ <span class="zdt-detail-label">Collection</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['collection']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <span class="zdt-detail-label">Query</span>
+ <span class="zdt-detail-value ddt-detail-query ddt-detail-value">
+
+ <?php if (isset($query['query']) && is_array($query['query']) && !empty($query['query'])): ?>
+ <?php foreach($query['query'] as $key => $value): ?>
+ <?php print_r($value) ?>
+ <?php endforeach ?>
+ <?php endif ?>
+ </span>
+
+ <span class="clear"></span>
+
+ <?php if (isset($query['fields']) && is_array($query['fields']) && !empty($query['fields'])): ?>
+ <span class="zdt-detail-label">Fields</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php foreach($query['fields'] as $key => $value): ?>
+ &nbsp;&nbsp;&nbsp;&nbsp;<?php echo $key ?> => <?php print_r($value) ?>
+ <?php endforeach ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['find'])): ?>
+ <span class="zdt-detail-label">Find</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['find']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['limit'])): ?>
+ <span class="zdt-detail-label">Limit to</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['limitNum']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['sort'])): ?>
+ <span class="zdt-detail-label">Sort by</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['sortFields']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['skip'])): ?>
+ <span class="zdt-detail-label">Skip to</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php \Doctrine\Common\Util\Debug::dump($query['skipNum']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['authenticate'])): ?>
+ <span class="zdt-detail-label">Authenticate</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;username => <?php \Doctrine\Common\Util\Debug::dump($query['username']) ?><br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;password => <?php \Doctrine\Common\Util\Debug::dump($query['password']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['command'])): ?>
+ <span class="zdt-detail-label">Command</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;data => <?php \Doctrine\Common\Util\Debug::dump($query['data']) ?><br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;options => <?php \Doctrine\Common\Util\Debug::dump($query['options']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['createCollection'])): ?>
+ <span class="zdt-detail-label">Create collection</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;capped => <?php \Doctrine\Common\Util\Debug::dump($query['capped']) ?><br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;size => <?php \Doctrine\Common\Util\Debug::dump($query['size']) ?><br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;max => <?php \Doctrine\Common\Util\Debug::dump($query['max']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['createDBRef'])): ?>
+ <span class="zdt-detail-label">Create DB ref</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;collection => <?php \Doctrine\Common\Util\Debug::dump($query['collection']) ?><br/>
+ &nbsp;&nbsp;&nbsp;&nbsp;reference => <?php \Doctrine\Common\Util\Debug::dump($query['reference']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['getDBRef'])): ?>
+ <span class="zdt-detail-label">Get DB ref</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;reference => <?php \Doctrine\Common\Util\Debug::dump($query['reference']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['drop'])): ?>
+ <span class="zdt-detail-label">Drop database</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ &nbsp;&nbsp;&nbsp;&nbsp;dropDatabase => <?php \Doctrine\Common\Util\Debug::dump($query['dropDatabase']) ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+
+ <?php if (isset($query['execute'])): ?>
+ <span class="zdt-detail-label">Code</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php print_r($query['code']) ?>
+ </span>
+ <span class="clear"></span>
+ <span class="zdt-detail-label">Args</span>
+ <span class="zdt-detail-value ddt-detail-value">
+ <?php foreach($query['args'] as $key => $value): ?>
+ &nbsp;&nbsp;&nbsp;&nbsp;<?php echo $key ?> => <?php \Doctrine\Common\Util\Debug::dump($value) ?><br/>
+ <?php endforeach ?>
+ </span>
+ <span class="clear"></span>
+ <?php endif ?>
+ <?php endforeach ?>
+ </span>
+ </div>
+</div>
+<style>
+.zdt-toolbar-entry .zdt-toolbar-detail .ddt-toolbar-info {
@Ocramius Owner

I think these should probably be different from those in DoctrineORMModule

@jhuet
jhuet added a note

I'm not sure what you mean here ?

@Ocramius Owner

The CSS classes are copied over from DoctrineORMModule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ font-size: 11px;
+ max-width: 600px;
+ witdh: 600px;
+ max-height: 300px;
+ overflow-y: scroll;
+ overflow-x: hidden;
+}
+
+.zdt-toolbar-entry .zdt-toolbar-detail .ddt-detail-query {
+
+ white-space: normal;
+ width: 400px;
+}
+
+.zdt-toolbar-entry .zdt-toolbar-detail .ddt-detail-query .highlight {
+
+ color: #80DC09;
+ font-weight: bold;
+}
+
+.zdt-toolbar-entry .zdt-toolbar-info .clear {
+
+ clear: both;
+ display: block;
+}
+
+.zdt-toolbar-entry .zdt-toolbar-detail .ddt-toolbar-info hr {
+
+ border: 0;
+ border-top: 1px solid #80DC09;
+ clear: both;
+}
+</style>
Something went wrong with that request. Please try again.