forked from doctrine/rest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.php
42 lines (32 loc) · 1.16 KB
/
server.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
use Doctrine\REST\Server\Server,
Doctrine\Common\ClassLoader;
require '/Users/jwage/Sites/doctrine2git/lib/Doctrine/Common/ClassLoader.php';
$classLoader = new ClassLoader('Doctrine\REST', __DIR__ . '/lib');
$classLoader->register();
$classLoader = new ClassLoader('Doctrine', '/Users/jwage/Sites/doctrine2git/lib');
$classLoader->register();
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$config->setProxyDir('/tmp');
$config->setProxyNamespace('Proxies');
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
$connectionOptions = array(
'driver' => 'pdo_mysql',
'dbname' => 'rest_test',
'user' => 'root'
);
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
$parser = new \Doctrine\REST\Server\PHPRequestParser();
$requestData = $parser->getRequestArray();
class TestAction
{
public function executeDBAL()
{
return array('test' => 'test');
}
}
$server = new \Doctrine\REST\Server\Server($em->getConnection(), $requestData);
$server->addEntityAction('user', 'test', 'TestAction');
$server->execute();
$server->getResponse()->send();