Updating API Rest Dispatching, adding alias support from a conf api.ini file
This commit is contained in:
@@ -1077,173 +1077,103 @@ class Bootstrap
|
|||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method dispatch rest/api service
|
* This method dispatch rest/api service
|
||||||
*
|
*
|
||||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||||
* @param $uri
|
* @param $uri
|
||||||
* @param $config
|
* @param string $version
|
||||||
* @param string $apiClassesPath
|
|
||||||
* @internal param string $url Contains the url request
|
|
||||||
*/
|
*/
|
||||||
public function dispatchApiService($uri, $version = '1.0')
|
public function dispatchApiService($uri, $version = '1.0')
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* $servicesDir contains directory where Services Classes are allocated
|
||||||
|
*/
|
||||||
|
$servicesDir = PATH_CORE . 'src' . PATH_SEP . 'Services' . PATH_SEP;
|
||||||
|
/*
|
||||||
|
* $apiDir - contains directory to scan classes and add them to Restler
|
||||||
|
*/
|
||||||
|
$apiDir = $servicesDir . 'Api' . PATH_SEP;
|
||||||
|
/*
|
||||||
|
* $apiIniFile - contains file name of api ini configuration
|
||||||
|
*/
|
||||||
|
$apiIniFile = $servicesDir . PATH_SEP . 'api.ini';
|
||||||
|
/*
|
||||||
|
* $authenticationClass - contains the class name that validate the authentication for Restler
|
||||||
|
*/
|
||||||
|
$authenticationClass = 'Services\\Api\\OAuth2\\Server';
|
||||||
|
/*
|
||||||
|
* $pmOauthClientId - contains PM Local OAuth Id (Web Designer)
|
||||||
|
*/
|
||||||
|
$pmOauthClientId = 'x-pm-local-client';
|
||||||
|
|
||||||
$dataUri = explode('/', $uri);
|
// load Api class
|
||||||
array_shift($dataUri);
|
G::loadClass('api');
|
||||||
$reqClass = ucfirst(array_shift($dataUri));
|
|
||||||
|
|
||||||
$servicesDir = PATH_CORE . 'services' . PATH_SEP;
|
// Load Api ini file for Rest Service
|
||||||
$apiDir = $servicesDir . 'api' . PATH_SEP;
|
|
||||||
$classDir = $apiDir . 'processmaker' . PATH_SEP;
|
|
||||||
|
|
||||||
require_once PATH_CORE . "classes" . PATH_SEP . "class.api.php";
|
$apiIniConf = array();
|
||||||
|
|
||||||
|
if (file_exists($apiIniFile)) {
|
||||||
|
$apiIniConf = parse_ini_file($apiIniFile, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setting current workspace to Api class
|
||||||
\ProcessMaker\Api::setWorkspace(SYS_SYS);
|
\ProcessMaker\Api::setWorkspace(SYS_SYS);
|
||||||
//var_dump($apiDir . 'oauth2/views'); die;
|
// TODO remove this setting on the future, it is not needed, but if it is not present is throwing a warning
|
||||||
Luracast\Restler\Format\HtmlFormat::$viewPath = $servicesDir . 'oauth2/views';
|
Luracast\Restler\Format\HtmlFormat::$viewPath = $servicesDir . 'oauth2/views';
|
||||||
|
|
||||||
require_once $servicesDir . 'oauth2/Server.php';
|
// create a new Restler instance
|
||||||
|
|
||||||
$rest = new Luracast\Restler\Restler();
|
$rest = new Luracast\Restler\Restler();
|
||||||
|
// setting api version to Restler
|
||||||
$rest->setAPIVersion($version);
|
$rest->setAPIVersion($version);
|
||||||
|
// adding $authenticationClass to Restler
|
||||||
|
$rest->addAuthenticationClass($authenticationClass, '');
|
||||||
|
|
||||||
|
// Setting database connection source
|
||||||
$rest->addAuthenticationClass('Api\\OAuth2\\Server', '');
|
|
||||||
|
|
||||||
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
||||||
$port = empty($port) ? '' : ";port=$port";
|
$port = empty($port) ? '' : ";port=$port";
|
||||||
|
\Services\Api\OAuth2\Server::setDatabaseSource(DB_USER, DB_PASS, DB_ADAPTER.":host=$host;dbname=".DB_NAME.$port);
|
||||||
|
|
||||||
\Api\OAuth2\Server::setDatabaseSource(DB_USER, DB_PASS, DB_ADAPTER.":host=$host;dbname=".DB_NAME.$port);
|
// Setting default OAuth Client id, for local PM Web Designer
|
||||||
\Api\OAuth2\Server::setPmClientId('x-pm-local-client');
|
\Services\Api\OAuth2\Server::setPmClientId($pmOauthClientId);
|
||||||
|
|
||||||
$rest->setSupportedFormats('JsonFormat', 'XmlFormat'); //, 'HtmlFormat');
|
$rest->setSupportedFormats('JsonFormat', 'XmlFormat');
|
||||||
//$rest->setOverridingFormats('UploadFormat', 'JsonFormat', 'XmlFormat', 'HtmlFormat');
|
//$rest->setOverridingFormats('UploadFormat', 'JsonFormat', 'XmlFormat', 'HtmlFormat');
|
||||||
$rest->setOverridingFormats('HtmlFormat', 'JsonFormat', 'UploadFormat');
|
$rest->setOverridingFormats('HtmlFormat', 'JsonFormat', 'UploadFormat');
|
||||||
|
|
||||||
|
// Override $_SERVER['REQUEST_URI'] to Restler handles the current url correctly
|
||||||
$_SERVER['REQUEST_URI'] = $uri;
|
$_SERVER['REQUEST_URI'] = $uri;
|
||||||
|
|
||||||
$classFile = $classDir . 'Services_Api_ProcessMaker_' . $reqClass . '.php';
|
// scan all api directory to find api classes
|
||||||
$classFile2 = $classDir . DIRECTORY_SEPARATOR . $reqClass . '.php';
|
$classesList = Bootstrap::rglob('*', 0, $apiDir);
|
||||||
|
|
||||||
if (file_exists($classFile)) {
|
foreach ($classesList as $classFile) {
|
||||||
require_once $classFile;
|
if (pathinfo($classFile, PATHINFO_EXTENSION) === 'php') {
|
||||||
|
$namespace = '\\Services\\' . str_replace(
|
||||||
$rest->addAPIClass('Services_Api_ProcessMaker_' . $reqClass);
|
DIRECTORY_SEPARATOR,
|
||||||
} elseif (file_exists($classFile2)) {
|
'\\',
|
||||||
require_once $classFile2;
|
str_replace('.php', '', str_replace($servicesDir, '', $classFile))
|
||||||
|
);
|
||||||
$rest->addAPIClass("\\Services\\Api\\Processmaker\\" . $reqClass);
|
//var_dump($namespace);
|
||||||
} else {
|
$rest->addAPIClass($namespace);
|
||||||
$rest->handleError(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$rest->handle();
|
|
||||||
|
|
||||||
die;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///
|
|
||||||
// OLD CODE FROM HERE, we can get some interisting things there on the future
|
|
||||||
//
|
|
||||||
|
|
||||||
$rest->setSupportedFormats('JsonFormat', 'XmlFormat');
|
|
||||||
// getting all services class
|
|
||||||
$restClasses = array();
|
|
||||||
$restClassesList = Bootstrap::rglob('*', 0, PATH_CORE . 'services/');
|
|
||||||
foreach ($restClassesList as $classFile) {
|
|
||||||
if (substr($classFile, - 4) === '.php') {
|
|
||||||
$restClasses[str_replace('.php', '', basename($classFile))] = $classFile;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!empty($apiClassesPath)) {
|
|
||||||
$pluginRestClasses = array();
|
|
||||||
$restClassesList = Bootstrap::rglob('*', 0, $apiClassesPath . 'services/');
|
|
||||||
foreach ($restClassesList as $classFile) {
|
|
||||||
if (substr($classFile, - 4) === '.php') {
|
|
||||||
$pluginRestClasses[str_replace('.php', '', basename($classFile))] = $classFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$restClasses = array_merge($restClasses, $pluginRestClasses);
|
|
||||||
}
|
|
||||||
// hook to get rest api classes from plugins
|
|
||||||
if (class_exists('PMPluginRegistry')) {
|
|
||||||
$pluginRegistry = & PMPluginRegistry::getSingleton();
|
|
||||||
$pluginClasses = $pluginRegistry->getRegisteredRestClassFiles();
|
|
||||||
$restClasses = array_merge($restClasses, $pluginClasses);
|
|
||||||
}
|
|
||||||
foreach ($restClasses as $key => $classFile) {
|
|
||||||
if (!file_exists($classFile)) {
|
|
||||||
unset($restClasses[$key]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//load the file, and check if exist the class inside it.
|
|
||||||
require_once $classFile;
|
|
||||||
$namespace = 'Services_Rest_';
|
|
||||||
$className = str_replace('.php', '', basename($classFile));
|
|
||||||
|
|
||||||
// if the core class does not exists try resolve the for a plugin
|
// adding aliases for Restler
|
||||||
if (!class_exists($namespace . $className)) {
|
if (array_key_exists('alias', $apiIniConf)) {
|
||||||
$namespace = 'Plugin_Services_Rest_';
|
foreach ($apiIniConf['alias'] as $alias => $namespace) {
|
||||||
// Couldn't resolve the class name, just skipp it
|
$namespace = '\\' . ltrim($namespace, '\\');
|
||||||
if (!class_exists($namespace . $className)) {
|
var_dump("$namespace, $alias");
|
||||||
unset($restClasses[$key]);
|
$rest->addAPIClass($namespace, $alias);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// verify if there is an auth class implementing 'iAuthenticate'
|
|
||||||
$classNameAuth = $namespace . $className;
|
|
||||||
$reflClass = new ReflectionClass($classNameAuth);
|
|
||||||
// that wasn't from plugin
|
|
||||||
if ($reflClass->implementsInterface('iAuthenticate') && $namespace != 'Plugin_Services_Rest_') {
|
|
||||||
// auth class found, set as restler authentication class handler
|
|
||||||
$rest->addAuthenticationClass($classNameAuth);
|
|
||||||
} else {
|
|
||||||
// add api class
|
|
||||||
$rest->addAPIClass($classNameAuth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//end foreach rest class
|
//var_dump($apiIniConf);die;
|
||||||
// resolving the class for current request
|
|
||||||
$uriPart = explode('/', $uri);
|
//$rest->addAPIClass('\Services\Api\ProcessMaker\Test');
|
||||||
$requestedClass = '';
|
//$rest->addAPIClass('\Services\Api\ProcessMaker\Test2','test');
|
||||||
if (isset($uriPart[1])) {
|
|
||||||
$requestedClass = ucfirst($uriPart[1]);
|
|
||||||
}
|
|
||||||
if (class_exists('Services_Rest_' . $requestedClass)) {
|
|
||||||
$namespace = 'Services_Rest_';
|
|
||||||
} elseif (class_exists('Plugin_Services_Rest_' . $requestedClass)) {
|
|
||||||
$namespace = 'Plugin_Services_Rest_';
|
|
||||||
} else {
|
|
||||||
$namespace = '';
|
|
||||||
}
|
|
||||||
// end resolv.
|
|
||||||
// Send additional headers (if exists) configured on rest-config.ini
|
|
||||||
if (array_key_exists('HEADERS', $config)) {
|
|
||||||
foreach ($config['HEADERS'] as $name => $value) {
|
|
||||||
header("$name: $value");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// to handle a request with "OPTIONS" method
|
|
||||||
if (!empty($namespace) && $_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
|
|
||||||
$reflClass = new ReflectionClass($namespace . $requestedClass);
|
|
||||||
// if the rest class has not a "options" method
|
|
||||||
if (!$reflClass->hasMethod('options')) {
|
|
||||||
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, HEADERS');
|
|
||||||
header('Access-Control-Allow-Headers: authorization, content-type');
|
|
||||||
header("Access-Control-Allow-Credentials", "false");
|
|
||||||
header('Access-Control-Max-Age: 60');
|
|
||||||
exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// override global REQUEST_URI to pass to Restler library
|
|
||||||
$_SERVER['REQUEST_URI'] = '/' . strtolower($namespace) . ltrim($uri, '/');
|
|
||||||
// handle the rest request
|
|
||||||
$rest->handle();
|
$rest->handle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Created by JetBrains PhpStorm.
|
|
||||||
* User: erik
|
|
||||||
* Date: 8/21/13
|
|
||||||
* Time: 4:55 PM
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class Services_Api_ProcessMaker_Trigger
|
|
||||||
{
|
|
||||||
public function hello($to='world')
|
|
||||||
{
|
|
||||||
return array('success'=>true, "message"=>"Hello $to!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public function hi($name)
|
|
||||||
{
|
|
||||||
return "Hi $name";
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function secret()
|
|
||||||
{
|
|
||||||
return 'S E C R E T';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Binary file not shown.
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// determine where the sqlite DB will go
|
|
||||||
$dbfile = __DIR__.'/oauth.sqlite';
|
|
||||||
|
|
||||||
// remove sqlite file if it exists
|
|
||||||
if (file_exists($dbfile)) {
|
|
||||||
unlink($dbfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_writable(__DIR__)) {
|
|
||||||
// try to set permissions.
|
|
||||||
if (!@chmod(__DIR__, 0777)) {
|
|
||||||
throw new Exception("Unable to write to $dbfile");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rebuild the DB
|
|
||||||
$db = new PDO(sprintf('sqlite://%s', $dbfile));
|
|
||||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
$db->exec('CREATE TABLE oauth_clients (client_id TEXT, client_secret TEXT, redirect_uri TEXT)');
|
|
||||||
$db->exec('CREATE TABLE oauth_access_tokens (access_token TEXT, client_id TEXT, user_id TEXT, expires TIMESTAMP, scope TEXT)');
|
|
||||||
$db->exec('CREATE TABLE oauth_authorization_codes (authorization_code TEXT, client_id TEXT, user_id TEXT, redirect_uri TEXT, expires TIMESTAMP, scope TEXT)');
|
|
||||||
$db->exec('CREATE TABLE oauth_refresh_tokens (refresh_token TEXT, client_id TEXT, user_id TEXT, expires TIMESTAMP, scope TEXT)');
|
|
||||||
|
|
||||||
// add test data
|
|
||||||
$db->exec('INSERT INTO oauth_clients (client_id, client_secret) VALUES ("demoapp", "demopass")');
|
|
||||||
|
|
||||||
chmod($dbfile, 0777);
|
|
||||||
// $db->exec('INSERT INTO oauth_access_tokens (access_token, client_id) VALUES ("testtoken", "Some Client")');
|
|
||||||
// $db->exec('INSERT INTO oauth_authorization_codes (authorization_code, client_id) VALUES ("testcode", "Some Client")');
|
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
# views
|
|
||||||
### home for the restler view files
|
|
||||||
|
|
||||||
When HtmlFormat is used, it looks into this folder for view (template) files
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,158 +0,0 @@
|
|||||||
<?php
|
|
||||||
use Luracast\Restler\Restler;
|
|
||||||
use Luracast\Restler\Util;
|
|
||||||
|
|
||||||
$call_trace = '';
|
|
||||||
|
|
||||||
function exceptions()
|
|
||||||
{
|
|
||||||
global $call_trace;
|
|
||||||
$r = Util::$restler;
|
|
||||||
$source = $r->_exceptions;
|
|
||||||
if (count($source)) {
|
|
||||||
$source = end($source);
|
|
||||||
$traces = array();
|
|
||||||
do {
|
|
||||||
$traces += $source->getTrace();
|
|
||||||
} while ($source = $source->getPrevious());
|
|
||||||
$traces += debug_backtrace();
|
|
||||||
$call_trace
|
|
||||||
= parse_backtrace($traces, 0);
|
|
||||||
} else {
|
|
||||||
$call_trace
|
|
||||||
= parse_backtrace(debug_backtrace());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
exceptions();
|
|
||||||
|
|
||||||
function parse_backtrace($raw, $skip = 1)
|
|
||||||
{
|
|
||||||
$output = "";
|
|
||||||
foreach ($raw as $entry) {
|
|
||||||
if ($skip-- > 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//$output .= print_r($entry, true) . "\n";
|
|
||||||
$output .= "\nFile: " . $entry['file'] . " (Line: " . $entry['line'] . ")\n";
|
|
||||||
if (isset($entry['class']))
|
|
||||||
$output .= $entry['class'] . "::";
|
|
||||||
$output .= $entry['function']
|
|
||||||
. "( " . json_encode($entry['args']) . " )\n";
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//print_r(get_defined_vars());
|
|
||||||
//print_r($response);
|
|
||||||
$icon;
|
|
||||||
if ($success && isset($api)) {
|
|
||||||
$arguments = implode(', ', $api->parameters);
|
|
||||||
$icon = "<icon class=\"success\"></icon>";
|
|
||||||
$title = "{$api->className}::"
|
|
||||||
. "{$api->methodName}({$arguments})";
|
|
||||||
} else {
|
|
||||||
if (isset($response['error']['message'])) {
|
|
||||||
$icon = '<icon class="denied"></icon>';
|
|
||||||
$title = end(explode(':',$response['error']['message']));
|
|
||||||
} else {
|
|
||||||
$icon = '<icon class="warning"></icon>';
|
|
||||||
$title = 'No Matching Resource';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function render($data, $shadow=true)
|
|
||||||
{
|
|
||||||
$r = '';
|
|
||||||
if (empty($data))
|
|
||||||
return $r;
|
|
||||||
$r .= $shadow ? "<ul class=\"shadow\">\n": "<ul>\n";
|
|
||||||
if (is_array($data)) {
|
|
||||||
// field name
|
|
||||||
foreach ($data as $key => $value) {
|
|
||||||
$r .= '<li>';
|
|
||||||
$r .= is_numeric($key)
|
|
||||||
? "[<strong>$key</strong>] "
|
|
||||||
: "<strong>$key: </strong>";
|
|
||||||
$r .= '<span>';
|
|
||||||
if (is_array($value)) {
|
|
||||||
// recursive
|
|
||||||
$r .= render($value,false);
|
|
||||||
} else {
|
|
||||||
// value, with hyperlinked hyperlinks
|
|
||||||
if (is_bool($value)) {
|
|
||||||
$value = $value ? 'true' : 'false';
|
|
||||||
}
|
|
||||||
$value = htmlentities($value, ENT_COMPAT, 'UTF-8');
|
|
||||||
if (strpos($value, 'http://') === 0) {
|
|
||||||
$r .= '<a href="' . $value . '">' . $value . '</a>';
|
|
||||||
} else {
|
|
||||||
$r .= $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$r .= "</span></li>\n";
|
|
||||||
}
|
|
||||||
} elseif (is_bool($data)) {
|
|
||||||
$r .= '<li>' . ($data ? 'true' : 'false') . '</li>';
|
|
||||||
} else {
|
|
||||||
$r .= "<li><strong>$data</strong></li>";
|
|
||||||
}
|
|
||||||
$r .= "</ul>\n";
|
|
||||||
return $r;
|
|
||||||
}
|
|
||||||
$reqHeadersArr = array();
|
|
||||||
$requestHeaders = $_SERVER['REQUEST_METHOD'] . ' ' . $_SERVER['REQUEST_URI'] . ' ' . $_SERVER['SERVER_PROTOCOL'] . PHP_EOL;
|
|
||||||
foreach ($reqHeadersArr as $key => $value) {
|
|
||||||
if ($key == 'Host')
|
|
||||||
continue;
|
|
||||||
$requestHeaders .= "$key: $value" . PHP_EOL;
|
|
||||||
}
|
|
||||||
// $requestHeaders = $this->encode(apache_request_headers(), FALSE,
|
|
||||||
// FALSE);
|
|
||||||
$responseHeaders = implode(PHP_EOL, headers_list()).PHP_EOL.'Status: HTTP/1.1 ';
|
|
||||||
$responseHeaders .= Util::$restler->responseCode.' '.\Luracast\Restler\RestException::$codes[Util::$restler->responseCode];
|
|
||||||
|
|
||||||
?>
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title><?php echo $title?></title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
|
||||||
<style>
|
|
||||||
<?php include __DIR__.'/debug.css'; ?>
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="breadcrumbs-one">
|
|
||||||
<?php
|
|
||||||
if(Util::$restler->exception){
|
|
||||||
$stages = Util::$restler->exception->getStages();
|
|
||||||
$curStage = Util::$restler->exception->getStage();
|
|
||||||
foreach($stages['success'] as $stage){
|
|
||||||
echo "<a href=\"#\">$stage</a>";
|
|
||||||
}
|
|
||||||
foreach($stages['failure'] as $stage){
|
|
||||||
echo '<a href="#" class="failure">'
|
|
||||||
. $stage
|
|
||||||
. ($stage==$curStage ? ' <span class="state"/> ' : '')
|
|
||||||
. '</a>';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
foreach(Util::$restler->_events as $stage){
|
|
||||||
echo "<a href=\"#\">$stage</a>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</div>
|
|
||||||
<header>
|
|
||||||
<h1><?php echo $title ?></h1>
|
|
||||||
</header>
|
|
||||||
<article>
|
|
||||||
|
|
||||||
<h2>Response:<right><?php echo $icon;?></right></h2>
|
|
||||||
<pre class="header"><?php echo $responseHeaders ?></pre>
|
|
||||||
<?php echo render($response); ?>
|
|
||||||
<p>Restler v<?php echo Restler::VERSION?></p>
|
|
||||||
</article>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{% if googleAnalyticsCode is defined %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
var _gaq = _gaq || [];
|
|
||||||
_gaq.push(['_setAccount', '{{ googleAnalyticsCode }}']);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
||||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
||||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
||||||
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
<title></title>
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ basePath }}/css/demo.css">
|
|
||||||
<link rel="stylesheet" href="{{ basePath }}/css/shared.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<!--[if lt IE 7]>
|
|
||||||
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
{% include 'oauth2/analytics.twig' %}
|
|
||||||
{% include 'oauth2/github.twig' %}
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
<header role="banner">
|
|
||||||
{% block header %}
|
|
||||||
<hgroup>
|
|
||||||
<h1>Restler 3</h1>
|
|
||||||
<h2>OAuth 2 Demo App</h2>
|
|
||||||
</hgroup>
|
|
||||||
<nav class="primary">
|
|
||||||
<ul class="menu">
|
|
||||||
<li class="current">
|
|
||||||
<a href="http://luracast.com">Home</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="../">More</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="http://github.com/Luracast">Source</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="http://twitter.com/Luracast">Twitter</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="http://github.com/bshaffer">OAuth2</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{% endblock %}
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<article class="home" role="main">
|
|
||||||
<div role="main">
|
|
||||||
{% block content %}
|
|
||||||
{% endblock %}
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
{% extends "oauth2/client/base.twig" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h3>Authorization Failed!</h3>
|
|
||||||
<p>
|
|
||||||
It seems authorization has been denied for the following reasons:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
{% if response.error.error_description %}
|
|
||||||
{{ response.error.error_description }}
|
|
||||||
{# optional "error_uri" param #}
|
|
||||||
{% if response.error_uri %}
|
|
||||||
(<a href="{{ response.error.error_uri }}">more information</a>)
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
|
||||||
<em>authorization server did not supply an error message</em>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
{% extends "oauth2/client/base.twig" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h3>Authorization Error</h3>
|
|
||||||
<p>
|
|
||||||
{{ response.error.error_description }}
|
|
||||||
{% if response.error.error_uri is defined %}
|
|
||||||
(<a href="{{response.error.error_uri}}">more information</a>)
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
<a href="{{ basePath }}">back</a>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
{% extends "oauth2/client/base.twig" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h3>Authorization Granted!</h3>
|
|
||||||
<pre><code> Access Token: {{ response.token }} </code></pre>
|
|
||||||
<p>
|
|
||||||
Here are your friends:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
{% for friend in response.friends %}
|
|
||||||
<li>{{ friend }}</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
<div class="help"><em>The API call can be seen at <a href="{{ response.endpoint }}" target="_blank">{{ response.endpoint }}</a></em></div>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{% extends "oauth2/client/base.twig" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<h3>Demo App</h3>
|
|
||||||
<p>
|
|
||||||
We would like to use your information in order to integrate with your friends,
|
|
||||||
use your personal information for nefarious purposes, and to make your life better somehow.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Click below to integrate with that service you belong to:
|
|
||||||
</p>
|
|
||||||
<a class="button" href="{{ response.authorize_url }}?response_type=code&client_id=demoapp&redirect_uri={{ response.authorize_redirect_url|url_encode() }}">Authorize</a>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<a href="https://github.com/Luracast/Restler"><img style="position: absolute; top: 0; right: 0; border: 0;z-index:100000" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
<p>
|
|
||||||
<strong><?php echo $response['client_details']['CLIENT_NAME']?></strong> would like to access the following data:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<?php foreach($response['requestedScope'] as $scope) {?>
|
|
||||||
<li><?php echo $response['supportedScope'][$scope] ?></li>
|
|
||||||
<?php } ?>
|
|
||||||
</ul>
|
|
||||||
<p>It will use this data to:</p>
|
|
||||||
<ul>
|
|
||||||
<li>integrate with ProcessMaker</li>
|
|
||||||
<li>make your life better</li>
|
|
||||||
<li>miscellaneous nefarious purposes</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="authorize_options">
|
|
||||||
<li>
|
|
||||||
<form action="/api/1.0/workflow/authorize?<?php echo $response['query_string']?>" method="post">
|
|
||||||
<input type="submit" class="button authorize" value="Yes, I Authorize This Request"/>
|
|
||||||
<input type="hidden" name="authorize" value="1"/>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
<li class="cancel">
|
|
||||||
<form id="cancel" action="/api/1.0/workflow/authorize?<?php echo $response['query_string']?>" method="post">
|
|
||||||
<a href="#" onclick="document.getElementById('cancel').submit()">cancel</a>
|
|
||||||
<input type="hidden" name="authorize" value="0"/>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
{% extends "oauth2/server/base.twig" %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
<p>
|
|
||||||
<strong>Demo App</strong> would like to access the following data:
|
|
||||||
</p>
|
|
||||||
<ul>
|
|
||||||
<li>friends</li>
|
|
||||||
<li>memories</li>
|
|
||||||
<li>hopes, dreams, passions, etc.</li>
|
|
||||||
<li>sock drawer</li>
|
|
||||||
</ul>
|
|
||||||
<p>It will use this data to:</p>
|
|
||||||
<ul>
|
|
||||||
<li>integrate with friends</li>
|
|
||||||
<li>make your life better</li>
|
|
||||||
<li>miscellaneous nefarious purposes</li>
|
|
||||||
</ul>
|
|
||||||
<ul class="authorize_options">
|
|
||||||
<li>
|
|
||||||
<form action="{{ 'authorize' ~ '?' ~ response.queryString }}" method="post">
|
|
||||||
<input type="submit" class="button authorize"
|
|
||||||
value="Yes, I Authorize This Request"/>
|
|
||||||
<input type="hidden" name="authorize" value="1"/>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
<li class="cancel">
|
|
||||||
<form id="cancel" action="{{ 'authorize' ~ '?' ~ response.queryString }}"
|
|
||||||
method="post">
|
|
||||||
<a href="#"
|
|
||||||
onclick="document.getElementById('cancel').submit()">cancel</a>
|
|
||||||
<input type="hidden" name="authorize" value="0"/>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
{% endblock %}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
|
||||||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
|
||||||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
|
||||||
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
||||||
<title></title>
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="viewport" content="width=device-width">
|
|
||||||
|
|
||||||
<link rel="stylesheet" href="{{ basePath }}/css/lockdin.css">
|
|
||||||
<link rel="stylesheet" href="{{ basePath }}/css/shared.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<!--[if lt IE 7]>
|
|
||||||
<p class="chromeframe">You are using an outdated browser. <a href="http://browsehappy.com/">Upgrade your browser today</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to better experience this site.</p>
|
|
||||||
<![endif]-->
|
|
||||||
|
|
||||||
{% include 'oauth2/analytics.twig' %}
|
|
||||||
{% include 'oauth2/github.twig' %}
|
|
||||||
{% include 'oauth2/server/header.html' %}
|
|
||||||
|
|
||||||
<div id="container">
|
|
||||||
<article class="home" role="main">
|
|
||||||
<div id="content" role="main">
|
|
||||||
{% block content %}
|
|
||||||
{% endblock %}
|
|
||||||
</div>
|
|
||||||
</article>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
<div id="header" class="global-nav member">
|
|
||||||
<div class="top-nav">
|
|
||||||
<div class="wrapper">
|
|
||||||
|
|
||||||
<ul class="util" role="navigation">
|
|
||||||
<li class="tab username-cont">
|
|
||||||
<a href="#" class="tab-name username">You <span class="menu-indicator"></span></a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2 class="logo"><a href="#" title="Home">Lock'd <span>in</span></a></h2>
|
|
||||||
|
|
||||||
<div class="account">
|
|
||||||
<span>You'll never get your data back</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="bottom-nav">
|
|
||||||
<div class="wrapper">
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<ul class="nav" role="navigation">
|
|
||||||
<li id="nav-primary-home" class="tab selected"><a href="#" class="tab-name"><span>Home</span></a></li>
|
|
||||||
<li id="nav-primary-profile" class="tab"><a href="#" class="tab-name"><span>Profile</span></a></li>
|
|
||||||
<li id="nav-primary-contacts" class="tab "><a href="/#" class="tab-name"><span>Contacts</span></a></li>
|
|
||||||
<li id="nav-primary-groups" class="tab "><a href="#" class="tab-name"><span>Groups</span></a></li>
|
|
||||||
<li id="nav-primary-jobs" class="tab "><a href="#" class="tab-name"><span>Jobs</span></a></li>
|
|
||||||
<li id="nav-primary-inbox-links" class="tab "><a href="#" class="tab-name"><span>Inbox</span></a></li>
|
|
||||||
<li id="nav-primary-company" class="tab"><a href="#" class="tab-name"><span>Companies</span></a></li>
|
|
||||||
<li id="nav-primary-news" class="tab"><a href="#" class="tab-name"><span>News</span></a></li>
|
|
||||||
<li id="nav-primary-more" class="tab "><a href="#" class="tab-name"><span>More</span></a></li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<form id="global-search" role="search" action="/search/fpsearch" method="get" accept-charset="UTF-8" name="commonSearch" class="global-search ">
|
|
||||||
<fieldset>
|
|
||||||
<div class="search-scope styled-dropdown" id="yui-gen1"><span class="label"> <span> People </span> </span></div>
|
|
||||||
<span class="search-box-container">
|
|
||||||
<span id="search-autocomplete-container" title="Tip: You can also search by keyword, company, school..." class="/typeahead">
|
|
||||||
<label for="main-search-box" class="ghost" id="yui-gen2" style="display: none; ">Search...</label>
|
|
||||||
<input name="keywords" id="main-search-box" class="search-term yui-ac-input" type="text" value="" autocomplete="off" placeholder="Search...">
|
|
||||||
<span id="search-typeahead-container"></span>
|
|
||||||
</span>
|
|
||||||
<input name="search" value="Search" class="search-go" type="submit">
|
|
||||||
</span>
|
|
||||||
</fieldset>
|
|
||||||
<a id="search-link" class="search-link" href="/search?trk=advsrch">Advanced</a>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
echo $_SESSION['ERIK'];
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<?php
|
|
||||||
echo $basePath;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Showing {{basePath}}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
Showing "{{ basePath }}"
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
<?php return <<<TEMPLATE
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
||||||
<base href="{$basePath}/"/>
|
|
||||||
<title>{$title}</title>
|
|
||||||
|
|
||||||
<!-- Including the jQuery UI Human Theme -->
|
|
||||||
<link rel="stylesheet"
|
|
||||||
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/themes/humanity/jquery-ui.css"
|
|
||||||
type="text/css" media="all"/>
|
|
||||||
|
|
||||||
<!-- Our own stylesheet -->
|
|
||||||
<link rel="stylesheet" type="text/css" href="styles.css"/>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>{$title}</h1>
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
<a href="../">Go
|
|
||||||
Back to the Examples »</a></h2>
|
|
||||||
|
|
||||||
<div id="main">
|
|
||||||
|
|
||||||
<ul class="todoList">
|
|
||||||
{$_('include','todo/list.php','response')}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<a id="addButton" class="green-button" href="#">Add a Task</a>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- This div is used as the base for the confirmation jQuery UI POPUP. Hidden by CSS. -->
|
|
||||||
<div id="dialog-confirm" title="Delete TODO Item?">Are you sure you want to
|
|
||||||
delete this task?
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<p class="note">{$description}</p>
|
|
||||||
|
|
||||||
<!-- Including our scripts -->
|
|
||||||
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
|
|
||||||
<script type="text/javascript"
|
|
||||||
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"></script>
|
|
||||||
<script type="text/javascript" src="script.js"></script>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
TEMPLATE;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php return <<<TEMPLATE
|
|
||||||
<li id="todo-{$id}" class="todo">
|
|
||||||
<div class="text">{$text}</div>
|
|
||||||
|
|
||||||
<div class="actions">
|
|
||||||
<a href="#" class="edit">Edit</a>
|
|
||||||
<a href="#" class="delete">Delete</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
|
|
||||||
TEMPLATE;
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Api\OAuth2;
|
namespace Services\Api\OAuth2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple PmPDO storage for all storage types
|
* Simple PmPDO storage for all storage types
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Api\OAuth2;
|
namespace Services\Api\OAuth2;
|
||||||
|
|
||||||
use Luracast\Restler\iAuthenticate;
|
use Luracast\Restler\iAuthenticate;
|
||||||
|
|
||||||
116
workflow/engine/src/Services/Api/ProcessMaker/Test.php
Normal file
116
workflow/engine/src/Services/Api/ProcessMaker/Test.php
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
<?php
|
||||||
|
namespace Services\Api\ProcessMaker;
|
||||||
|
|
||||||
|
use \ProcessMaker\Api;
|
||||||
|
use \Luracast\Restler\RestException;
|
||||||
|
|
||||||
|
class Test extends Api
|
||||||
|
{
|
||||||
|
protected $data = array();
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
if (! isset($_SESSION['__rest_tmp__'])) {
|
||||||
|
$this->data[1] = array(
|
||||||
|
'id' => '1',
|
||||||
|
'name' => 'John',
|
||||||
|
'lastname' => 'Doe',
|
||||||
|
'age' => '27'
|
||||||
|
);
|
||||||
|
$this->saveData();
|
||||||
|
} else {
|
||||||
|
$this->loadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function index()
|
||||||
|
{
|
||||||
|
return array_values($this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get($id)
|
||||||
|
{
|
||||||
|
if (array_key_exists($id, $this->data)) {
|
||||||
|
return $this->data[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new RestException(400, "Record not found. Record with id: $id does not exist!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function post($request_data = NULL)
|
||||||
|
{
|
||||||
|
$id = count($this->data) + 1;
|
||||||
|
$this->data[$id] = array(
|
||||||
|
'id' => $id,
|
||||||
|
'name' => '',
|
||||||
|
'lastname' => '',
|
||||||
|
'age' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
if (array_key_exists('name', $request_data)) {
|
||||||
|
$this->data[$id]['name'] = $request_data['name'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('lastname', $request_data)) {
|
||||||
|
$this->data[$id]['lastname'] = $request_data['lastname'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('age', $request_data)) {
|
||||||
|
$this->data[$id]['age'] = $request_data['age'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->saveData();
|
||||||
|
|
||||||
|
return $this->data[$id];
|
||||||
|
}
|
||||||
|
|
||||||
|
function put($id, $request_data = NULL)
|
||||||
|
{
|
||||||
|
if (array_key_exists($id, $this->data)) {
|
||||||
|
if (array_key_exists('name', $request_data)) {
|
||||||
|
$this->data[$id] = $request_data['name'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('lastname', $request_data)) {
|
||||||
|
$this->data[$id] = $request_data['lastname'];
|
||||||
|
}
|
||||||
|
if (array_key_exists('age', $request_data)) {
|
||||||
|
$this->data[$id] = $request_data['age'];
|
||||||
|
}
|
||||||
|
$this->saveData();
|
||||||
|
|
||||||
|
return $this->data[$id];
|
||||||
|
} else {
|
||||||
|
throw new RestException(400, "Record not found. Record with id: $id does not exist!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id)
|
||||||
|
{
|
||||||
|
if (array_key_exists($id, $this->data)) {
|
||||||
|
$row = $this->data[$id];
|
||||||
|
unset($this->data[$id]);
|
||||||
|
$this->saveData();
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
} else {
|
||||||
|
throw new RestException(400, "Record not found. Record with id: $id does not exist!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url GET /testing/sample/:param
|
||||||
|
*/
|
||||||
|
function doOverride($param)
|
||||||
|
{
|
||||||
|
return $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Private methods */
|
||||||
|
private function loadData()
|
||||||
|
{
|
||||||
|
$this->data = $_SESSION['__rest_tmp__'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function saveData()
|
||||||
|
{
|
||||||
|
$_SESSION['__rest_tmp__'] = $this->data;
|
||||||
|
}
|
||||||
|
}
|
||||||
30
workflow/engine/src/Services/Api/ProcessMaker/Test2.php
Normal file
30
workflow/engine/src/Services/Api/ProcessMaker/Test2.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
namespace Services\Api\ProcessMaker;
|
||||||
|
|
||||||
|
use \ProcessMaker\Api;
|
||||||
|
use \Luracast\Restler\RestException;
|
||||||
|
|
||||||
|
class Test2 extends Api
|
||||||
|
{
|
||||||
|
|
||||||
|
function hello()
|
||||||
|
{
|
||||||
|
return 'GEEET ALL';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url GET /getHello
|
||||||
|
*/
|
||||||
|
function helloworld($param = '')
|
||||||
|
{
|
||||||
|
return 'Greetings, from a overridden url ' . $param;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @url GET /sample/other/large/:name
|
||||||
|
*/
|
||||||
|
function sampleOther($name)
|
||||||
|
{
|
||||||
|
return 'Name: ' . $name;
|
||||||
|
}
|
||||||
|
}
|
||||||
6
workflow/engine/src/Services/api.ini
Normal file
6
workflow/engine/src/Services/api.ini
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
;
|
||||||
|
; API Rest Configuration File
|
||||||
|
;
|
||||||
|
|
||||||
|
[alias]
|
||||||
|
test = "Services\Api\ProcessMaker\Test2"
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user