Refactor Guide?


!Friendica Developers

Is there a guide somewhere on how we're supposed to rewrite code for the refactor in the release candidate? I'm trying to get my add-ons to work in 2025.07-rc and apparently DI::app() is no longer a thing. What am I supposed to replace that with? Is there some preferred means for my add-ons to detect whether they are installed in the 2024 or 2025 versions of Friendica so I can conditionally handle these changes?

#addons #friendica #php

Als Antwort auf Random Penguin

Ok, well I figured out something that works though I'm not sure this is how I'm supposed to do it. I noticed a new file /src/AppHelper.php and from that gathered I needed to add to the top of my code:

use Friendica\AppHelper

It seems if you include a use that doesn't actually exist it just ignores it, so that didn't throw any errors in the stable 2024 version.

Then later in my code I did:

$fv = explode('.',App::VERSION);
if ( $fv[0] == '2024'){
     $current_theme = DI::app()->getCurrentTheme();
} else {
     $current_theme = DI::appHelper()->getCurrentTheme();
}

The add-on works in both stable 2024 and the 2025-rc now. But is that a good way to get the Friendica version number?

Als Antwort auf Artur Weigandt

Thanks @Artur Weigandt ! Looks like what I figured is the recommended replacement (DI::app() --> DI::appHelper()). I'm only checking method_exists() so I can add logic supporting both Friendica 2024.12 and the 2025 release candidate, rather than maintain two different versions of my addons. Also I figured checking for the actual class and method was better than checking for the Friendica version. I did get my addons working in the RC on my dev server.
Als Antwort auf Random Penguin

@Alt Pygoscelis Papua Great! Please take also a look at the "Deprecated" section and fix your plugins if needed. This way your plugins won't stop working with the next version thanks to the new compatibility promise: github.com/friendica/friendica…

The CHANGELOG.md should show you the upgrade path. You might give the PR a proper reaction if it was helpful: github.com/friendica/friendica…

Friendica Developers hat dies geteilt.

Als Antwort auf Random Penguin

I think art4, who wilhelm just tagged, is the best qualified to answer that, as he made the relevant PRs that refactored addons. :-)

I guess this one should be updated:
wiki.friendi.ca/docs/addons
...except from what I've read, that wiki is frequently pretty out of date, so maybe it'll be replaced by something else instead. Incidentally art is also working on some greatly needed updates to how documentation is handled, but that may be more user centric documentation rather than developer documentation? Not entirely sure. Either way, important work.