Jump to content
blazedd

Blesta 4.0 Breaking API changes

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?

Share this post


Link to post
Share on other sites

4.0 was a major release, which included an upgrade to the framework minPHP, PHP 7 support, and a lot more. Major releases can have backwards incompatible changes. Any custom extensions should be tested with a major release in a dev environment before deploying live.

Share this post


Link to post
Share on other sites

Haha, thanks. It was on a Dev instance. :) 

We use a central API for controlling all Blesta instances, so need to be able to support both 3.6 and 4.x during the upgrade. 

Tyson has been kind enough to provide a temporary workaround.

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×