Civi\Core\Container - Fix warning about Symfony 3=>4 and boot services
authorTim Otten <totten@civicrm.org>
Sat, 2 Nov 2019 02:30:17 +0000 (19:30 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 2 Nov 2019 02:30:17 +0000 (19:30 -0700)
commit765daeac4eba0e3ab1732d8cc424af026b4482d7
treee573f69f459a6f964f343b4ba47f5c107368d641
parent33b500808a2faa8b3af4d180b30409467786e3b9
Civi\Core\Container - Fix warning about Symfony 3=>4 and boot services

Boot services are initialized before the container starts -- and then passed in via `$container->set()`.

Symfony 3.4 changes the default handling of `set()` - it now emits warnings
unless the services were previously flagged as public.

https://symfony.com/blog/new-in-symfony-3-4-services-are-private-by-default

Before
------

```
[bknix-min:~/bknix/build/d8re] drush php
Psy Shell v0.9.9 (PHP 7.0.32 — cli) by Justin Hileman
>>> \Drupal::service('civicrm')->initialize();
PHP Deprecated:  The "runtime" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "paths" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userSystem" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "userPermissionClass" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "cache.settings" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "settings_manager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
PHP Deprecated:  The "lockManager" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0. in /Users/totten/bknix/build/d8re/vendor/symfony/dependency-injection/Container.php on line 190
```

After
-----

The warnings don't appear.

Comments
--------

The `Definition` class includes two methods, `setPublic()` and
`setPrivate()`, which appear to do the same thing (but as opposites).
`setPublic()` exists Symfony 2.8+, but `setPrivate()` was added in Symfony
3.x, so we use `setPublic()` for broader compatibility.
Civi/Core/Container.php