• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 How to filter media sites in an add-on?

JoshyPHP

Well-known member
#1
I'm currently looking into upgrading my media sites add-on for XenForo 2.0. The add-on contains many definitions and lets the user select which ones should be installed. It means that media sites should be filtered during install/upgrade, and should be reinstalled whenever that selection changes.

In XenForo 1.x, the XML for the media sites can be accessed during install via $addon->bb_code_media_sites, and media sites can be reinstalled using XenForo_Model_BbCode's importBbCodeMediaSitesAddOnXml() and rebuildBbCodeCache(). What would be the correct way to do that in XenForo 2.0?

So far, I have found that the add-on's bb_code_media_sites.xml file can be modified during the installation but that's hacky and it assumes the add-on can write to the filesystem. I see that there is a rebuildBbCodeMediaSiteCache() accessible via $this->app->repository('XF:BbCodeMediaSite') but I haven't been able to ascertain this works as expected yet.

Any information is welcome, thanks in advance.
 

Mike

XenForo developer
Staff member
#2
Realistically, I don't think there was any expectation that you could do what you were doing in XF1. It was certainly not intentional. The approach has always been that we import the media sites associated with the add-on (by virtue of being in the XML). Dynamic changes during installation were never a target use case.

If you want to continue an approach like this, you're likely to need to do an entirely custom system for this. Alternatively, install all of the media sites and let people enable/disable them. Those states will be maintained across upgrades.
 

JoshyPHP

Well-known member
#3
Ok, I'll look into it. What's the policy regarding public API? Are public methods guaranteed to remain forward compatible for the duration of a major version or is it something that could break in a 2.x release?
 

Mike

XenForo developer
Staff member
#4
We don't totally adhere to semantic versioning, but I would expect the API of methods to be mostly stable within 2.x (particularly public methods). Obviously we may add arguments, though they would generally be expected to be optional.