prettify attribute access in BaseField type and replace uuid retrieval in ApiMutableModelControllerBase, close https://github.com/opnsense/core/issues/2760

This commit is contained in:
Ad Schellevis 2018-09-26 21:35:17 +02:00
parent 2918fb59d6
commit 8967d76f70
2 changed files with 15 additions and 1 deletions

View File

@ -297,7 +297,7 @@ abstract class ApiMutableModelControllerBase extends ApiControllerBase
Config::getInstance()->save();
$result = array(
"result" => "saved",
"uuid" => str_replace($path . ".", "", $node->__reference)
"uuid" => $node->getAttribute('uuid')
);
} else {
$result["result"] = "failed";

View File

@ -379,6 +379,20 @@ abstract class BaseField
return $this->internalAttributes;
}
/**
* get attribute by name
* @param string $key attribute key
* @return null|string value
*/
public function getAttribute($key)
{
if (isset($this->internalAttributes[$key])) {
return $this->internalAttributes[$key];
} else {
return null;
}
}
/**
* get this nodes children
* @return array child items