Files
luos/workflow/engine/bin/rest-gen
Erik Amaru Ortiz ce21ee6454 PM Rest Feature: added plugins support & more improvements
from a plugin a rest class can be registered now:

on setup method add the following:
---
$this->registerRestService('Sample', [optional string: $path]);
--

and create the folder   PATH_PLUGIN . /your_plugin/classes/rest

next add a class with the flowing characteristics:

<?php

class Plugin_Services_Rest_Sample
{
    public function get()
    {
        return 'hello world';
    }
}

A class prefixed with Plugin_Services_Rest_
and add the corresponding methods for a Restler api
(http://luracast.com/products/restler/)

Finally on process maker will be exposed as:

via GET: http://127.0.0.1/rest/workflow/sample
2012-08-23 13:01:19 -04:00

59 lines
1.4 KiB
PHP

#!/usr/bin/env php
<?php
include '../../../gulliver/Core/Bootstrap.php';
include '../../../workflow/engine/PmBootstrap.php';
$config = array(
'path_trunk' => realpath('../../../')
);
$bootstrap = new PmBootstrap($config);
$bootstrap->registerClasses();
$bootstrap->configure();
if (! isset($argv[1])) {
$help = '$>' . $argv[0] . " [option]\n";
$help .= "Avalaibles options:\n";
$help .= " build-api : Build the PM Rest API.\n";
$help .= " gen-ini : Generates the rest config ini file.\n\n";
echo $help;
exit(0);
}
$restTool = new Service_Rest_RestTool();
try {
switch ($argv[1]) {
case 'build-api':
$restTool->buildApi();
break;
case 'gen-ini':
if (file_exists(PATH_CONFIG . '/rest-config.ini')) {
echo "The file 'rest-config.ini' already exits, overwrite (Y/n)? ";
$resp = trim(fgets(STDIN));
if (strtolower($resp) != 'y') {
echo "Skipped\n";
exit(0);
}
}
echo "Generating config ini file ... ";
$genFile = $restTool->buildConfigIni();
echo "DONE!\n";
echo "File generated: $genFile\n\n";
break;
default:
echo "Invalid option!\n";
break;
}
} catch (Exception $e) {
echo $e->getMessage() . "\n";
}