Details
-
Type: Improvement
-
Status: Closed
-
Priority: Trivial
-
Resolution: Fixed
-
Affects Version/s: 4.0.0
-
Fix Version/s: 4.3.0-b1
-
Component/s: None
-
Labels:None
Description
minphp changed in v4.0 such that API actions no longer return the expected response for plugins since it is now case-sensitive. We can update the API controller to support this again relatively easily, however, it is recommended to use CamelCase names to reference models rather than snake_case.
Consider the following example:
```
$response = $api->get("support_manager.support_manager_departments", "getList", array('company_id' => 1));
```
Pre-4.0, the API controller would set the model to "SupportManager.supportManagerDepartments", which would successfully load the SupportManagerDepartments model from the SupportManager plugin. While the same string is converted to camel-case in the same way post-4.0, minphp does not load "SupportManager.supportManagerDepartments" because it cannot find the class due to case-sensitivity.
Sample fix in /app/controllers/api.php:
-$this->model = Loader::toCamelCase($this->get[0]); +$this->model = ''; +$fields = explode('.', $this->get[0]); +foreach ($fields as $i => $field) { + $this->model .= Loader::toCamelCase($field) . (isset($fields[$i+1]) ? '.' : ''); +}