(dev/cloud-native#3) Container, Extension Classloader - Change CIVICRM_TEMPLATE_COMPI...
authorTim Otten <totten@civicrm.org>
Wed, 10 Jul 2019 05:10:05 +0000 (22:10 -0700)
committerTim Otten <totten@civicrm.org>
Tue, 16 Jul 2019 01:58:12 +0000 (18:58 -0700)
commit6f50d29cbc58be26ebcc67777ba2de9a25c02fa4
tree7b6623adcbd68ce5bc97b12abe2771f7ca2148a4
parent9a13b5fda600936bad646d7c145ef6e6e679c3b5
(dev/cloud-native#3) Container, Extension Classloader - Change CIVICRM_TEMPLATE_COMPILEDIR to 'civicrm.compile'

The broader PR seeks to make path computation more intuitive, which requires computing the
path to `templates_c` using a function. This PR replaces the reference to `CIVICRM_TEMPLATE_COMPILEDIR`
with a function-call to `Civi::paths()->getPath()`.

Why change these two files in the same commit? Because they're basically doing the same
thing (writing an executable PHP file to the template cache), and the demonstration
of their safety is basically the same.

Is it safe to change this reference to `CIVICRM_TEMPLATE_COMPILEDIR` in
`Civi\Core\Container::loadContainer()` and `CRM_Extension_ClassLoader::register()/::getCacheFile()`?  Yes, I believe so:

* Look at `Civi\Core\Container::boot()`.
* Observe that it initializes services in two general stages:
    * First, the `$bootServices` (`runtime`, `paths`, `userSystem`, etc)
    * Second, the DB/extension-dependent services (`CRM_Utils_Hook`, `CRM_Extension_System`, `loadContainer()`).
* The first stage services (e.g. `paths`) provide enough information
  to process `Civi::paths()->getPath('[civicrm.compile]/foo')`.
* All the modified lines run as part of the *second* stage (i.e. after
  the `$bootServices` have been initialized).
CRM/Extension/ClassLoader.php
Civi/Core/Container.php