Ensure custom fields properties are assigned to the template
[civicrm-core.git] / Civi.php
index 12b2119b45bc846ca7472b3ac6a518c5140532fb..f087d19c8d6b00ceefb777d1b1d81c86d94ef44a 100644 (file)
--- a/Civi.php
+++ b/Civi.php
@@ -1,5 +1,7 @@
 <?php
 
+use Civi\Core\Format;
+
 /**
  * Class Civi
  *
@@ -19,11 +21,11 @@ class Civi {
   /**
    * A central location for static variable storage.
    * @var array
-   * @code
+   * ```
    * `Civi::$statics[__CLASS__]['foo'] = 'bar';
-   * @endcode
+   * ```
    */
-  public static $statics = array();
+  public static $statics = [];
 
   /**
    * Retrieve a named cache instance.
@@ -64,7 +66,14 @@ class Civi {
    * @return \Symfony\Component\EventDispatcher\EventDispatcherInterface
    */
   public static function dispatcher() {
-    return Civi\Core\Container::singleton()->get('dispatcher');
+    // NOTE: The dispatcher object is initially created as a boot service
+    // (ie `dispatcher.boot`). For compatibility with the container (eg
+    // `RegisterListenersPass` and `createEventDispatcher` addons),
+    // it is also available as the `dispatcher` service.
+    //
+    // The 'dispatcher.boot' and 'dispatcher' services are the same object,
+    // but 'dispatcher.boot' is resolvable earlier during bootstrap.
+    return Civi\Core\Container::getBootService('dispatcher.boot');
   }
 
   /**
@@ -75,10 +84,16 @@ class Civi {
   }
 
   /**
+   * Find or create a logger.
+   *
+   * @param string $channel
+   *   Symbolic name (or channel) of the intended log.
+   *   This should correlate to a service "log.{NAME}".
+   *
    * @return \Psr\Log\LoggerInterface
    */
-  public static function log() {
-    return Civi\Core\Container::singleton()->get('psr_log');
+  public static function log($channel = 'default') {
+    return \Civi\Core\Container::singleton()->get('psr_log_manager')->getLog($channel);
   }
 
   /**
@@ -90,6 +105,15 @@ class Civi {
     return \Civi\Core\Container::getBootService('paths');
   }
 
+  /**
+   * Obtain the formatting object.
+   *
+   * @return \Civi\Core\Format
+   */
+  public static function format(): Format {
+    return new Civi\Core\Format();
+  }
+
   /**
    * Fetch a service from the container.
    *
@@ -106,7 +130,7 @@ class Civi {
    * singletons, containers.
    */
   public static function reset() {
-    self::$statics = array();
+    self::$statics = [];
     Civi\Core\Container::singleton();
   }