Commit 58bfcf6e authored by pv2b's avatar pv2b Committed by Per von Zweigbergk

style fix

parent fbe7cd29
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
*/ */
namespace OPNsense\Base; namespace OPNsense\Base;
/** /**
* Class ApiMutableTableModelControllerBase, inherit this class to implement * Class ApiMutableTableModelControllerBase, inherit this class to implement
* an API that exposes a model for tables. * an API that exposes a model for tables.
...@@ -37,8 +36,8 @@ namespace OPNsense\Base; ...@@ -37,8 +36,8 @@ namespace OPNsense\Base;
*/ */
abstract class ApiMutableTableModelControllerBase extends ApiControllerBase abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
{ {
// FIXME What about validation? // FIXME What about validation?
static protected $modelPathPrefix = ''; static protected $modelPathPrefix = '';
private function getNodes() { private function getNodes() {
$ref = static::$modelPathPrefix $ref = static::$modelPathPrefix
...@@ -49,12 +48,13 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase ...@@ -49,12 +48,13 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
return $this->getNodes()->$uuid; return $this->getNodes()->$uuid;
} }
/** /**
* retrieve item or return defaults * retrieve item or return defaults
* @param $uuid item unique id * @param $uuid item unique id
* @return array * @return array
*/ */
public function getItemAction($uuid = null) { public function getItemAction($uuid = null)
{
$mdl = $this->getModel(); $mdl = $this->getModel();
if ($uuid != null) { if ($uuid != null) {
$node = $this->getNodeByUUID($uuid); $node = $this->getNodeByUUID($uuid);
...@@ -69,13 +69,14 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase ...@@ -69,13 +69,14 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
} }
return array(); return array();
} }
/** /**
* update item with given properties * update item with given properties
* @param $uuid item unique id * @param $uuid item unique id
* @return array * @return array
*/ */
public function setItemAction($uuid) { public function setItemAction($uuid)
{
if ($this->request->isPost() && $this->request->hasPost(static::$internalModelName)) { if ($this->request->isPost() && $this->request->hasPost(static::$internalModelName)) {
$mdl = $this->getModel(); $mdl = $this->getModel();
if ($uuid != null) { if ($uuid != null) {
...@@ -93,26 +94,28 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase ...@@ -93,26 +94,28 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
* add new item and set with attributes from post * add new item and set with attributes from post
* @return array * @return array
*/ */
public function addItemAction() { public function addItemAction()
{
$result = array("result"=>"failed"); $result = array("result"=>"failed");
if ($this->request->isPost() && $this->request->hasPost(static::$internalModelName))) { if ($this->request->isPost() && $this->request->hasPost(static::$internalModelName))) {
$mdl = $this->getModel(); $mdl = $this->getModel();
// FIXME Is this correct? // FIXME Is this correct?
$node = $this->getNodes()->add(); $node = $this->getNodes()->add();
$node->setNodes($this->request->getPost(static::$internalModelName))); $node->setNodes($this->request->getPost(static::$internalModelName)));
// FIXME What do we do with this? Is this traffic-shaper specific? Do we need a hook here? // FIXME What do we do with this? Is this traffic-shaper specific? Do we need a hook here?
$node->origin = "TrafficShaper"; // set origin to this component. $node->origin = "TrafficShaper"; // set origin to this component.
return $this->save($mdl, $node, static::$internalModelName)); return $this->save($mdl, $node, static::$internalModelName));
} }
return $result; return $result;
} }
/** /**
* delete item by uuid * delete item by uuid
* @param $uuid item unique id * @param $uuid item unique id
* @return array status * @return array status
*/ */
public function delItemAction($uuid) { public function delItemAction($uuid)
{
$result = array("result"=>"failed"); $result = array("result"=>"failed");
if ($this->request->isPost()) { if ($this->request->isPost()) {
$mdl = $this->getModel(); $mdl = $this->getModel();
...@@ -129,14 +132,15 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase ...@@ -129,14 +132,15 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
} }
return $result; return $result;
} }
/** /**
* toggle item by uuid (enable/disable) * toggle item by uuid (enable/disable)
* @param $uuid item unique id * @param $uuid item unique id
* @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle * @param $enabled desired state enabled(1)/disabled(1), leave empty for toggle
* @return array status * @return array status
*/ */
public function toggleItemAction($uuid, $enabled = null) { public function toggleItemAction($uuid, $enabled = null)
{
$result = array("result" => "failed"); $result = array("result" => "failed");
if ($this->request->isPost()) { if ($this->request->isPost()) {
$mdl = $this->getModel(); $mdl = $this->getModel();
...@@ -159,18 +163,19 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase ...@@ -159,18 +163,19 @@ abstract class ApiMutableTableModelControllerBase extends ApiControllerBase
} }
return $result; return $result;
} }
/** /**
* search items * search items
* @return array * @return array
*/ */
public function searchItemsAction() { public function searchItemsAction()
{
$this->sessionClose(); $this->sessionClose();
$mdl = $this->getModel(); $mdl = $this->getModel();
$grid = new UIModelGrid($this->getNodes()); $grid = new UIModelGrid($this->getNodes());
return $grid->fetchBindRequest( return $grid->fetchBindRequest(
$this->request, $this->request,
// FIXME Where do we get this list from? Is this something to be supplied by class implementor? // FIXME Where do we get this list from? Is this something to be supplied by class implementor?
array("enabled","number", "bandwidth","bandwidthMetric","burst","description","mask","origin"), array("enabled","number", "bandwidth","bandwidthMetric","burst","description","mask","origin"),
"number" "number"
); );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment