Uploaded image for project: 'Blesta Core'
  1. Blesta Core
  2. CORE-2479

Update API to allow for dot-separated actions

    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]) ? '.' : '');
      +}
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            jonathan Jonathan Reissmueller
            Reporter:
            tyson Tyson Phillips (Inactive)
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Fix Release Date:
              15/Jun/18

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 39 minutes
              39m

                Agile