diff core/lib/Drupal.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
line wrap: on
line diff
--- a/core/lib/Drupal.php	Tue Jul 10 15:07:59 2018 +0100
+++ b/core/lib/Drupal.php	Thu Feb 28 13:21:36 2019 +0000
@@ -82,7 +82,7 @@
   /**
    * The current system version.
    */
-  const VERSION = '8.5.5';
+  const VERSION = '8.6.10';
 
   /**
    * Core API compatibility.
@@ -141,7 +141,6 @@
     return static::$container !== NULL;
   }
 
-
   /**
    * Retrieves a service from the container.
    *
@@ -230,7 +229,7 @@
   }
 
   /**
-   * Retrives the request stack.
+   * Retrieves the request stack.
    *
    * @return \Symfony\Component\HttpFoundation\RequestStack
    *   The request stack
@@ -320,10 +319,20 @@
    * One common usecase is to provide a class which contains the actual code
    * of a hook implementation, without having to create a service.
    *
-   * @return \Drupal\Core\DependencyInjection\ClassResolverInterface
-   *   The class resolver.
+   * @param string $class
+   *   (optional) A class name to instantiate.
+   *
+   * @return \Drupal\Core\DependencyInjection\ClassResolverInterface|object
+   *   The class resolver or if $class is provided, a class instance with a
+   *   given class definition.
+   *
+   * @throws \InvalidArgumentException
+   *   If $class does not exist.
    */
-  public static function classResolver() {
+  public static function classResolver($class = NULL) {
+    if ($class) {
+      return static::getContainer()->get('class_resolver')->getInstanceFromDefinition($class);
+    }
     return static::getContainer()->get('class_resolver');
   }