Skip to content

Commit 18dd440

Browse files
committed
Update tools/sandbox for Composer vendors
1 parent 582a0ac commit 18dd440

File tree

10 files changed

+36
-43
lines changed

10 files changed

+36
-43
lines changed

tools/sandbox/Documents/Account.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,4 @@ public function __toString()
3737
{
3838
return $this->name;
3939
}
40-
}
40+
}

tools/sandbox/Documents/Address.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ public function setPostalCode($postalCode)
5858
{
5959
$this->postalCode = $postalCode;
6060
}
61-
}
61+
}

tools/sandbox/Documents/Phonenumber.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ public function __toString()
2929
{
3030
return $this->phonenumber;
3131
}
32-
}
32+
}

tools/sandbox/Documents/User.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ public function __toString()
8484
{
8585
return $this->username;
8686
}
87-
}
87+
}

tools/sandbox/UserRepository.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
*/
1313
class serRepository extends DocumentRepository
1414
{
15-
}
15+
}

tools/sandbox/cli-config.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

3+
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper;
4+
35
require_once 'config.php';
46

5-
$helpers = array(
6-
'dm' => new Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper($dm),
7-
);
7+
$helpers = array(new DocumentManagerHelper($dm));

tools/sandbox/config.php

+16-26
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
<?php
22

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;
49

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+
}
1114

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;
1716

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();
2318

2419
$classLoader = new ClassLoader('Documents', __DIR__);
2520
$classLoader->register();
@@ -34,14 +29,9 @@
3429

3530
$config->setDefaultDB('doctrine_odm_sandbox');
3631

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());
4334

44-
$reader = new AnnotationReader();
45-
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
35+
$config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), __DIR__ . '/Documents'));
4636

47-
$dm = DocumentManager::create(new Connection(), $config);
37+
$dm = DocumentManager::create(new Connection(), $config);

tools/sandbox/index.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
require_once 'config.php';
44

5-
use Documents\User,
6-
Documents\Address,
7-
Documents\Phonenumber,
8-
Documents\Account;
5+
use Documents\User;
6+
use Documents\Address;
7+
use Documents\Phonenumber;
8+
use Documents\Account;
99

10-
// Your code here...
10+
// Your code here...

tools/sandbox/mongodb

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env php
22
<?php
33

4-
include('mongodb.php');
4+
include('mongodb.php');

tools/sandbox/mongodb.php

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?php
22

3+
use Symfony\Component\Console\Application;
4+
use Symfony\Component\Console\Helper\HelperSet;
5+
36
require __DIR__ . DIRECTORY_SEPARATOR . 'cli-config.php';
47

5-
$helperSet = isset($helperSet) ? $helperSet : new \Symfony\Component\Console\Helper\HelperSet();
8+
$helperSet = isset($helperSet) ? $helperSet : new HelperSet();
69
foreach ($helpers as $name => $helper) {
710
$helperSet->set($helper, $name);
811
}
912

10-
$cli = new \Symfony\Component\Console\Application('Doctrine ODM MongoDB Command Line Interface', Doctrine\ODM\MongoDB\Version::VERSION);
13+
$cli = new Application('Doctrine ODM MongoDB Command Line Interface', Doctrine\ODM\MongoDB\Version::VERSION);
1114
$cli->setCatchExceptions(true);
1215
$cli->setHelperSet($helperSet);
1316
$cli->addCommands(array(
@@ -19,4 +22,4 @@
1922
new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\CreateCommand(),
2023
new \Doctrine\ODM\MongoDB\Tools\Console\Command\Schema\DropCommand(),
2124
));
22-
$cli->run();
25+
$cli->run();

0 commit comments

Comments
 (0)