Fix save feature via REST services

This commit is contained in:
Gustavo Cruz
2015-02-27 17:37:12 -04:00
parent d20754a0b6
commit 92245527cf
5 changed files with 77 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Features; namespace \Features\ActionsByEmail;
/** /**
* Description of ActionsByEmailFeature * Description of ActionsByEmailFeature
* *

View File

@@ -0,0 +1,21 @@
<?php
namespace Features\ActionsByEmail;
/**
* Description of ActionsByEmailService
*
*/
class ActionsByEmailService
{
public function saveConfiguration($params)
{
switch ($params['type']) {
case 'configuration':
require_once 'classes/model/AbeConfiguration.php';
$abeConfigurationInstance = new \AbeConfiguration();
$abeConfigurationInstance->createOrUpdate($params['fields']);
break;
default:
break;
}
}
}

View File

@@ -55,20 +55,17 @@ class ActivityConfigurationView
'type' => 'dropdown', 'type' => 'dropdown',
'options' => array( 'options' => array(
array( array(
'name' => '', 'label' => '- None -',
'value' => '', 'value' => '',
'text' => '- None -',
'type' => 'default' 'type' => 'default'
), ),
array( array(
'name' => 'LINK', 'label' => 'Link to fill a form',
'value' => 'LINK', 'value' => 'LINK',
'text' => 'Link to fill a form',
), ),
array( array(
'name' => 'FIELD', 'label' => 'Use a field to generate actions links',
'value' => 'FIELD', 'value' => 'FIELD',
'text' => 'Use a field to generate actions links',
) )
) )
), ),
@@ -84,9 +81,8 @@ class ActivityConfigurationView
), ),
'options' => array( 'options' => array(
array( array(
'name' => '',
'value' => '', 'value' => '',
'text' => '- Select a Template -', 'label' => '- Select a Template -',
'type' => 'default' 'type' => 'default'
) )
) )
@@ -118,9 +114,8 @@ class ActivityConfigurationView
), ),
'options' => array( 'options' => array(
array( array(
'name' => '',
'value' => '', 'value' => '',
'text' => '- Select a Dynaform -', 'label' => '- Select a Dynaform -',
'type' => 'default' 'type' => 'default'
) )
), ),
@@ -137,9 +132,8 @@ class ActivityConfigurationView
'type' => 'dropdown', 'type' => 'dropdown',
'options' => array( 'options' => array(
array( array(
'name' => '',
'value' => '', 'value' => '',
'text' => '- Send to the email of the assigned user to the task -', 'label' => '- Send to the email of the assigned user to the task -',
'type' => 'default' 'type' => 'default'
) )
), ),
@@ -165,9 +159,8 @@ class ActivityConfigurationView
'type' => 'dropdown', 'type' => 'dropdown',
'options' => array( 'options' => array(
array( array(
'name' => '',
'value' => '', 'value' => '',
'text' => '- Select a Field -', 'label' => '- Select a Field -',
'type' => 'default' 'type' => 'default'
) )
), ),
@@ -186,10 +179,15 @@ class ActivityConfigurationView
), ),
array( array(
'name' => 'ABE_CASE_NOTE_IN_RESPONSE', 'name' => 'ABE_CASE_NOTE_IN_RESPONSE',
'value' => true, 'type' => 'checkbox',
'default' => false, 'labelVisible' => false,
'label' => 'Register a Case Note when the recipient submits the Response', 'options' => array(
'type' => 'checkbox' array(
'id' => 'formTimingControlOption',
'label' => 'Register a Case Note when the recipient submits the Response',
'value' => '1'
)
)
), ),
// array( // array(
// 'name' => 'APPLY_CHANGES', // 'name' => 'APPLY_CHANGES',

View File

@@ -1,5 +1,4 @@
<?php <?php
namespace Features; namespace Features;
/** /**
* Description of FeatureManager * Description of FeatureManager
@@ -14,20 +13,51 @@ class FeaturesHandler
} }
} }
public function retrieveConfiguration($params)
{
foreach ($this->getFeatureList() as $feature) {
}
}
public function saveConfiguration($type, $configurationForms)
{
foreach ($configurationForms as $feature => $form) {
$service = $this->getFeatureService(array('name' => $feature));
$service->saveConfiguration($form);
}
return true;
}
public function getFeatureList() public function getFeatureList()
{ {
$invalidFolders = array('ViewContainers'); $invalidFolders = array('ViewContainers');
$featuresFolders = glob(PATH_FEATURES.'/*', GLOB_ONLYDIR); $featuresFolders = glob(PATH_FEATURES.'/*', GLOB_ONLYDIR);
$features = array(); $features = array();
foreach ($featuresFolders as $directory) { foreach ($featuresFolders as $directory) {
$feature = new stdClass(); $feature = new \stdClass();
if (in_array($directory, $invalidFolders)) { $featureName = basename($directory);
if (in_array($featureName, $invalidFolders)) {
continue; continue;
} }
$feature->path = PATH_FEATURES . PATH_SEP . $directory; $feature->path = PATH_FEATURES . $featureName;
$feature->name = $directory; $feature->name = $featureName;
$features[] = $feature; $features[] = $feature;
} }
return $features; return $features;
} }
public function getFeatureService($params)
{
$features = $this->getFeatureList();
foreach ($features as $feature) {
if ($params['name'] == $feature->name) {
$className = $feature->name . 'Service';
$namespace = '\\Features\\' . $feature->name . '\\' . $className;
require_once $feature->path . PATH_SEP . $className . '.php';
$service = new $namespace();
return $service;
}
}
}
} }

View File

@@ -106,6 +106,10 @@ class Activity extends Api
} }
$task = new \ProcessMaker\BusinessModel\Task(); $task = new \ProcessMaker\BusinessModel\Task();
$properties = $task->updateProperties($prj_uid, $act_uid, $request_data); $properties = $task->updateProperties($prj_uid, $act_uid, $request_data);
/** features */
$featureHandler = new \Features\FeaturesHandler();
$featureHandler->saveConfiguration('activity', $request_data['properties']['_features']);
/** features */
} catch (\Exception $e) { } catch (\Exception $e) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()); throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
} }