dev/drupal#4 - Add Civi\Setup::getPendingAction() helper
authorTim Otten <totten@civicrm.org>
Wed, 26 Feb 2020 03:42:47 +0000 (19:42 -0800)
committerTim Otten <totten@civicrm.org>
Wed, 26 Feb 2020 04:26:02 +0000 (20:26 -0800)
commit589e1936a81ae7223dcb842d93370de3bb0b394b
tree74eed28a1506cba6608bee81ffa5f39adc119bbc
parentfb5bc77f45f9f06fde4ac7f99095cb1a5261b865
dev/drupal#4 - Add Civi\Setup::getPendingAction() helper

Overview
--------

This exposes a new piece of information for downstream consumers of the `civicrm-setup` API.

It doesn't change any behaviors or expectations - it merely tracks an extra piece of info.

Before
------

The `Civi\Setup` interface does not give any reporting about what's going on.

After
-----

The `Civi\Setup` interface has a method, `getPendingAction()`, which reports the pending action.

Technical Details
-----------------

(1) The pending action is strictly singular - it would not be sensible, for example, to have the
`installFiles` and `uninstallFiles` actions running at the same time. Thus, the guards within
each function.

(2) The basic gist of the change - in each of the functions
(`{install,uninstall}{Files,Database}`), set the `pendingAction` at the start and unset
it at the end.  The change looks slightly bigger than it should - because it wraps the
existing code within the `try ...  finally ...` block.

(3) This facilitates dev/drupal#4 and https://github.com/civicrm/civicrm-drupal-8/pull/37
- there were some use-cases in which the auto-install behaviors of `civicrm_install()`
and `FlushDrupal8.civi-setup.php` would provoke each other (causing a sort of
installer-loop).  This change makes it possible to avoid the loop without changing the
contracts.
setup/src/Setup.php