X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal.php;h=014aea27f0f0a4eab65cbd32baf8203c58858c83;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=9371f1e5f1c98d300780ffb4bbbffa60430d8c4e;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal.php b/web/core/lib/Drupal.php index 9371f1e5f..014aea27f 100644 --- a/web/core/lib/Drupal.php +++ b/web/core/lib/Drupal.php @@ -6,8 +6,9 @@ */ use Drupal\Core\DependencyInjection\ContainerNotInitializedException; -use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Messenger\LegacyMessenger; use Drupal\Core\Url; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Static Service Container wrapper. @@ -81,7 +82,7 @@ class Drupal { /** * The current system version. */ - const VERSION = '8.3.4'; + const VERSION = '8.6.4'; /** * Core API compatibility. @@ -140,7 +141,6 @@ class Drupal { return static::$container !== NULL; } - /** * Retrieves a service from the container. * @@ -229,7 +229,7 @@ class Drupal { } /** - * Retrives the request stack. + * Retrieves the request stack. * * @return \Symfony\Component\HttpFoundation\RequestStack * The request stack @@ -319,10 +319,20 @@ class Drupal { * 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'); } @@ -757,4 +767,16 @@ class Drupal { return static::getContainer()->get('datetime.time'); } + /** + * Returns the messenger. + * + * @return \Drupal\Core\Messenger\MessengerInterface + * The messenger. + */ + public static function messenger() { + // @todo Replace with service once LegacyMessenger is removed in 9.0.0. + // @see https://www.drupal.org/node/2928994 + return new LegacyMessenger(); + } + }