本文整理汇总了PHP中Drupal\Core\Config\ConfigFactoryInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFactoryInterface::get方法的具体用法?PHP ConfigFactoryInterface::get怎么用?PHP ConfigFactoryInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Config\ConfigFactoryInterface
的用法示例。
在下文中一共展示了ConfigFactoryInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getErrorLevel
/**
* 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;
}
示例2: resolveCurrencyLocale
/**
* {@inheritdoc}
*/
public function resolveCurrencyLocale($language_type = LanguageInterface::TYPE_CONTENT)
{
if (empty($this->currencyLocales[$language_type])) {
$currency_locale = NULL;
$language_code = $this->languageManager->getCurrentLanguage($language_type)->getId();
// Try this request's country code.
$country_code = $this->eventDispatcher->resolveCountryCode();
if ($country_code) {
$currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code);
}
// Try the site's default country code.
if (!$currency_locale) {
$country_code = $this->configFactory->get('system.data')->get('country.default');
if ($country_code) {
$currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code);
}
}
// Try the Currency default.
if (!$currency_locale) {
$currency_locale = $this->currencyLocaleStorage->load($this::DEFAULT_LOCALE);
}
if ($currency_locale) {
$this->currencyLocales[$language_type] = $currency_locale;
} else {
throw new \RuntimeException(sprintf('The currency locale for %s could not be loaded.', $this::DEFAULT_LOCALE));
}
}
return $this->currencyLocales[$language_type];
}
示例3: __construct
/**
* 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;
}
示例4: collect
/**
* {@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;
}
示例5: getCleanSeparators
/**
* {@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;
}
示例6: processInbound
/**
* 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;
}
示例7: handle
/**
* {@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;
}
示例8: onConfigSave
/**
* 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();
}
}
示例9: getConfig
/**
* Gets the configuration object when needed.
*
* Since this service is injected into all static menu link objects, but
* only used when updating one, avoid actually loading the config when it's
* not needed.
*/
protected function getConfig()
{
if (empty($this->config)) {
$this->config = $this->configFactory->get($this->configName);
}
return $this->config;
}
示例10: formElement
/**
* {@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;
}
示例11: access
/**
* 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'));
}
示例12: access
/**
* 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;
}
示例13: __construct
/**
* 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;
}
示例14: on404
/**
* {@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);
}
}
示例15: onKernelException
/**
* 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);
}
}
}