Permalink
Browse files

Separating services from module, better docs

  • Loading branch information...
1 parent afe01ec commit 6b8cabdc85b68487b036170754f03f922a2048ce @Ocramius Ocramius committed Dec 15, 2012
Showing with 119 additions and 132 deletions.
  1. +1 −1 composer.json
  2. +75 −3 config/module.config.php
  3. +42 −90 config/services.config.php
  4. +1 −38 src/DoctrineORMModule/Module.php
View
@@ -45,7 +45,7 @@
"suggest": {
"zendframework/zend-developer-tools": "zend-developer-tools if you want to profile operations executed by the ORM during development"
},
- "minimum-stability": "alpha",
+ "minimum-stability": "dev",
"autoload": {
"psr-0": {
"DoctrineORMModule\\": "src/",
View
@@ -1,13 +1,37 @@
<?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>.
+ */
+
return array(
'doctrine' => array(
- 'orm_autoload_annotations' => true,
-
'connection' => array(
+ // Configuration for service `doctrine.connection.orm_default` service
'orm_default' => array(
+ // configuration instance to use. The retrieved service name will
+ // be `doctrine.configuration.$thisSetting`
'configuration' => 'orm_default',
+
+ // event manager instance to use. The retrieved service name will
+ // be `doctrine.eventmanager.$thisSetting`
'eventmanager' => 'orm_default',
+ // connection parameters, see
+ // http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html
'params' => array(
'host' => 'localhost',
'port' => '3306',
@@ -18,49 +42,93 @@
),
),
+ // Configuration details for the ORM.
+ // See http://docs.doctrine-project.org/en/latest/reference/configuration.html
'configuration' => array(
+ // Configuration for service `doctrine.configuration.orm_default` service
'orm_default' => array(
+ // metadata cache instance to use. The retrieved service name will
+ // be `doctrine.cache.$thisSetting`
'metadata_cache' => 'array',
+
+ // DQL queries parsing cache instance to use. The retrieved service
+ // name will be `doctrine.cache.$thisSetting`
'query_cache' => 'array',
+
+ // ResultSet cache to use. The retrieved service name will be
+ // `doctrine.cache.$thisSetting`
'result_cache' => 'array',
+ // Mapping driver instance to use. Change this only if you don't want
+ // to use the default chained driver. The retrieved service name will
+ // be `doctrine.driver.$thisSetting`
'driver' => 'orm_default',
+ // Generate proxies automatically (turn off for production)
'generate_proxies' => true,
+
+ // directory where proxies will be stored. By default, this is in
+ // the `data` directory of your application
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
+
+ // namespace for generated proxy classes
'proxy_namespace' => 'DoctrineORMModule\Proxy',
+
+ // SQL filters. See http://docs.doctrine-project.org/en/latest/reference/filters.html
'filters' => array()
)
),
+ // Metadata Mapping driver configuration
'driver' => array(
+ // Configuration for service `doctrine.driver.orm_default` service
'orm_default' => array(
+ // By default, the ORM module uses a driver chain. This allows multiple
+ // modules to define their own entities
'class' => 'Doctrine\ORM\Mapping\Driver\DriverChain',
+
+ // Map of driver names to be used within this driver chain, indexed by
+ // entity namespace
'drivers' => array()
)
),
+ // Entity Manager instantiation settings
'entitymanager' => array(
+ // configuration for the `doctrine.entitymanager.orm_default` service
'orm_default' => array(
+ // connection instance to use. The retrieved service name will
+ // be `doctrine.connection.$thisSetting`
'connection' => 'orm_default',
+
+ // configuration instance to use. The retrieved service name will
+ // be `doctrine.configuration.$thisSetting`
'configuration' => 'orm_default'
)
),
'eventmanager' => array(
+ // configuration for the `doctrine.eventmanager.orm_default` service
'orm_default' => array()
),
+ // collector SQL logger, used when ZendDeveloperTools and its toolbar are active
'sql_logger_collector' => array(
+ // configuration for the `doctrine.sql_logger_collector.orm_default` service
'orm_default' => array(),
),
+ // entity resolver configuration, allows mapping associations to interfaces
'entity_resolver' => array(
+ // configuration for the `doctrine.entity_resolver.orm_default` service
'orm_default' => array()
),
+ // authentication service configuration
'authentication' => array(
+ // configuration for the `doctrine.authentication.orm_default` authentication service
'orm_default' => array(
+ // name of the object manager to use. By default, the EntityManager is used
'objectManager' => 'doctrine.entitymanager.orm_default',
//'identityClass' => 'Application\Model\User',
//'identityProperty' => 'username',
@@ -69,7 +137,11 @@
),
),
- // zendframework/zend-developer-tools specific settings
+ ////////////////////////////////////////////////////////////////////
+ // `zendframework/zend-developer-tools` specific settings //
+ // ignore these if you're not developing additional features for //
+ // zend developer tools //
+ ////////////////////////////////////////////////////////////////////
'view_manager' => array(
'template_map' => array(
View
@@ -1,95 +1,47 @@
<?php
-return array(
- 'doctrine' => array(
- 'orm_autoload_annotations' => true,
-
- 'connection' => array(
- 'orm_default' => array(
- 'configuration' => 'orm_default',
- 'eventmanager' => 'orm_default',
-
- 'params' => array(
- 'host' => 'localhost',
- 'port' => '3306',
- 'user' => 'username',
- 'password' => 'password',
- 'dbname' => 'database',
- )
- ),
- ),
-
- 'configuration' => array(
- 'orm_default' => array(
- 'metadata_cache' => 'array',
- 'query_cache' => 'array',
- 'result_cache' => 'array',
-
- 'driver' => 'orm_default',
-
- 'generate_proxies' => true,
- 'proxy_dir' => 'data/DoctrineORMModule/Proxy',
- 'proxy_namespace' => 'DoctrineORMModule\Proxy',
- 'filters' => array()
- )
- ),
-
- 'driver' => array(
- 'orm_default' => array(
- 'class' => 'Doctrine\ORM\Mapping\Driver\DriverChain',
- 'drivers' => array()
- )
- ),
-
- 'entitymanager' => array(
- 'orm_default' => array(
- 'connection' => 'orm_default',
- 'configuration' => 'orm_default'
- )
- ),
+/*
+ * 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>.
+ */
- 'eventmanager' => array(
- 'orm_default' => array()
- ),
-
- 'sql_logger_collector' => array(
- 'orm_default' => array(),
- ),
-
- 'entity_resolver' => array(
- 'orm_default' => array()
- ),
-
- 'authentication' => array(
- 'orm_default' => array(
- 'objectManager' => 'doctrine.entitymanager.orm_default',
- //'identityClass' => 'Application\Model\User',
- //'identityProperty' => 'username',
- //'credentialProperty' => 'password'
- ),
- ),
- ),
-
- // zendframework/zend-developer-tools specific settings
-
- 'view_manager' => array(
- 'template_map' => array(
- 'zend-developer-tools/toolbar/doctrine-orm-queries' => __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-orm-queries.phtml',
- 'zend-developer-tools/toolbar/doctrine-orm-mappings' => __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-orm-mappings.phtml',
- ),
+return array(
+ 'aliases' => array(
+ 'Doctrine\ORM\EntityManager' => 'doctrine.entitymanager.orm_default',
),
-
- 'zenddevelopertools' => array(
- 'profiler' => array(
- 'collectors' => array(
- 'orm_default' => 'doctrine.sql_logger_collector.orm_default',
- 'orm_default_mappings' => 'doctrine.mapping_collector.orm_default',
- ),
- ),
- 'toolbar' => array(
- 'entries' => array(
- 'orm_default' => 'zend-developer-tools/toolbar/doctrine-orm-queries',
- 'orm_default_mappings' => 'zend-developer-tools/toolbar/doctrine-orm-mappings',
- ),
- ),
+ 'factories' => array(
+
+ 'doctrine.authenticationadapter.orm_default' => new DoctrineModule\Service\Authentication\AdapterFactory('orm_default'),
+ 'doctrine.authenticationstorage.orm_default' => new DoctrineModule\Service\Authentication\StorageFactory('orm_default'),
+ 'doctrine.authenticationservice.orm_default' => new DoctrineModule\Service\Authentication\AuthenticationServiceFactory('orm_default'),
+
+ 'doctrine.connection.orm_default' => new DoctrineORMModule\Service\DBALConnectionFactory('orm_default'),
+ 'doctrine.configuration.orm_default' => new DoctrineORMModule\Service\ConfigurationFactory('orm_default'),
+ 'doctrine.entitymanager.orm_default' => new DoctrineORMModule\Service\EntityManagerFactory('orm_default'),
+
+ 'doctrine.driver.orm_default' => new DoctrineModule\Service\DriverFactory('orm_default'),
+ 'doctrine.eventmanager.orm_default' => new DoctrineModule\Service\EventManagerFactory('orm_default'),
+ 'doctrine.entity_resolver.orm_default' => new DoctrineORMModule\Service\EntityResolverFactory('orm_default'),
+ 'doctrine.sql_logger_collector.orm_default' => new DoctrineORMModule\Service\SQLLoggerCollectorFactory('orm_default'),
+ 'doctrine.mapping_collector.orm_default' => function (Zend\ServiceManager\ServiceLocatorInterface $sl) {
+ $em = $sl->get('doctrine.entitymanager.orm_default');
+
+ return new DoctrineORMModule\Collector\MappingCollector($em->getMetadataFactory(), 'orm_default_mappings');
+ },
+ 'DoctrineORMModule\Form\Annotation\AnnotationBuilder' => function(Zend\ServiceManager\ServiceLocatorInterface $sl) {
+ return new DoctrineORMModule\Form\Annotation\AnnotationBuilder($sl->get('doctrine.entitymanager.orm_default'));
+ },
),
);
@@ -19,16 +19,7 @@
namespace DoctrineORMModule;
-use DoctrineModule\Service\DriverFactory;
-use DoctrineModule\Service\EventManagerFactory;
-
use DoctrineModule\Service\Authentication;
-use DoctrineORMModule\Service\ConfigurationFactory as ORMConfigurationFactory;
-use DoctrineORMModule\Service\EntityManagerFactory;
-use DoctrineORMModule\Service\EntityResolverFactory;
-use DoctrineORMModule\Service\DBALConnectionFactory;
-use DoctrineORMModule\Service\SQLLoggerCollectorFactory;
-use DoctrineORMModule\Form\Annotation\AnnotationBuilder;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
@@ -144,34 +135,6 @@ public function getConfig()
*/
public function getServiceConfig()
{
- return array(
- 'aliases' => array(
- 'Doctrine\ORM\EntityManager' => 'doctrine.entitymanager.orm_default',
- ),
- 'factories' => array(
-
- 'doctrine.authenticationadapter.orm_default' => new Authentication\AdapterFactory('orm_default'),
- 'doctrine.authenticationstorage.orm_default' => new Authentication\StorageFactory('orm_default'),
- 'doctrine.authenticationservice.orm_default' => new Authentication\AuthenticationServiceFactory('orm_default'),
-
- 'doctrine.connection.orm_default' => new DBALConnectionFactory('orm_default'),
- 'doctrine.configuration.orm_default' => new ORMConfigurationFactory('orm_default'),
- 'doctrine.entitymanager.orm_default' => new EntityManagerFactory('orm_default'),
-
- 'doctrine.driver.orm_default' => new DriverFactory('orm_default'),
- 'doctrine.eventmanager.orm_default' => new EventManagerFactory('orm_default'),
- 'doctrine.entity_resolver.orm_default' => new EntityResolverFactory('orm_default'),
- 'doctrine.sql_logger_collector.orm_default' => new SQLLoggerCollectorFactory('orm_default'),
- 'doctrine.mapping_collector.orm_default' => function ($sl) {
- $em = $sl->get('doctrine.entitymanager.orm_default');
-
- return new MappingCollector($em->getMetadataFactory(), 'orm_default_mappings');
- },
-
- 'DoctrineORMModule\Form\Annotation\AnnotationBuilder' => function(ServiceLocatorInterface $sl) {
- return new AnnotationBuilder($sl->get('doctrine.entitymanager.orm_default'));
- },
- ),
- );
+ return include __DIR__ . '/../../config/services.config.php';
}
}

0 comments on commit 6b8cabd

Please sign in to comment.