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

        tyson Tyson Phillips (Inactive) created issue -
        tyson Tyson Phillips (Inactive) made changes -
        Field Original Value New Value
        Rank Ranked higher
        tyson Tyson Phillips (Inactive) made changes -
        Story Points 3
        tyson Tyson Phillips (Inactive) made changes -
        Rank Ranked higher
        tyson Tyson Phillips (Inactive) made changes -
        Sprint 4.3.0 Sprint 1 [ 49 ]
        tyson Tyson Phillips (Inactive) made changes -
        Rank Ranked higher
        jonathan Jonathan Reissmueller made changes -
        Assignee Tyson Phillips [ tyson ] Jonathan Reissmueller [ jonathan ]
        Automated transition triggered when Jonathan Reissmueller created a branch in Stash -
        Status Open [ 1 ] In Progress [ 3 ]
        jonathan Jonathan Reissmueller made changes -
        Remaining Estimate 0 minutes [ 0 ]
        Time Spent 39 minutes [ 2340 ]
        Worklog Id 10674 [ 10674 ]
        Automated transition triggered when Jonathan Reissmueller created pull request #388 in Stash -
        Status In Progress [ 3 ] In Review [ 5 ]
        Resolution Fixed [ 1 ]
        tyson Tyson Phillips (Inactive) made changes -
        Sprint 4.3.0 Sprint 1 [ 49 ] 4.3.0 Sprint 1, 4.3.0 Sprint 2 [ 49, 52 ]
        tyson Tyson Phillips (Inactive) made changes -
        Rank Ranked higher
        tyson Tyson Phillips (Inactive) made changes -
        Sprint 4.3.0 Sprint 1, 4.3.0 Sprint 2 [ 49, 52 ] 4.3.0 Sprint 1, 4.3.0 Sprint 2, 4.3.0 Sprint 3 [ 49, 52, 53 ]
        tyson Tyson Phillips (Inactive) made changes -
        Sprint 4.3.0 Sprint 1, 4.3.0 Sprint 2, 4.3.0 Sprint 3 [ 49, 52, 53 ] 4.3.0 Sprint 1, 4.3.0 Sprint 2, 4.3.0 Sprint 3, 4.3.0 Sprint 4 [ 49, 52, 53, 54 ]
        Automated transition triggered when Tyson Phillips (Inactive) merged pull request #388 in Stash -
        Status In Review [ 5 ] Closed [ 6 ]
        tyson Tyson Phillips (Inactive) made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        tyson Tyson Phillips (Inactive) made changes -
        Fix Version/s 4.3.0-b1 [ 11019 ]
        tyson Tyson Phillips (Inactive) made changes -
        Security Private [ 10000 ]
        tyson Tyson Phillips (Inactive) made changes -
        Status Reopened [ 4 ] Closed [ 6 ]
        Resolution Fixed [ 1 ]

          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