• totten's avatar
    (REF) CRM_Core_Resources - Move hook declaration from addCoreResources() to Container.php · f22fb451
    totten authored
    tldr: It's easier to declare `hook_civicrm_buildAsset` listeners at a high-level.
    
    Asset building can use two modes -- production mode writes a static file to
    disk when it's being reference.  Debug mode just generates a URL for a
    web-service (which in turn dynamically renders the content in a separate
    page-view).
    
    If the only mode were production mode, then the code would be on pretty
    solid ground.  We could even simplify things a lot by changing the
    AssetBuilder contract to replace the hooks with callbacks, as in:
    
    ```php
    Civi::service('asset_builder')->getUrl('crm-menu.css', function() {
      return '...the css code...';
    });
    ```
    
    Why have a hook?  Because hooks are generally context-free and
    always-available.  If we use debug-mode (or if we add a feature to warm-up
    the caches during deployment), then we'll want to fire that hook from a
    different context (e.g.  web-service or CLI), and the hook-listener needs to
    be available in those other contexts.
    
    It would be nice if we could declare hooks generally without needing to edit
    the `Container.php` mega-file (e.g.  maybe some kind of annotation).  But,
    for the moment, I think this is the best spot that we have in `civicrm-core`
    for ensuring that hook listeners are fully/consistently registered.
    f22fb451
Name
Last commit
Last update
..
DAO/Event Loading commit data...
Event Loading commit data...
Exception Loading commit data...
Lock Loading commit data...
SqlTrigger Loading commit data...
Transaction Loading commit data...
AssetBuilder.php Loading commit data...
CiviEventDispatcher.php Loading commit data...
CiviEventInspector.php Loading commit data...
Container.php Loading commit data...
DatabaseInitializer.php Loading commit data...
InstallationCanary.php Loading commit data...
LocalizationInitializer.php Loading commit data...
Paths.php Loading commit data...
Resolver.php Loading commit data...
SettingsBag.php Loading commit data...
SettingsManager.php Loading commit data...
SettingsMetadata.php Loading commit data...
SettingsStack.php Loading commit data...
SqlTriggers.php Loading commit data...