Jump to content

Blesta 4.0 Breaking API changes


blazedd

Recommended Posts

It looks like a fairly undocumented change in Blesta 4 includes a change in how plugins extend the API by their url.

If you look at the docs here, it shows per 4.0: https://docs.blesta.com/display/dev/Extending+the+API

You would make a request to: https://yourdomain.com/installpath/api/foo_bar.foo_bar_sprocket/create.json?vars[price]=1.99

Now you make a request to: https://yourdomain.com/installpath/api/foo_bar.FooBarSprocket/create.json?vars[price]=1.99

It appears that you now reference the class name, rather than the file name. Is there a way that docs can be updated to reflect these changes?

Link to comment
Share on other sites

  • 4 months later...

I'm adding Tyson's solution to this thread in case it comes up for anyone else. Nobody should do this unless they rely on snake_case and are having the same issue as @barryf CamelCase should be used going forward.

Quote

The use of snake case plugin API actions may be supported in the future, but are not currently. It's recommended to use CamelCase. You can apply the below temporary fix to work-around the issue for now:

  1. Open and update /app/controllers/api.php from your Blesta installation

  2. Find the following line:
    $this->model = Loader::toCamelCase($this->get[0]);

  3. Replace that line with the following:
    $this->model = '';
    $fields = explode('.', $this->get[0]);
    foreach ($fields as $i => $field) {
    $this->model .= Loader::toCamelCase($field) . (isset($fields[$i+1]) ? '.' : '');
    }

  4. Save the file. Your snake_case plugin API actions will now work.

 

Link to comment
Share on other sites

  • 2 months later...

Paul,

We would like to get a dev license to test our existing customizations before upgrading to 4.x. Further, we have a module we would like to start developing as well. Please let us know how we can acquire a dev license to work locally. Thank you.

 

Regards,
Jonathan Griffin | JaxSite

Link to comment
Share on other sites

On 12/4/2017 at 1:00 AM, JaxSite said:

Paul,

We would like to get a dev license to test our existing customizations before upgrading to 4.x. Further, we have a module we would like to start developing as well. Please let us know how we can acquire a dev license to work locally. Thank you.

 

Regards,
Jonathan Griffin | JaxSite

would have been better to have contacted @Paul on his livechat.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...