Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 42 lines (32 sloc) 1.187 kb
1725df8 Jonathan H. Wage Adding ability for server to go through ORM or DBAL by itself. Initial e...
jwage authored
1 <?php
2
3 use Doctrine\REST\Server\Server,
4 Doctrine\Common\ClassLoader;
5
6 require '/Users/jwage/Sites/doctrine2git/lib/Doctrine/Common/ClassLoader.php';
7
8 $classLoader = new ClassLoader('Doctrine\REST', __DIR__ . '/lib');
9 $classLoader->register();
10
11 $classLoader = new ClassLoader('Doctrine', '/Users/jwage/Sites/doctrine2git/lib');
12 $classLoader->register();
13
14 $config = new \Doctrine\ORM\Configuration();
15 $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
16 $config->setProxyDir('/tmp');
17 $config->setProxyNamespace('Proxies');
18 $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
19
20 $connectionOptions = array(
21 'driver' => 'pdo_mysql',
22 'dbname' => 'rest_test',
23 'user' => 'root'
24 );
25
26 $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
27
28 $parser = new \Doctrine\REST\Server\PHPRequestParser();
29 $requestData = $parser->getRequestArray();
30
31 class TestAction
32 {
33 public function executeDBAL()
34 {
35 return array('test' => 'test');
36 }
37 }
38
39 $server = new \Doctrine\REST\Server\Server($em->getConnection(), $requestData);
40 $server->addEntityAction('user', 'test', 'TestAction');
41 $server->execute();
42 $server->getResponse()->send();
Something went wrong with that request. Please try again.