From 0ed36810547fe8f7da7f757a1810b2cb917f39f2 Mon Sep 17 00:00:00 2001 From: qronald Date: Thu, 9 Feb 2017 17:06:17 -0400 Subject: [PATCH 1/6] HOR-2582 --- composer.json | 2 +- composer.lock | 202 ++++++++++++------- framework/src/Maveriks/Extension/Restler.php | 53 +++++ 3 files changed, 185 insertions(+), 72 deletions(-) diff --git a/composer.json b/composer.json index 47bc1a704..1f7672224 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "luracast/restler": "3.0.0-RC5", + "luracast/restler": "^3.0", "bshaffer/oauth2-server-php": "v1.0", "colosa/pmUI": "release/3.2-dev", "colosa/MichelangeloFE": "release/3.2-dev", diff --git a/composer.lock b/composer.lock index 66c0b5002..73fa44db5 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "e94e04e50eb74bdfd3dfedcb1af4e6d0", - "content-hash": "f0b89bffcea74fc73605464d3f0ca520", + "content-hash": "98d0285e56960342341a1a39337891ad", "packages": [ { "name": "bshaffer/oauth2-server-php", @@ -48,15 +47,15 @@ "oauth", "oauth2" ], - "time": "2013-08-12 16:35:58" + "time": "2013-08-12T16:35:58+00:00" }, { "name": "colosa/MichelangeloFE", - "version": "release/3.2-dev", + "version": "dev-release/3.2", "source": { "type": "git", "url": "git@bitbucket.org:colosa/michelangelofe.git", - "reference": "7e889f23a7e8397c052a4d9ae6331334b57c9d48" + "reference": "733277aef23c643b094c123043c3dbee975997a4" }, "require": { "colosa/pmui": "release/3.2-dev" @@ -67,15 +66,15 @@ "keywords": [ "js app ProcessMaker" ], - "time": "2016-03-09 20:18:44" + "time": "2017-01-30 20:34:14" }, { "name": "colosa/pmDynaform", - "version": "release/3.2-dev", + "version": "dev-release/3.2", "source": { "type": "git", "url": "git@bitbucket.org:colosa/pmdynaform.git", - "reference": "c2008027bd721ac42e4a7d98cc773f82ac25921e" + "reference": "e189423614abd5fce667645799e54781a596ba0b" }, "type": "library", "description": "JS Library to render ProcessMaker Dynaforms", @@ -83,15 +82,15 @@ "keywords": [ "js lib ProcessMaker Dynaforms" ], - "time": "2016-03-15 17:46:33" + "time": "2017-02-01 19:31:09" }, { "name": "colosa/pmUI", - "version": "release/3.2-dev", + "version": "dev-release/3.2", "source": { "type": "git", "url": "git@bitbucket.org:colosa/pmui.git", - "reference": "851ee86a1006df111ee8b281bf2b033cdbcc6f0b" + "reference": "462ab5f45a4cce1ca9920fcb854255f10abea1e1" }, "type": "library", "description": "JS UI Library", @@ -99,20 +98,20 @@ "keywords": [ "js lib ProcessMaker UI" ], - "time": "2016-02-26 21:41:50" + "time": "2017-01-30 20:34:06" }, { "name": "dapphp/securimage", - "version": "3.6.4", + "version": "3.6.5", "source": { "type": "git", "url": "https://github.com/dapphp/securimage.git", - "reference": "2ed50264ae5541fec8d8c79e4c9b6235a7cfd506" + "reference": "3f5a84fd80b1a35d58332896c944142713a7e802" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dapphp/securimage/zipball/2ed50264ae5541fec8d8c79e4c9b6235a7cfd506", - "reference": "2ed50264ae5541fec8d8c79e4c9b6235a7cfd506", + "url": "https://api.github.com/repos/dapphp/securimage/zipball/3f5a84fd80b1a35d58332896c944142713a7e802", + "reference": "3f5a84fd80b1a35d58332896c944142713a7e802", "shasum": "" }, "require": { @@ -130,7 +129,7 @@ "securimage.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "BSD" ], @@ -146,7 +145,7 @@ "captcha", "security" ], - "time": "2016-03-04 21:08:00" + "time": "2016-12-04T17:45:57+00:00" }, { "name": "google/apiclient", @@ -189,20 +188,20 @@ "keywords": [ "google" ], - "time": "2015-10-16 22:11:08" + "time": "2015-10-16T22:11:08+00:00" }, { "name": "luracast/restler", - "version": "3.0.0-RC5", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/Luracast/Restler.git", - "reference": "1dcf910c1e1fd1ea565a537b053a66971d818e42" + "reference": "581d8d6dc5d37f439765f89725a92f85e98f1826" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Luracast/Restler/zipball/1dcf910c1e1fd1ea565a537b053a66971d818e42", - "reference": "1dcf910c1e1fd1ea565a537b053a66971d818e42", + "url": "https://api.github.com/repos/Luracast/Restler/zipball/581d8d6dc5d37f439765f89725a92f85e98f1826", + "reference": "581d8d6dc5d37f439765f89725a92f85e98f1826", "shasum": "" }, "require": { @@ -268,7 +267,7 @@ "rest", "server" ], - "time": "2015-08-04 07:52:49" + "time": "2017-01-11T03:42:36+00:00" }, { "name": "monolog/monolog", @@ -346,7 +345,7 @@ "logging", "psr-3" ], - "time": "2016-04-12 18:29:35" + "time": "2016-04-12T18:29:35+00:00" }, { "name": "psr/log", @@ -384,7 +383,7 @@ "psr", "psr-3" ], - "time": "2012-12-21 11:40:51" + "time": "2012-12-21T11:40:51+00:00" } ], "packages-dev": [ @@ -453,7 +452,7 @@ "Behat", "Symfony2" ], - "time": "2013-06-06 10:46:48" + "time": "2013-06-06T10:46:48+00:00" }, { "name": "behat/gherkin", @@ -514,7 +513,7 @@ "Symfony2", "parser" ], - "time": "2013-03-02 10:38:40" + "time": "2013-03-02T10:38:40+00:00" }, { "name": "guzzle/guzzle", @@ -571,7 +570,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "release/3.2-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -607,26 +606,29 @@ "web service" ], "abandoned": "guzzlehttp/guzzle", - "time": "2013-01-28 00:07:40" + "time": "2013-01-28T00:07:40+00:00" }, { "name": "symfony/config", - "version": "v2.8.9", + "version": "v2.8.17", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "4275ef5b59f18959df0eee3991e9ca0cc208ffd4" + "reference": "747fa191136cf798409183c501435aa4c16184df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/4275ef5b59f18959df0eee3991e9ca0cc208ffd4", - "reference": "4275ef5b59f18959df0eee3991e9ca0cc208ffd4", + "url": "https://api.github.com/repos/symfony/config/zipball/747fa191136cf798409183c501435aa4c16184df", + "reference": "747fa191136cf798409183c501435aa4c16184df", "shasum": "" }, "require": { "php": ">=5.3.9", "symfony/filesystem": "~2.3|~3.0.0" }, + "require-dev": { + "symfony/yaml": "~2.7|~3.0.0" + }, "suggest": { "symfony/yaml": "To use the yaml reference dumper" }, @@ -660,24 +662,25 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-07-26 08:02:44" + "time": "2017-02-05T10:11:19+00:00" }, { "name": "symfony/console", - "version": "v2.8.9", + "version": "v2.8.17", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "36e62335caca8a6e909c5c5bac4a8128149911c9" + "reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/36e62335caca8a6e909c5c5bac4a8128149911c9", - "reference": "36e62335caca8a6e909c5c5bac4a8128149911c9", + "url": "https://api.github.com/repos/symfony/console/zipball/f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4", + "reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4", "shasum": "" }, "require": { "php": ">=5.3.9", + "symfony/debug": "~2.7,>=2.7.2|~3.0.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -720,20 +723,77 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:20:35" + "time": "2017-02-06T12:04:06+00:00" }, { - "name": "symfony/dependency-injection", - "version": "v2.8.9", + "name": "symfony/debug", + "version": "v3.0.9", "source": { "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "f2b5a00d176f6a201dc430375c0ef37706ea3d12" + "url": "https://github.com/symfony/debug.git", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/f2b5a00d176f6a201dc430375c0ef37706ea3d12", - "reference": "f2b5a00d176f6a201dc430375c0ef37706ea3d12", + "url": "https://api.github.com/repos/symfony/debug/zipball/697c527acd9ea1b2d3efac34d9806bf255278b0a", + "reference": "697c527acd9ea1b2d3efac34d9806bf255278b0a", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2016-07-30T07:22:48+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v2.8.17", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "1dfbf6a9e30113a9c4e482ab056e969c70c37a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1dfbf6a9e30113a9c4e482ab056e969c70c37a19", + "reference": "1dfbf6a9e30113a9c4e482ab056e969c70c37a19", "shasum": "" }, "require": { @@ -783,20 +843,20 @@ ], "description": "Symfony DependencyInjection Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:20:35" + "time": "2017-01-27T23:54:58+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.9", + "version": "v2.8.17", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8" + "reference": "74877977f90fb9c3e46378d5764217c55f32df34" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/889983a79a043dfda68f38c38b6dba092dd49cd8", - "reference": "889983a79a043dfda68f38c38b6dba092dd49cd8", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74877977f90fb9c3e46378d5764217c55f32df34", + "reference": "74877977f90fb9c3e46378d5764217c55f32df34", "shasum": "" }, "require": { @@ -843,7 +903,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-28 16:56:28" + "time": "2017-01-02T20:30:24+00:00" }, { "name": "symfony/filesystem", @@ -892,7 +952,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-07-20 05:43:46" + "time": "2016-07-20T05:43:46+00:00" }, { "name": "symfony/finder", @@ -942,20 +1002,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2016-05-13 14:58:35" + "time": "2016-05-13T14:58:35+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.2.0", + "version": "v1.3.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "dff51f72b0706335131b00a7f49606168c582594" + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/dff51f72b0706335131b00a7f49606168c582594", - "reference": "dff51f72b0706335131b00a7f49606168c582594", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", + "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", "shasum": "" }, "require": { @@ -967,7 +1027,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2-dev" + "dev-master": "1.3-dev" } }, "autoload": { @@ -978,7 +1038,7 @@ "bootstrap.php" ] }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1001,20 +1061,20 @@ "portable", "shim" ], - "time": "2016-05-18 14:26:46" + "time": "2016-11-14T01:06:16+00:00" }, { "name": "symfony/translation", - "version": "v2.8.9", + "version": "v2.8.17", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "32b0c824da6df065f43b0c458dc505940e98a7f1" + "reference": "c281ac2b484210bb95106bdb8ae8356e63277725" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/32b0c824da6df065f43b0c458dc505940e98a7f1", - "reference": "32b0c824da6df065f43b0c458dc505940e98a7f1", + "url": "https://api.github.com/repos/symfony/translation/zipball/c281ac2b484210bb95106bdb8ae8356e63277725", + "reference": "c281ac2b484210bb95106bdb8ae8356e63277725", "shasum": "" }, "require": { @@ -1065,20 +1125,20 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2016-07-30 07:20:35" + "time": "2017-01-21T16:59:38+00:00" }, { "name": "symfony/yaml", - "version": "v2.8.9", + "version": "v2.8.17", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "0ceab136f43ed9d3e97b3eea32a7855dc50c121d" + "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/0ceab136f43ed9d3e97b3eea32a7855dc50c121d", - "reference": "0ceab136f43ed9d3e97b3eea32a7855dc50c121d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153", + "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153", "shasum": "" }, "require": { @@ -1114,7 +1174,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-07-17 09:06:15" + "time": "2017-01-21T16:40:50+00:00" } ], "aliases": [], diff --git a/framework/src/Maveriks/Extension/Restler.php b/framework/src/Maveriks/Extension/Restler.php index e3672fa9d..14c27ea0f 100644 --- a/framework/src/Maveriks/Extension/Restler.php +++ b/framework/src/Maveriks/Extension/Restler.php @@ -141,4 +141,57 @@ class Restler extends \Luracast\Restler\Restler { return $this->workspace; } + + protected function call() + { + $this->dispatch('call'); + $o = & $this->apiMethodInfo; + $accessLevel = max(\Luracast\Restler\Defaults::$apiAccessLevel, + $o->accessLevel); + $object = \Luracast\Restler\Scope::get($o->className); + switch ($accessLevel) { + case 3 : //protected method + $reflectionMethod = new \ReflectionMethod( + $object, + $o->methodName + ); + $reflectionMethod->setAccessible(true); + $result = $reflectionMethod->invokeArgs( + $object, + $o->parameters + ); + break; + default : + $object = $this->reviewApiExtensions($o->className); + $result = call_user_func_array(array( + $object, + $o->methodName + ), $o->parameters); + } + $this->responseData = $result; + } + + public function reviewApiExtensions($className) + { + $object = \Luracast\Restler\Scope::get($className); + $classReflection = new \ReflectionClass($object); + $classShortName = $classReflection->getShortName(); + \G::LoadClass('pluginRegistry'); + $registry = \PMPluginRegistry::getSingleton(); + $pluginsActive = $registry->getEnabledPlugins(); + foreach ($pluginsActive as $name => $plugin) { + $pathExtensions = PATH_PLUGINS . $plugin . PATH_SEP . 'src' . PATH_SEP . 'Services' . PATH_SEP . 'Ext' . PATH_SEP; + $sFileExits = file_exists($pathExtensions . 'Ext' . $classShortName . '.php'); + if ($sFileExits) { + require_once($pathExtensions . 'Ext' . $classShortName . '.php'); + $classExtName = 'Ext' . $classShortName; + $newObjectExt = new $classExtName(); + if (is_subclass_of($newObjectExt, $className)) { + $object = $newObjectExt; + } + } + } + return $object; + } + } \ No newline at end of file From d8f160cfa07532af675ca92c26f0050dd8e19793 Mon Sep 17 00:00:00 2001 From: qronald Date: Tue, 14 Feb 2017 15:23:41 -0400 Subject: [PATCH 2/6] up observations --- framework/src/Maveriks/Extension/Restler.php | 19 +++++------ workflow/engine/classes/class.plugin.php | 11 ++++++ .../engine/classes/class.pluginRegistry.php | 34 +++++++++++++++++++ 3 files changed, 53 insertions(+), 11 deletions(-) diff --git a/framework/src/Maveriks/Extension/Restler.php b/framework/src/Maveriks/Extension/Restler.php index 14c27ea0f..a70f1e175 100644 --- a/framework/src/Maveriks/Extension/Restler.php +++ b/framework/src/Maveriks/Extension/Restler.php @@ -162,7 +162,7 @@ class Restler extends \Luracast\Restler\Restler ); break; default : - $object = $this->reviewApiExtensions($o->className); + $object = $this->reviewApiExtensions($object, $o->className); $result = call_user_func_array(array( $object, $o->methodName @@ -171,20 +171,17 @@ class Restler extends \Luracast\Restler\Restler $this->responseData = $result; } - public function reviewApiExtensions($className) + public function reviewApiExtensions($object, $className) { - $object = \Luracast\Restler\Scope::get($className); $classReflection = new \ReflectionClass($object); $classShortName = $classReflection->getShortName(); - \G::LoadClass('pluginRegistry'); $registry = \PMPluginRegistry::getSingleton(); - $pluginsActive = $registry->getEnabledPlugins(); - foreach ($pluginsActive as $name => $plugin) { - $pathExtensions = PATH_PLUGINS . $plugin . PATH_SEP . 'src' . PATH_SEP . 'Services' . PATH_SEP . 'Ext' . PATH_SEP; - $sFileExits = file_exists($pathExtensions . 'Ext' . $classShortName . '.php'); - if ($sFileExits) { - require_once($pathExtensions . 'Ext' . $classShortName . '.php'); - $classExtName = 'Ext' . $classShortName; + $pluginsApiExtend = $registry->getExtendsRestService($classShortName); + if ($pluginsApiExtend) { + $classFilePath = $pluginsApiExtend['filePath']; + if(file_exists($classFilePath)) { + require_once($classFilePath); + $classExtName = $pluginsApiExtend['classExtend']; $newObjectExt = new $classExtName(); if (is_subclass_of($newObjectExt, $className)) { $object = $newObjectExt; diff --git a/workflow/engine/classes/class.plugin.php b/workflow/engine/classes/class.plugin.php index e4e5c0d6c..a4da2dd9c 100644 --- a/workflow/engine/classes/class.plugin.php +++ b/workflow/engine/classes/class.plugin.php @@ -349,6 +349,17 @@ class PMPlugin $oPluginRegistry->registerRestService($this->sNamespace); } + /** + * Register a extend rest service and expose it + * + * @param string $className that is name class to extends + */ + function registerExtendsRestService($className) + { + $oPluginRegistry =& PMPluginRegistry::getSingleton(); + $oPluginRegistry->registerExtendsRestService($this->sNamespace, $className); + } + /** * Unregister a rest service * diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index cd7e0f46d..6cedb0d88 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -117,6 +117,8 @@ class PMPluginRegistry */ private $_restServices = array (); + private $_restExtendServices = array (); + private $_restServiceEnabled = array(); private static $instance = null; @@ -1458,6 +1460,38 @@ class PMPluginRegistry return true; } + /** + * Register a extend rest service class from a plugin to be served by processmaker + * + * @param string $sNamespace The namespace for the plugin + * @param string $className The service (api) class name + * @return bool + */ + public function registerExtendsRestService($sNamespace, $className) + { + $baseSrcPluginPath = PATH_PLUGINS . $sNamespace . PATH_SEP . "src"; + $apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP; + $classFile = $baseSrcPluginPath . $apiPath . 'Ext' . $className . '.php'; + if(file_exists($classFile)){ + $this->_restExtendServices[$className] = array( + "filePath" => $classFile, + "classParent" => $className, + "classExtend" => 'Ext' . $className + ); + } + return true; + } + + /** + * Get a extend rest service class from a plugin to be served by processmaker + * + * @param string $className The service (api) class name + * @return bool + */ + public function getExtendsRestService($className) + { + return isset($this->_restExtendServices[$className]) ? $this->_restExtendServices[$className] : array(); + } /** * Unregister a rest service class of a plugin * From a9a1bd149e05d42c167bb720cb67aab510815e95 Mon Sep 17 00:00:00 2001 From: qronald Date: Tue, 14 Feb 2017 15:49:14 -0400 Subject: [PATCH 3/6] remove extend in action disable --- workflow/engine/classes/class.plugin.php | 11 +++++++++++ workflow/engine/classes/class.pluginRegistry.php | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/workflow/engine/classes/class.plugin.php b/workflow/engine/classes/class.plugin.php index a4da2dd9c..675963b6e 100644 --- a/workflow/engine/classes/class.plugin.php +++ b/workflow/engine/classes/class.plugin.php @@ -360,6 +360,17 @@ class PMPlugin $oPluginRegistry->registerExtendsRestService($this->sNamespace, $className); } + /** + * Register a extend rest service and expose it + * + * @param string $className that is name class to extends + */ + function disableExtendsRestService($className) + { + $oPluginRegistry =& PMPluginRegistry::getSingleton(); + $oPluginRegistry->disableExtendsRestService($this->sNamespace, $className); + } + /** * Unregister a rest service * diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index 6cedb0d88..dec148504 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1492,6 +1492,20 @@ class PMPluginRegistry { return isset($this->_restExtendServices[$className]) ? $this->_restExtendServices[$className] : array(); } + + /** + * Remove a extend rest service class from a plugin to be served by processmaker + * + * @param string $className The service (api) class name + * @return bool + */ + public function disableExtendsRestService($sNamespace, $className) + { + if (isset($this->_restExtendServices[$className])) { + unset($this->_restExtendServices[$className]); + } + } + /** * Unregister a rest service class of a plugin * From d009cb462bf3cb9b19ab0bfd6ebb93228f3466b6 Mon Sep 17 00:00:00 2001 From: qronald Date: Tue, 14 Feb 2017 17:12:38 -0400 Subject: [PATCH 4/6] code style --- framework/src/Maveriks/Extension/Restler.php | 11 +++++------ workflow/engine/classes/class.pluginRegistry.php | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/framework/src/Maveriks/Extension/Restler.php b/framework/src/Maveriks/Extension/Restler.php index a70f1e175..c4769a9f3 100644 --- a/framework/src/Maveriks/Extension/Restler.php +++ b/framework/src/Maveriks/Extension/Restler.php @@ -145,10 +145,9 @@ class Restler extends \Luracast\Restler\Restler protected function call() { $this->dispatch('call'); - $o = & $this->apiMethodInfo; - $accessLevel = max(\Luracast\Restler\Defaults::$apiAccessLevel, - $o->accessLevel); - $object = \Luracast\Restler\Scope::get($o->className); + $o = &$this->apiMethodInfo; + $accessLevel = max(\Luracast\Restler\Defaults::$apiAccessLevel, $o->accessLevel); + $object = \Luracast\Restler\Scope::get($o->className); switch ($accessLevel) { case 3 : //protected method $reflectionMethod = new \ReflectionMethod( @@ -175,11 +174,11 @@ class Restler extends \Luracast\Restler\Restler { $classReflection = new \ReflectionClass($object); $classShortName = $classReflection->getShortName(); - $registry = \PMPluginRegistry::getSingleton(); + $registry = &\PMPluginRegistry::getSingleton(); $pluginsApiExtend = $registry->getExtendsRestService($classShortName); if ($pluginsApiExtend) { $classFilePath = $pluginsApiExtend['filePath']; - if(file_exists($classFilePath)) { + if (file_exists($classFilePath)) { require_once($classFilePath); $classExtName = $pluginsApiExtend['classExtend']; $newObjectExt = new $classExtName(); diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index dec148504..5d74be578 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1472,7 +1472,7 @@ class PMPluginRegistry $baseSrcPluginPath = PATH_PLUGINS . $sNamespace . PATH_SEP . "src"; $apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP; $classFile = $baseSrcPluginPath . $apiPath . 'Ext' . $className . '.php'; - if(file_exists($classFile)){ + if (file_exists($classFile)) { $this->_restExtendServices[$className] = array( "filePath" => $classFile, "classParent" => $className, From 1532d2af97a8414977ac7a6466f197f6f0e153c8 Mon Sep 17 00:00:00 2001 From: qronald Date: Tue, 14 Feb 2017 17:14:17 -0400 Subject: [PATCH 5/6] code style --- workflow/engine/classes/class.pluginRegistry.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index 5d74be578..96c72d3c4 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -1465,7 +1465,6 @@ class PMPluginRegistry * * @param string $sNamespace The namespace for the plugin * @param string $className The service (api) class name - * @return bool */ public function registerExtendsRestService($sNamespace, $className) { @@ -1479,7 +1478,6 @@ class PMPluginRegistry "classExtend" => 'Ext' . $className ); } - return true; } /** From 0188c56590908f08a8a15b1bbc1a6466dabaa8a8 Mon Sep 17 00:00:00 2001 From: qronald Date: Tue, 14 Feb 2017 17:46:17 -0400 Subject: [PATCH 6/6] check for plugins --- .../engine/classes/class.pluginRegistry.php | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/workflow/engine/classes/class.pluginRegistry.php b/workflow/engine/classes/class.pluginRegistry.php index 96c72d3c4..0061dcb78 100644 --- a/workflow/engine/classes/class.pluginRegistry.php +++ b/workflow/engine/classes/class.pluginRegistry.php @@ -429,6 +429,10 @@ class PMPluginRegistry if(sizeof( $this->_aOpenReassignCallback )){ unset( $this->_aOpenReassignCallback ); } + + if (sizeof($this->_restExtendServices)) { + $this->disableExtendsRestService($sNamespace); + } //unregistering javascripts from this plugin $this->unregisterJavascripts( $sNamespace ); //unregistering rest services from this plugin @@ -1472,7 +1476,7 @@ class PMPluginRegistry $apiPath = PATH_SEP . "Services" . PATH_SEP . "Ext" . PATH_SEP; $classFile = $baseSrcPluginPath . $apiPath . 'Ext' . $className . '.php'; if (file_exists($classFile)) { - $this->_restExtendServices[$className] = array( + $this->_restExtendServices[$sNamespace][$className] = array( "filePath" => $classFile, "classParent" => $className, "classExtend" => 'Ext' . $className @@ -1484,23 +1488,33 @@ class PMPluginRegistry * Get a extend rest service class from a plugin to be served by processmaker * * @param string $className The service (api) class name - * @return bool + * @return array */ public function getExtendsRestService($className) { - return isset($this->_restExtendServices[$className]) ? $this->_restExtendServices[$className] : array(); + $responseRestExtendService = array(); + foreach ($this->_restExtendServices as $sNamespace => $restExtendService) { + if (isset($restExtendService[$className])) { + $responseRestExtendService = $restExtendService[$className]; + break; + } + } + return $responseRestExtendService; } /** * Remove a extend rest service class from a plugin to be served by processmaker * + * @param string $sNamespace * @param string $className The service (api) class name * @return bool */ - public function disableExtendsRestService($sNamespace, $className) + public function disableExtendsRestService($sNamespace, $className = '') { - if (isset($this->_restExtendServices[$className])) { - unset($this->_restExtendServices[$className]); + if (isset($this->_restExtendServices[$sNamespace][$className]) && !empty($className)) { + unset($this->_restExtendServices[$sNamespace][$className]); + } elseif (empty($className)) { + unset($this->_restExtendServices[$sNamespace]); } }