Fix save feature via REST services
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user