-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to disable extension by overriding *.yml config file? #2146
Comments
i think this is the only way to do it, are you using the FQCN when passing it to |
Yes, I am using FQCN. |
There should be a feature to do this via |
If you're talking about the comments yml - that's not true, you can apply your yml to the extension directly rather than to the target class. |
What do you mean by applying yml to extension directly? I go to the extension |
I think if the extension has a key then you can set it to falsy (in SS4), e.g. MyClass:
extensions:
MyExtensionAlias: My\Extension\ClassName Then: ---
Name: myconfig
After: '#originalconfig'
---
MyClass:
extensions:
MyExtensionAlias: false If you are just pushing an array with no keys then config will be merged and you will need to use PHP to remove it |
This is the original extension yml partial content: SilverStripe\CMS\Model\SiteTree:
extensions:
- SilverStripe\Comments\Extensions\CommentsExtension |
If you modify the comments YAML file so it has an alias, are you able to remove it again via that alias? |
Yes, I can modify the comments |
There is an awkward hack you can use to do this. ---
name: resetextensions
---
SilverStripe\CMS\Model\SiteTree:
extensions: null
---
name: restoresomeextensions
after: '#resetextensions'
---
SilverStripe\CMS\Model\SiteTree:
extensions:
- SilverStripe\ORM\Hierarchy\Hierarchy
- SilverStripe\Versioned\Versioned
- SilverStripe\Security\InheritedPermissionsExtension This will clear all extensions, letting you re-add back only the ones you want to keep on SiteTree. |
For comments module, we could do this SilverStripe\CMS\Model\SiteTree:
extensions:
comments: SilverStripe\Comments\Extensions\CommentsExtension This would allow you to disable that extension with only this code SilverStripe\CMS\Model\SiteTree:
extensions:
comments: null However, this would only fix the issue in one module. Maybe we should make a convention that all extensions should be added with an alias? |
How about a new yml block. Instead of |
Shifting to silverstripe/silverstripe-config#32 |
Right now, the simplest approach is to edit the original extension's configuration file directly and do it again in case of updates in the future. No hacking, no bloated config files all around the project. It's a bad approach, but it works nicely. |
If some extension adds itself to
SiteTree
through the extension's*.yml
config file, how do I disable the extension forSiteTree
and allow it only for a customMyClass
by overriding, using custom*.yml
config file inmysite/_config
location?I tried adding the following line in mysite/_config.php file:
but it didn't work.
I don't want to change the original extension's config file, for the sake of future upgrades.
Btw, I am using latest Silverstripe 4.1 CMS.
The text was updated successfully, but these errors were encountered: