-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
30 lines (27 loc) · 1.05 KB
/
index.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
<?php
// allow any access as it is read only
header("Access-Control-Allow-Origin: *");
$MODX_CORE_DIRECTORY = dirname(__FILE__) . '/../modx-git/core/';
// Boot up MODX
require_once $MODX_CORE_DIRECTORY . 'config/config.inc.php';
require_once $MODX_CORE_DIRECTORY . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('web');
$modx->getService('error','error.modError', '', '');
// Boot up any service classes or packages (models) you will need
$modx->addPackage('myPage', $MODX_CORE_DIRECTORY . 'model/');
// Load the modRestService class and pass it some basic configuration
$rest = $modx->getService('rest', 'rest.modRestService', '', array(
'basePath' => dirname(__FILE__) . '/Controllers/',
'controllerClassSeparator' => '',
'controllerClassPrefix' => 'MyController',
'xmlRootNode' => 'response',
));
// Prepare the request
$rest->prepare();
// Make sure the user has the proper permissions, send the user a 401 error if not
if (!$rest->checkPermissions()) {
$rest->sendUnauthorized(true);
}
// Run the request
$rest->process();