1
1
<?php
2
2
3
- require_once __DIR__ . '/../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php ' ;
3
+ use Doctrine \Common \ClassLoader ;
4
+ use Doctrine \Common \Annotations \AnnotationReader ;
5
+ use Doctrine \MongoDB \Connection ;
6
+ use Doctrine \ODM \MongoDB \Configuration ;
7
+ use Doctrine \ODM \MongoDB \DocumentManager ;
8
+ use Doctrine \ODM \MongoDB \Mapping \Driver \AnnotationDriver ;
4
9
5
- use Doctrine \Common \ClassLoader ,
6
- Doctrine \Common \Annotations \AnnotationReader ,
7
- Doctrine \ODM \MongoDB \Configuration ,
8
- Doctrine \ODM \MongoDB \Mapping \Driver \AnnotationDriver ,
9
- Doctrine \MongoDB \Connection ,
10
- Doctrine \ODM \MongoDB \DocumentManager ;
10
+ $ file = __DIR__ .'/../../vendor/autoload.php ' ;
11
+ if (!file_exists ($ file )) {
12
+ throw new RuntimeException ('Install dependencies to run the sandbox. ' );
13
+ }
11
14
12
- $ classLoader = new ClassLoader ('Doctrine\Common ' , __DIR__ . '/../../lib/vendor/doctrine-common/lib ' );
13
- $ classLoader ->register ();
14
-
15
- $ classLoader = new ClassLoader ('Doctrine\ODM\MongoDB ' , __DIR__ . '/../../lib ' );
16
- $ classLoader ->register ();
15
+ require_once $ file ;
17
16
18
- $ classLoader = new ClassLoader ('Doctrine\MongoDB ' , __DIR__ . '/../../lib/vendor/doctrine-mongodb/lib ' );
19
- $ classLoader ->register ();
20
-
21
- $ classLoader = new ClassLoader ('Symfony ' , __DIR__ . '/../../lib/vendor ' );
22
- $ classLoader ->register ();
17
+ AnnotationDriver::registerAnnotationClasses ();
23
18
24
19
$ classLoader = new ClassLoader ('Documents ' , __DIR__ );
25
20
$ classLoader ->register ();
34
29
35
30
$ config ->setDefaultDB ('doctrine_odm_sandbox ' );
36
31
37
- /*
38
- $config->setLoggerCallable(function(array $log) {
39
- print_r($log);
40
- });
41
- $config->setMetadataCacheImpl(new ApcCache());
42
- */
32
+ // $config->setLoggerCallable(function(array $log) { print_r($log); });
33
+ // $config->setMetadataCacheImpl(new ApcCache());
43
34
44
- $ reader = new AnnotationReader ();
45
- $ config ->setMetadataDriverImpl (new AnnotationDriver ($ reader , __DIR__ . '/Documents ' ));
35
+ $ config ->setMetadataDriverImpl (new AnnotationDriver (new AnnotationReader (), __DIR__ . '/Documents ' ));
46
36
47
- $ dm = DocumentManager::create (new Connection (), $ config );
37
+ $ dm = DocumentManager::create (new Connection (), $ config );
0 commit comments