123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791 |
- <?php
- use Drupal\Core\DependencyInjection\ContainerNotInitializedException;
- use Drupal\Core\Messenger\LegacyMessenger;
- use Drupal\Core\Url;
- use Symfony\Component\DependencyInjection\ContainerInterface;
- class Drupal {
-
- const VERSION = '8.9.7';
-
- const CORE_COMPATIBILITY = '8.x';
-
- const CORE_MINIMUM_SCHEMA_VERSION = 8000;
-
- protected static $container;
-
- public static function setContainer(ContainerInterface $container) {
- static::$container = $container;
- }
-
- public static function unsetContainer() {
- static::$container = NULL;
- }
-
- public static function getContainer() {
- if (static::$container === NULL) {
- throw new ContainerNotInitializedException('\Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container.');
- }
- return static::$container;
- }
-
- public static function hasContainer() {
- return static::$container !== NULL;
- }
-
- public static function service($id) {
- return static::getContainer()->get($id);
- }
-
- public static function hasService($id) {
-
- return static::hasContainer() && static::getContainer()->has($id);
- }
-
- public static function root() {
- return static::getContainer()->get('app.root');
- }
-
- public static function installProfile() {
- return static::getContainer()->getParameter('install_profile');
- }
-
- public static function hasRequest() {
-
- return static::hasContainer() && static::getContainer()->has('request_stack') && static::getContainer()->get('request_stack')->getCurrentRequest() !== NULL;
- }
-
- public static function request() {
- return static::getContainer()->get('request_stack')->getCurrentRequest();
- }
-
- public static function requestStack() {
- return static::getContainer()->get('request_stack');
- }
-
- public static function routeMatch() {
- return static::getContainer()->get('current_route_match');
- }
-
- public static function currentUser() {
- return static::getContainer()->get('current_user');
- }
-
- public static function entityManager() {
- @trigger_error("\Drupal::entityManager() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager() instead in most cases. If the needed method is not on \Drupal\Core\Entity\EntityTypeManagerInterface, see the deprecated \Drupal\Core\Entity\EntityManager to find the correct interface or service. See https://www.drupal.org/node/2549139", E_USER_DEPRECATED);
- return static::getContainer()->get('entity.manager');
- }
-
- public static function entityTypeManager() {
- return static::getContainer()->get('entity_type.manager');
- }
-
- public static function database() {
- return static::getContainer()->get('database');
- }
-
- public static function cache($bin = 'default') {
- return static::getContainer()->get('cache.' . $bin);
- }
-
- public static function classResolver($class = NULL) {
- if ($class) {
- return static::getContainer()->get('class_resolver')->getInstanceFromDefinition($class);
- }
- return static::getContainer()->get('class_resolver');
- }
-
- public static function keyValueExpirable($collection) {
- return static::getContainer()->get('keyvalue.expirable')->get($collection);
- }
-
- public static function lock() {
- return static::getContainer()->get('lock');
- }
-
- public static function config($name) {
- return static::getContainer()->get('config.factory')->get($name);
- }
-
- public static function configFactory() {
- return static::getContainer()->get('config.factory');
- }
-
- public static function queue($name, $reliable = FALSE) {
- return static::getContainer()->get('queue')->get($name, $reliable);
- }
-
- public static function keyValue($collection) {
- return static::getContainer()->get('keyvalue')->get($collection);
- }
-
- public static function state() {
- return static::getContainer()->get('state');
- }
-
- public static function httpClient() {
- return static::getContainer()->get('http_client');
- }
-
- public static function entityQuery($entity_type, $conjunction = 'AND') {
- return static::entityTypeManager()->getStorage($entity_type)->getQuery($conjunction);
- }
-
- public static function entityQueryAggregate($entity_type, $conjunction = 'AND') {
- return static::entityTypeManager()->getStorage($entity_type)->getAggregateQuery($conjunction);
- }
-
- public static function flood() {
- return static::getContainer()->get('flood');
- }
-
- public static function moduleHandler() {
- return static::getContainer()->get('module_handler');
- }
-
- public static function typedDataManager() {
- return static::getContainer()->get('typed_data_manager');
- }
-
- public static function token() {
- return static::getContainer()->get('token');
- }
-
- public static function urlGenerator() {
- return static::getContainer()->get('url_generator');
- }
-
- public static function url($route_name, $route_parameters = [], $options = [], $collect_bubbleable_metadata = FALSE) {
- @trigger_error('Drupal::url() is deprecated as of Drupal 8.0.x, will be removed before Drupal 9.0.0. Instead create a \Drupal\Core\Url object directly, for example using Url::fromRoute()', E_USER_DEPRECATED);
- return static::getContainer()->get('url_generator')->generateFromRoute($route_name, $route_parameters, $options, $collect_bubbleable_metadata);
- }
-
- public static function linkGenerator() {
- return static::getContainer()->get('link_generator');
- }
-
- public static function l($text, Url $url) {
- @trigger_error('\Drupal::l() is deprecated in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Link::fromTextAndUrl() instead. See https://www.drupal.org/node/2614344', E_USER_DEPRECATED);
- return static::getContainer()->get('link_generator')->generate($text, $url);
- }
-
- public static function translation() {
- return static::getContainer()->get('string_translation');
- }
-
- public static function languageManager() {
- return static::getContainer()->get('language_manager');
- }
-
- public static function csrfToken() {
- return static::getContainer()->get('csrf_token');
- }
-
- public static function transliteration() {
- return static::getContainer()->get('transliteration');
- }
-
- public static function formBuilder() {
- return static::getContainer()->get('form_builder');
- }
-
- public static function theme() {
- return static::getContainer()->get('theme.manager');
- }
-
- public static function isConfigSyncing() {
- return static::getContainer()->get('config.installer')->isSyncing();
- }
-
- public static function logger($channel) {
- return static::getContainer()->get('logger.factory')->get($channel);
- }
-
- public static function menuTree() {
- return static::getContainer()->get('menu.link_tree');
- }
-
- public static function pathValidator() {
- return static::getContainer()->get('path.validator');
- }
-
- public static function accessManager() {
- return static::getContainer()->get('access_manager');
- }
-
- public static function destination() {
- return static::getContainer()->get('redirect.destination');
- }
-
- public static function entityDefinitionUpdateManager() {
- return static::getContainer()->get('entity.definition_update_manager');
- }
-
- public static function time() {
- return static::getContainer()->get('datetime.time');
- }
-
- public static function messenger() {
-
-
- return new LegacyMessenger();
- }
- }
|