/** * {@inheritdoc} */ public function getCleanSeparators($string, $separator = NULL) { $config = $this->configFactory->get('pathauto.settings'); if (!isset($separator)) { $separator = $config->get('separator'); } $output = $string; if (strlen($separator)) { // Trim any leading or trailing separators. $output = trim($output, $separator); // Escape the separator for use in regular expressions. $seppattern = preg_quote($separator, '/'); // Replace multiple separators with a single one. $output = preg_replace("/{$seppattern}+/", $separator, $output); // Replace trailing separators around slashes. if ($separator !== '/') { $output = preg_replace("/\\/+{$seppattern}\\/+|{$seppattern}\\/+|\\/+{$seppattern}/", "/", $output); } else { // If the separator is a slash, we need to re-add the leading slash // dropped by the trim function. $output = '/' . $output; } } return $output; }
/** * Attempts to log the authenticated CAS user into Drupal. * * This method should be used to login a user after they have successfully * authenticated with the CAS server. * * @param CasPropertyBag $property_bag * CasPropertyBag containing username and attributes from CAS. * * @throws CasLoginException */ public function loginToDrupal(CasPropertyBag $property_bag, $ticket) { $this->eventDispatcher->dispatch(CasHelper::CAS_PROPERTY_ALTER, new CasPropertyEvent($property_bag)); $account = $this->userLoadByName($property_bag->getUsername()); if (!$account) { $config = $this->settings->get('cas.settings'); if ($config->get('user_accounts.auto_register') === TRUE) { if (!$property_bag->getRegisterStatus()) { $_SESSION['cas_temp_disable'] = TRUE; throw new CasLoginException("Cannot register user, an event listener denied access."); } $account = $this->registerUser($property_bag->getUsername()); } else { throw new CasLoginException("Cannot login, local Drupal user account does not exist."); } } $this->eventDispatcher->dispatch(CasHelper::CAS_USER_ALTER, new CasUserEvent($account, $property_bag)); $account->save(); if (!$property_bag->getLoginStatus()) { $_SESSION['cas_temp_disable'] = TRUE; throw new CasLoginException("Cannot login, an event listener denied access."); } $this->userLoginFinalize($account); $this->storeLoginSessionData($this->sessionManager->getId(), $ticket); }
/** * Gets the configured error level. * * @return string */ protected function getErrorLevel() { if (!isset($this->errorLevel)) { $this->errorLevel = $this->configFactory->get('system.logging')->get('error_level'); } return $this->errorLevel; }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->aliasProcessor = $this->getMockBuilder('Drupal\Core\PathProcessor\PathProcessorAlias') ->disableOriginalConstructor() ->getMock(); $this->languageManager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $this->languageManager->expects($this->any()) ->method('getCurrentLanguage') ->willReturn(new Language(Language::$defaultValues)); $this->pathValidator = $this->getMock('Drupal\Core\Path\PathValidatorInterface'); $this->subPathautoSettings = $this->getMock('Drupal\Core\Config\ConfigBase'); $this->configFactory = $this->getMock('Drupal\Core\Config\ConfigFactoryInterface'); $this->configFactory->expects($this->any()) ->method('get') ->with('subpathauto.settings') ->willReturn($this->subPathautoSettings); $this->sut = new PathProcessor($this->aliasProcessor, $this->languageManager, $this->configFactory); $this->sut->setPathValidator($this->pathValidator); }
/** * Checks access to the given user's contact page. * * @param \Drupal\user\UserInterface $user * The user being contacted. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * * @return string * A \Drupal\Core\Access\AccessInterface constant value. */ public function access(UserInterface $user, AccountInterface $account) { $contact_account = $user; // Anonymous users cannot have contact forms. if ($contact_account->isAnonymous()) { return static::DENY; } // Users may not contact themselves. if ($account->id() == $contact_account->id()) { return static::DENY; } // User administrators should always have access to personal contact forms. if ($account->hasPermission('administer users')) { return static::ALLOW; } // If requested user has been blocked, do not allow users to contact them. if ($contact_account->isBlocked()) { return static::DENY; } // If the requested user has disabled their contact form, do not allow users // to contact them. $account_data = $this->userData->get('contact', $contact_account->id(), 'enabled'); if (isset($account_data) && empty($account_data)) { return static::DENY; } else { if (!$this->configFactory->get('contact.settings')->get('user_default_enabled')) { return static::DENY; } } return $account->hasPermission('access user contact forms') ? static::ALLOW : static::DENY; }
/** * Constructs a 'Disqus Comment Count' view field plugin. * * @param array $configuration * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implementation definition. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. * @param \Drupal\disqus\DisqusCommentManager $disqus_manager * The disqus comment manager object. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, AccountInterface $current_user, DisqusCommentManager $disqus_manager, ConfigFactoryInterface $config_factory) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->currentUser = $current_user; $this->disqusManager = $disqus_manager; $this->config = $config_factory->get('disqus.settings'); }
/** * Creates a SpoolStorage object. * * @param \Drupal\Core\Database\Connection $connection * The database connection. * @param \Drupal\Core\Lock\LockBackendInterface $lock * The lock. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Extension\ModuleHandlerInterface * The module handler. */ public function __construct(Connection $connection, LockBackendInterface $lock, ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) { $this->connection = $connection; $this->lock = $lock; $this->config = $config_factory->get('simplenews.settings'); $this->moduleHandler = $module_handler; }
/** * Constructs the secure login service. */ public function __construct(ConfigFactoryInterface $config_factory, EventDispatcherInterface $event_dispatcher, RequestStack $request_stack) { $this->config = $config_factory->get('securelogin.settings'); $this->eventDispatcher = $event_dispatcher; $this->requestStack = $request_stack; $this->request = $this->requestStack->getCurrentRequest(); }
/** * Constructs a new unroutedUrlAssembler object. * * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * A request stack object. * @param \Drupal\Core\Config\ConfigFactoryInterface $config * The config factory. * @param \Drupal\Core\PathProcessor\OutboundPathProcessorInterface $path_processor * The output path processor. */ public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, OutboundPathProcessorInterface $path_processor) { $allowed_protocols = $config->get('system.filter')->get('protocols') ?: ['http', 'https']; UrlHelper::setAllowedProtocols($allowed_protocols); $this->requestStack = $request_stack; $this->pathProcessor = $path_processor; }
/** * Constructs Disqus comments destination plugin. * * @param array $configuration * A configuration array containing information about the plugin instance. * @param string $plugin_id * The plugin_id for the plugin instance. * @param mixed $plugin_definition * The plugin implemetation definition. * @param \Drupal\migrate\Entity\MigrationInterface $migration * The migration. * @param \Psr\Log\LoggerInterface $logger * A logger instance. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. * @param \Drupal\Core\Entity\Query\QueryFactory $entity_query * The entity query factory. */ public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, LoggerInterface $logger, ConfigFactoryInterface $config_factory, QueryFactory $entity_query) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration); $this->logger = $logger; $this->config = $config_factory->get('disqus.settings'); $this->entityQuery = $entity_query; }
public function __construct(Client $http_client, LoggerChannelInterface $logger, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config) { $this->httpClient = $http_client; $this->logger = $logger; $this->moduleHandler = $module_handler; $this->config = $config->get('nodejs.config')->get(); }
/** * {@inheritdoc} */ public function collect(Request $request, Response $response, \Exception $exception = NULL) { $connections = []; foreach (Database::getAllConnectionInfo() as $key => $info) { $database = Database::getConnection('default', $key); $connections[$key] = $database->getLogger()->get('webprofiler'); } $this->data['connections'] = array_keys($connections); $data = []; foreach ($connections as $key => $queries) { foreach ($queries as $query) { // Remove caller args. unset($query['caller']['args']); // Remove query args element if empty. if (empty($query['args'])) { unset($query['args']); } // Save time in milliseconds. $query['time'] = $query['time'] * 1000; $query['database'] = $key; $data[] = $query; } } $querySort = $this->configFactory->get('webprofiler.config')->get('query_sort'); if ('duration' === $querySort) { usort($data, ["Drupal\\webprofiler\\DataCollector\\DatabaseDataCollector", "orderQueryByTime"]); } $this->data['queries'] = $data; $options = $this->database->getConnectionOptions(); // Remove password for security. unset($options['password']); $this->data['database'] = $options; }
/** * Constructs dropzone upload controller route controller. * * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack * The request stack. * @param \Drupal\Core\Config\ConfigFactoryInterface $config * Config factory. * @param \Drupal\Core\Transliteration\PhpTransliteration $transliteration * Transliteration service. */ public function __construct(RequestStack $request_stack, ConfigFactoryInterface $config, TransliterationInterface $transliteration) { $this->request = $request_stack->getCurrentRequest(); $tmp_override = $config->get('dropzonejs.settings')->get('tmp_dir'); $this->temporaryUploadLocation = $tmp_override ?: $config->get('system.file')->get('path.temporary'); $this->transliteration = $transliteration; }
/** * Constructs a FinishResponseSubscriber object. * * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager object for retrieving the correct language code. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * A config factory for retrieving required config objects. * @param \Drupal\Core\PageCache\RequestPolicyInterface $request_policy * A policy rule determining the cacheability of a request. * @param \Drupal\Core\PageCache\ResponsePolicyInterface $response_policy * A policy rule determining the cacheability of a response. */ public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy) { $this->languageManager = $language_manager; $this->config = $config_factory->get('system.performance'); $this->requestPolicy = $request_policy; $this->responsePolicy = $response_policy; }
/** * Redirects on 403 Access Denied kernel exceptions. * * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The Event to process. */ public function onKernelException(GetResponseEvent $event) { $exception = $event->getException(); if (!$exception instanceof AccessDeniedHttpException) { return; } $config = $this->configFactory->get('r4032login.settings'); $options = array(); $options['query'] = $this->redirectDestination->getAsArray(); $options['absolute'] = TRUE; $code = $config->get('default_redirect_code'); if ($this->currentUser->isAnonymous()) { // Show custom access denied message if set. if ($config->get('display_denied_message')) { $message = $config->get('access_denied_message'); $message_type = $config->get('access_denied_message_type'); drupal_set_message(Xss::filterAdmin($message), $message_type); } // Handle redirection to the login form. $login_route = $config->get('user_login_route'); $url = Url::fromRoute($login_route, array(), $options)->toString(); $response = new RedirectResponse($url, $code); $event->setResponse($response); } else { // Check to see if we are to redirect the user. $redirect = $config->get('redirect_authenticated_users_to'); if ($redirect) { // Custom access denied page for logged in users. $url = Url::fromUserInput($redirect, $options)->toString(); $response = new RedirectResponse($url, $code); $event->setResponse($response); } } }
/** * {@inheritdoc} */ public function on404(GetResponseForExceptionEvent $event) { $custom_404_path = $this->configFactory->get('system.site')->get('page.404'); if (!empty($custom_404_path)) { $this->makeSubrequest($event, $custom_404_path, Response::HTTP_NOT_FOUND); } }
/** * {@inheritdoc} */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $settings = $this->configFactory->get('ivw_integration.settings'); if ($settings->get('offering_overridable')) { $element['offering'] = array('#type' => 'textfield', '#title' => t('Offering code'), '#default_value' => isset($items[$delta]->offering) ? $items[$delta]->offering : NULL, '#description' => t('A single ivw site can have multiple offerings, they can be differentiated by different numbers.'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#min' => 1); } if ($settings->get('language_overridable')) { $element['language'] = array('#type' => 'select', '#options' => array(1 => 'Deutsch', 2 => 'Andere Sprache, Inhalt prüfbar', 3 => 'Andere Sprache, Inhalt nicht prüfbar'), '#title' => t('Language'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->language) ? $items[$delta]->language : NULL); } if ($settings->get('format_overridable')) { $element['format'] = array('#type' => 'select', '#options' => array(1 => 'Bild/Text', 2 => 'Audio', 3 => 'Video', 4 => 'Andere dynamische Formate'), '#title' => t('Format'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->format) ? $items[$delta]->format : NULL); } if ($settings->get('creator_overridable')) { $element['creator'] = array('#type' => 'select', '#options' => array(1 => 'Redaktion', 2 => 'User', 3 => 'Unbekannt'), '#title' => t('Creator'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->creator) ? $items[$delta]->creator : NULL); } if ($settings->get('homepage_overridable')) { $element['homepage'] = array('#type' => 'select', '#options' => array(1 => 'Homepage des Angebots', 2 => 'Keine Homepage', 3 => 'Hompage der Fremddomains bei Multi-Angeboten'), '#title' => t('Homepage flag'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->homepage) ? $items[$delta]->homepage : NULL); } if ($settings->get('delivery_overridable')) { $element['delivery'] = array('#type' => 'select', '#options' => array(1 => 'Online', 2 => 'Mobile', 3 => 'Connected TV'), '#title' => t('Delivery'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->delivery) ? $items[$delta]->delivery : NULL); } if ($settings->get('app_overridable')) { $element['app'] = array('#type' => 'select', '#options' => array(1 => 'App', 2 => 'Keine App'), '#title' => t('Fallback app flag'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->app) ? $items[$delta]->app : NULL); } if ($settings->get('paid_overridable')) { $element['paid'] = array('#type' => 'select', '#options' => array(1 => 'Paid', 2 => 'Nicht zugeordnet'), '#title' => t('Paid flag'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->paid) ? $items[$delta]->paid : NULL); } if ($settings->get('content_overridable')) { $element['content'] = array('#type' => 'select', '#group' => 'ivw_integration_settings_override', '#options' => array('01' => 'Nachrichten', '02' => 'Sport', '03' => 'Entertainment/Boulevard/Stars/Film/Musik', '04' => 'Fashion/Beauty', '05' => 'Familie/Kinder/Lebenshilfe', '06' => 'Liebe/Psychologie/Beziehungen', '07' => 'Fahrzeuge/Verkehr/Mobilität', '08' => 'Reise/Touristik', '09' => 'Computer', '10' => 'Consumer Electronics', '11' => 'Telekommunikation/Internetdienste', '12' => 'Spiele', '13' => 'Wohnen/Immobilien/Garten/Haushalt', '14' => 'Wirtschaft/Finanzen/Job/Karriere', '15' => 'Gesundheit', '16' => 'Essen/Trinken', '17' => 'Kunst/Kultur/Literatur', '18' => 'Erotik', '19' => 'Wissenschaft/Bildung/Natur/Umwelt', '20' => 'Angebotsinformation', '21' => 'Vermischtes (multithematisch)', '22' => 'Sonstiges (monothematisch)', '23' => 'Übersichtsseite zu Spiele', '24' => 'Casual Games', '25' => 'Core Games', '26' => 'Sonstiges (Bereich Spiele)', '27' => 'Social Networking - Privat', '28' => 'Social Networking - Business', '29' => 'Partnersuche/Dating', '30' => 'Newsletter', '31' => 'E-Mail/SMS/E-Cards', '32' => 'Messenger/Chat', '33' => 'Sonstiges (Bereich Networking/Kommunikation', '34' => 'Suchmaschinen', '35' => 'Verzeichnisse/Auskunftsdienste', '36' => 'Sonstiges (Bereich Suchmaschinen/Verzeichnisse)', '37' => 'Onlineshops/Shopping Mall/Auktionen/B2bMarktplätze', '38' => 'Immobilien Rubrikenmärkte/Kleinanzeigen', '39' => 'Jobs Rubrikenmärkte/Kleinanzeigen', '40' => 'Fahrzeuge Rubrikenmärkte/Kleinanzeigen', '41' => 'Sonstiges Rubrikenmärkte/Kleinanzeigen', '42' => 'Sonstiges (Bereich E-Commerce)'), '#title' => t('Content category'), '#required' => FALSE, '#empty_option' => t('Site default value'), '#default_value' => isset($items[$delta]->content) ? $items[$delta]->content : NULL); } return $element; }
/** * Checks access to the given user's contact page. * * @param \Drupal\user\UserInterface $user * The user being contacted. * @param \Drupal\Core\Session\AccountInterface $account * The currently logged in account. * * @return \Drupal\Core\Access\AccessResultInterface * The access result. */ public function access(UserInterface $user, AccountInterface $account) { $contact_account = $user; // Anonymous users cannot have contact forms. if ($contact_account->isAnonymous()) { return AccessResult::forbidden(); } // Users may not contact themselves. if ($account->id() == $contact_account->id()) { return AccessResult::forbidden()->cachePerUser(); } // User administrators should always have access to personal contact forms. $access = AccessResult::neutral()->cachePerRole(); $permission_access = AccessResult::allowedIfHasPermission($account, 'administer users'); if ($permission_access->isAllowed()) { return $access->orIf($permission_access); } // If requested user has been blocked, do not allow users to contact them. $access->cacheUntilEntityChanges($contact_account); if ($contact_account->isBlocked()) { return $access; } // If the requested user has disabled their contact form, do not allow users // to contact them. $account_data = $this->userData->get('contact', $contact_account->id(), 'enabled'); if (isset($account_data) && empty($account_data)) { return $access; } else { if (!$this->configFactory->get('contact.settings')->get('user_default_enabled')) { return $access; } } return $access->orIf(AccessResult::allowedIfHasPermission($account, 'access user contact forms')); }
/** * Constructs a DevelEventSubscriber object. */ public function __construct(ConfigFactoryInterface $config, AccountInterface $account, ModuleHandlerInterface $module_handler, UrlGeneratorInterface $url_generator) { $this->config = $config->get('devel.settings'); $this->account = $account; $this->moduleHandler = $module_handler; $this->urlGenerator = $url_generator; }
/** * Causes the container to be rebuilt on the next request. * * This event subscriber assumes that the new default langcode and old default * langcode are valid langcodes. If the schema definition of either * system.site:default_langcode or language.negotiation::url.prefixes changes * then this event must be changed to work with both the old and new schema * definition so this event is update safe. * * @param ConfigCrudEvent $event * The configuration event. */ public function onConfigSave(ConfigCrudEvent $event) { $saved_config = $event->getConfig(); if ($saved_config->getName() == 'system.site' && $event->isChanged('default_langcode')) { $new_default_langcode = $saved_config->get('default_langcode'); $default_language = $this->configFactory->get('language.entity.' . $new_default_langcode); // During an import the language might not exist yet. if (!$default_language->isNew()) { $this->languageDefault->set(new Language($default_language->get())); $this->languageManager->reset(); // Directly update language negotiation settings instead of calling // language_negotiation_url_prefixes_update() to ensure that the code // obeys the hook_update_N() restrictions. $negotiation_config = $this->configFactory->getEditable('language.negotiation'); $negotiation_changed = FALSE; $url_prefixes = $negotiation_config->get('url.prefixes'); $old_default_langcode = $saved_config->getOriginal('default_langcode'); if (empty($url_prefixes[$old_default_langcode])) { $negotiation_config->set('url.prefixes.' . $old_default_langcode, $old_default_langcode); $negotiation_changed = TRUE; } if (empty($url_prefixes[$new_default_langcode])) { $negotiation_config->set('url.prefixes.' . $new_default_langcode, ''); $negotiation_changed = TRUE; } if ($negotiation_changed) { $negotiation_config->save(TRUE); } } // Trigger a container rebuild on the next request by invalidating it. ConfigurableLanguageManager::rebuildServices(); } }
/** * Constructs an EntityComparisonBase object. * * @param DiffBuilderManager $diffBuilderManager * The diff field builder plugin manager. * @param EntityManagerInterface $entityManager * Entity Manager service. * @param ConfigFactoryInterface $configFactory * The configuration factory. */ public function __construct(DiffBuilderManager $diffBuilderManager, EntityManagerInterface $entityManager, ConfigFactoryInterface $configFactory) { $this->entityManager = $entityManager; $this->config = $configFactory->get('diff.settings'); $this->pluginsConfig = $configFactory->get('diff.plugins'); $this->diffBuilderManager = $diffBuilderManager; }
/** * Constructs a new NgLightbox service. * * @param \Drupal\Core\Path\PathMatcherInterface $path_matcher * Patch matcher services for comparing the lightbox patterns. * @param \Drupal\Core\Path\AliasManagerInterface $alias_manager * Alias manager so we can also test path aliases. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory so we can get the lightbox settings. */ public function __construct(PathMatcherInterface $path_matcher, AliasManagerInterface $alias_manager, ConfigFactoryInterface $config_factory, AdminContext $admin_context) { $this->pathMatcher = $path_matcher; $this->aliasManager = $alias_manager; $this->config = $config_factory->get('ng_lightbox.settings'); $this->adminContext = $admin_context; }
/** * Constructs an Importer object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $fetcher_manager * The aggregator fetcher plugin manager. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $parser_manager * The aggregator parser plugin manager. * @param \Drupal\aggregator\Plugin\AggregatorPluginManager $processor_manager * The aggregator processor plugin manager. */ public function __construct(ConfigFactoryInterface $config_factory, AggregatorPluginManager $fetcher_manager, AggregatorPluginManager $parser_manager, AggregatorPluginManager $processor_manager) { $this->fetcherManager = $fetcher_manager; $this->processorManager = $processor_manager; $this->parserManager = $parser_manager; $this->config = $config_factory->get('aggregator.settings'); }
/** * {@inheritdoc} */ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { $config = $this->configFactory->get('shield.settings'); $allow_cli = $config->get('allow_cli'); $user = $config->get('user'); $pass = $config->get('pass'); if (empty($user) || PHP_SAPI === 'cli' && $allow_cli) { // If username is empty, then authentication is disabled, // or if request is coming from a cli and it is allowed, // then proceed with response without shield authentication. return $this->httpKernel->handle($request, $type, $catch); } else { if ($request->server->has('PHP_AUTH_USER') && $request->server->has('PHP_AUTH_PW')) { $input_user = $request->server->get('PHP_AUTH_USER'); $input_pass = $request->server->get('PHP_AUTH_PW'); } elseif ($request->server->has('HTTP_AUTHORIZATION')) { list($input_user, $input_pass) = explode(':', base64_decode(substr($request->server->get('HTTP_AUTHORIZATION'), 6)), 2); } elseif ($request->server->has('REDIRECT_HTTP_AUTHORIZATION')) { list($input_user, $input_pass) = explode(':', base64_decode(substr($request->server->get('REDIRECT_HTTP_AUTHORIZATION'), 6)), 2); } if (isset($input_user) && $input_user === $user && Crypt::hashEquals($pass, $input_pass)) { return $this->httpKernel->handle($request, $type, $catch); } } $response = new Response(); $response->headers->add(['WWW-Authenticate' => 'Basic realm="' . strtr($config->get('print'), ['[user]' => $user, '[pass]' => $pass]) . '"']); $response->setStatusCode(401); return $response; }
/** * Implements Drupal\Core\PathProcessor\InboundPathProcessorInterface::processInbound(). */ public function processInbound($path, Request $request) { if (empty($path)) { $path = $this->config->get('system.site')->get('page.front'); } return $path; }
/** * @param ConfigFactoryInterface $config * @param \Drupal\Core\Access\AccessManager $access_manager * The access manager service. * @param \Drupal\Core\Session\AccountInterface $account * The account object. * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * The route provider service. */ public function __construct(ConfigFactoryInterface $config, AccessManager $access_manager, AccountInterface $account, RouteProviderInterface $route_provider) { $this->config = $config->get('globalredirect.settings'); $this->accessManager = $access_manager; $this->account = $account; $this->routeProvider = $route_provider; }
/** * Sets options based on admin input parameters for rendering. * * @param array $options * The array of options to the sitemap theme. * @param string $option_string * The string index given from the admin form to match. * @param int $equal_param * Result of param test, 0 or 1. * @param string $set_string * Index of option to set, or the option name. * @param bool $set_value * The option, on or off, or strings or ints for other options. */ public function setOption(array &$options, $option_string, $equal_param, $set_string, $set_value) { $config = $this->configFactory->get('sitemap.settings'); if ($config->get($option_string) == $equal_param) { $options[$set_string] = $set_value; } }
/** * Constructs a NegotiationConfigureForm object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The factory for configuration objects. * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager * The language manager. * @param \Drupal\language\LanguageNegotiatorInterface $negotiator * The language negotiation methods manager. * @param \Drupal\block\BlockManagerInterface $block_manager * The block manager, or NULL if not available. */ public function __construct(ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager, LanguageNegotiatorInterface $negotiator, BlockManagerInterface $block_manager = NULL) { $this->languageTypes = $config_factory->get('language.types'); $this->languageManager = $language_manager; $this->negotiator = $negotiator; $this->blockManager = $block_manager; }
/** * Constructs the MailManager object. * * @param \Traversable $namespaces * An object that implements \Traversable which contains the root paths * keyed by the corresponding namespace to look for plugin implementations. * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend * Cache backend instance to use. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke the alter hook with. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The configuration factory. */ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, ConfigFactoryInterface $config_factory) { parent::__construct('Plugin/Mail', $namespaces, $module_handler, 'Drupal\\Core\\Annotation\\Mail'); $this->alterInfo('mail_backend_info'); $this->setCacheBackend($cache_backend, 'mail_backend_plugins'); $this->mailConfig = $config_factory->get('system.mail'); }
/** * Constructs a XmlSitemapGenerator object. * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory object. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager handler. * @param \Drupal\Core\State\StateInterface $state * The state handler. */ public function __construct(ConfigFactoryInterface $config_factory, EntityManagerInterface $entity_manager, StateInterface $state, LanguageManagerInterface $language_manager) { $this->config = $config_factory->getEditable('xmlsitemap.settings'); $this->entityManager = $entity_manager; $this->state = $state; $this->languageManager = $language_manager; }