modifyClass failed with a warning

Hello!
I want to modify controller with plugin api, but it failed with a warning like:

[THEME xxx] “controller:full-page-search” was already cached in the container. Changes won’t be applied.

my code:

function modifySearchTypes(api) {
    api.modifyClass("controller:full-page-search", {
        pluginId: "modify-search-types",
        init() {
            this._super(...arguments);
            
        
            this.set("searchTypes", [
              { name: I18n.t("search.type.default"), id: SEARCH_TYPE_DEFAULT },
              {
                name: this.siteSettings.tagging_enabled
                  ? I18n.t("search.type.categories_and_tags")
                  : I18n.t("search.type.categories"),
                id: SEARCH_TYPE_CATS_TAGS,
              },
            ]);
            this.selected = [];
        },
    });
}

export default {
    name: "modify-search-types",
    initialize() {     
        withPluginApi("0.10.0", modifySearchTypes);
    },
};

How can I deal with it?
Thank you very much!

See api.modifyClass sometimes(!) not working - #12 by RGJ

2 Likes

Thank you!
However, code below still failed and print this warning.

function modifySearchTypes(api) {
    api.modifyClass("controller:full-page-search", {
        pluginId: "modify-search-types",
        init() {
            this._super(...arguments);
            
        
            this.set("searchTypes", [
              { name: I18n.t("search.type.default"), id: SEARCH_TYPE_DEFAULT },
              {
                name: this.siteSettings.tagging_enabled
                  ? I18n.t("search.type.categories_and_tags")
                  : I18n.t("search.type.categories"),
                id: SEARCH_TYPE_CATS_TAGS,
              },
            ]);
            this.selected = [];
        },
    });
   const searchController = api.container.lookup("controller:full-page-search");
}

export default {
    name: "modify-search-types",
    initialize() {     
        withPluginApi("0.10.0", modifySearchTypes);
    },
};

In that case, I have no idea.

1 Like

I override template of full page search with a new one in my theme component. Does it have any effect?