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
namespace Features;
namespace \Features\ActionsByEmail;
/**
* 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',
'options' => array(
array(
'name' => '',
'label' => '- None -',
'value' => '',
'text' => '- None -',
'type' => 'default'
),
array(
'name' => 'LINK',
'label' => 'Link to fill a form',
'value' => 'LINK',
'text' => 'Link to fill a form',
),
array(
'name' => 'FIELD',
'label' => 'Use a field to generate actions links',
'value' => 'FIELD',
'text' => 'Use a field to generate actions links',
)
)
),
@@ -84,9 +81,8 @@ class ActivityConfigurationView
),
'options' => array(
array(
'name' => '',
'value' => '',
'text' => '- Select a Template -',
'label' => '- Select a Template -',
'type' => 'default'
)
)
@@ -118,9 +114,8 @@ class ActivityConfigurationView
),
'options' => array(
array(
'name' => '',
'value' => '',
'text' => '- Select a Dynaform -',
'label' => '- Select a Dynaform -',
'type' => 'default'
)
),
@@ -137,9 +132,8 @@ class ActivityConfigurationView
'type' => 'dropdown',
'options' => array(
array(
'name' => '',
'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'
)
),
@@ -165,9 +159,8 @@ class ActivityConfigurationView
'type' => 'dropdown',
'options' => array(
array(
'name' => '',
'value' => '',
'text' => '- Select a Field -',
'label' => '- Select a Field -',
'type' => 'default'
)
),
@@ -186,10 +179,15 @@ class ActivityConfigurationView
),
array(
'name' => 'ABE_CASE_NOTE_IN_RESPONSE',
'value' => true,
'default' => false,
'type' => 'checkbox',
'labelVisible' => false,
'options' => array(
array(
'id' => 'formTimingControlOption',
'label' => 'Register a Case Note when the recipient submits the Response',
'type' => 'checkbox'
'value' => '1'
)
)
),
// array(
// 'name' => 'APPLY_CHANGES',

View File

@@ -1,5 +1,4 @@
<?php
namespace Features;
/**
* 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()
{
$invalidFolders = array('ViewContainers');
$featuresFolders = glob(PATH_FEATURES.'/*', GLOB_ONLYDIR);
$features = array();
foreach ($featuresFolders as $directory) {
$feature = new stdClass();
if (in_array($directory, $invalidFolders)) {
$feature = new \stdClass();
$featureName = basename($directory);
if (in_array($featureName, $invalidFolders)) {
continue;
}
$feature->path = PATH_FEATURES . PATH_SEP . $directory;
$feature->name = $directory;
$feature->path = PATH_FEATURES . $featureName;
$feature->name = $featureName;
$features[] = $feature;
}
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();
$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) {
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
}