diff --git a/src/Controller/Component/ACLComponent.php b/src/Controller/Component/ACLComponent.php index e7ff59f..2a5a648 100644 --- a/src/Controller/Component/ACLComponent.php +++ b/src/Controller/Component/ACLComponent.php @@ -671,6 +671,34 @@ class ACLComponent extends Component 'popup' => 1 ] ] + ], + 'LocalTools' => [ + 'label' => __('Local Tools'), + 'url' => '/localTools/index', + 'children' => [ + 'index' => [ + 'url' => '/localTools/index', + 'label' => __('List Connectors') + ], + 'viewConnector' => [ + 'url' => '/localTools/viewConnector/{{connector}}', + 'label' => __('View Connector'), + 'actions' => ['view'], + 'skipTopMenu' => 1 + ], + 'add' => [ + 'url' => '/localTools/add/{{connector}}', + 'label' => __('Add connection'), + 'actions' => ['viewConnector'], + 'skipTopMenu' => 1 + ], + 'view' => [ + 'url' => '/localTools/view/{{id}}', + 'label' => __('View Connection'), + 'actions' => ['view'], + 'skipTopMenu' => 1 + ] + ] ] ], 'Cerebrate' => [ diff --git a/src/Controller/Component/CRUDComponent.php b/src/Controller/Component/CRUDComponent.php index ee373a1..32d3717 100644 --- a/src/Controller/Component/CRUDComponent.php +++ b/src/Controller/Component/CRUDComponent.php @@ -38,11 +38,17 @@ class CRUDComponent extends Component } $params = $this->Controller->ParamHandler->harvestParams($optionFilters); $query = $this->Table->find(); + if (!empty($options['filterFunction'])) { + $query = $options['filterFunction']($query); + } $query = $this->setFilters($params, $query, $options); $query = $this->setQuickFilters($params, $query, empty($options['quickFilters']) ? [] : $options['quickFilters']); if (!empty($options['contain'])) { $query->contain($options['contain']); } + if (!empty($options['fields'])) { + $query->select($options['fields']); + } if ($this->Controller->ParamHandler->isRest()) { $data = $query->all(); if (isset($options['afterFind'])) { @@ -323,6 +329,9 @@ class CRUDComponent extends Component $data = $this->Table->get($id, $params); $data = $this->attachMetaData($id, $data); + if (isset($params['afterFind'])) { + $data = $params['afterFind']($data); + } if ($this->Controller->ParamHandler->isRest()) { $this->Controller->restResponsePayload = $this->Controller->RestResponse->viewData($data, 'json'); } diff --git a/src/Controller/Component/RestResponseComponent.php b/src/Controller/Component/RestResponseComponent.php index ef9bf53..96b3725 100644 --- a/src/Controller/Component/RestResponseComponent.php +++ b/src/Controller/Component/RestResponseComponent.php @@ -426,8 +426,8 @@ class RestResponseComponent extends Component $response = [ 'success' => true, 'message' => $message, - 'data' => $entity->toArray(), - 'url' => $this->__generateURL($action, $ObjectAlias, $entity->id) + 'data' => $entity->toArray() + //'url' => $this->__generateURL($action, $ObjectAlias, $entity->id) ]; if (!empty($additionalData)) { $response['additionalData'] = $additionalData;