Skip to content
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

CRM_Core_Resources - Allow container to swap the implementation #12959

Merged
merged 1 commit into from
Oct 19, 2018

Conversation

totten
Copy link
Member

@totten totten commented Oct 18, 2018

Overview

CRM_Core_Resources manages the registration of page-level resources, such as JS and CSS files. This changes the construction logic so that it becomes possible for an extension to modify the definition of CRM_Core_Resources.

This is intended to allow experimentation with theme-management in extensions.

Before and After (Unchanged)

CRM_Core_Resources::singleton(), Civi::resources(), and Civi::container()->get('resources') all return the same object.

Before

The object construction is handled in the singleton() function.

After

The object construction is handled in the Container. Container defintions can be modified via hook_civicrm_container.

Technical Details

A possible critique: "You can't move everything in the container; is this one safe?." The main limitation of the container is that it cannot initialize boot-critical services (i.e. it's not available during pre/early-bootstrap). However, the resource manager is not boot-critical. You can tell this because the old logic (from CRM_Core_Resources::singleton()) already relied on having a working container (to lookup js_strings). If it was boot-critical, then the old call to Civi::cache('js_strings') would have been crash-y.

@civibot
Copy link

civibot bot commented Oct 18, 2018

(Standard links)

@civibot civibot bot added the master label Oct 18, 2018
@eileenmcnaughton
Copy link
Contributor

@totten I'm happy to merge this at this stage - I feel like we have discussed & this will be part of any solution - although it may not be the only part. Do you have any reason I should hold off at this stage?

@totten
Copy link
Member Author

totten commented Oct 19, 2018

@eileenmcnaughton Yes, I think it's fine to merge too.

Aside on r-run: Based on past experience, I was curious about resource handling in some oddball screens (like profiles embedded under Drupal's /user paths) -- but these seem to work as well as before (on both local and the autobuild demo).

@totten totten merged commit 8ed8724 into civicrm:master Oct 19, 2018
@totten totten deleted the master-theme-lite branch October 19, 2018 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants