Source of file ApiSchemaController.php
Size: 0,838 Bytes - Last Modified: 2021-12-23T10:10:59+00:00
/var/www/docs.ssmods.com/process/src/code/controller/ApiSchemaController.php
12345678910111213141516171819202122232425262728293031323334 | <?php class ApiSchemaController extends ApiController { private static $allowed_actions = [ "index" => "->isModelAllowed", ]; function index() { $modelName = $this->request->param('Model'); $schema = array(); $underscoreFields = Config::inst()->get($modelName, 'underscoreFields'); foreach(singleton($modelName)->inheritedDatabaseFields() as $key => $value) { if ($underscoreFields) { $key = ApiDataObject::to_underscore($key); } $schema[$key] = $value; } return $this->sendData([ "schema" => $schema ]); } function isModelAllowed() { $allowedModels = $this->config()->get('allowedModels'); $modelName = $this->request->param('Model'); if (!is_array($allowedModels)) $allowedModels = []; return (in_array($modelName, $allowedModels)); } } |