当前位置: 首页>>代码示例>>PHP>>正文


PHP Config::get方法代码示例

本文整理汇总了PHP中Drupal\Core\Config\Config::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::get方法的具体用法?PHP Config::get怎么用?PHP Config::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Config\Config的用法示例。


在下文中一共展示了Config::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: canRedirect

 /**
  * Determines if redirect may be performed.
  *
  * @param Request $request
  *   The current request object.
  * @param string $route_name
  *   The current route name.
  *
  * @return bool
  *   TRUE if redirect may be performed.
  */
 public function canRedirect(Request $request, $route_name = NULL)
 {
     $can_redirect = TRUE;
     if (isset($route_name)) {
         $route = $this->routeProvider->getRouteByName($route_name);
         if ($this->config->get('access_check')) {
             // Do not redirect if is a protected page.
             $can_redirect &= $this->accessManager->check($route, $request, $this->account);
         }
     } else {
         $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     }
     if (strpos($request->getScriptName(), 'index.php') === FALSE) {
         // Do not redirect if the root script is not /index.php.
         $can_redirect = FALSE;
     } elseif (!($request->isMethod('GET') || $request->isMethod('HEAD'))) {
         // Do not redirect if this is other than GET request.
         $can_redirect = FALSE;
     } elseif ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE')) {
         // Do not redirect in offline or maintenance mode.
         $can_redirect = FALSE;
     } elseif ($this->config->get('ignore_admin_path') && isset($route)) {
         // Do not redirect on admin paths.
         $can_redirect &= !(bool) $route->getOption('_admin_route');
     }
     return $can_redirect;
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:38,代码来源:RedirectChecker.php

示例2: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb[] = Link::createFromRoute($this->t('Home'), '<front>');
     $vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($this->config->get('vocabulary'));
     $breadcrumb[] = Link::createFromRoute($vocabulary->label(), 'forum.index');
     return $breadcrumb;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:ForumBreadcrumbBuilderBase.php

示例3: get

 /**
  * {@inheritdoc}
  */
 public function get($key, $defaultValue = NULL)
 {
     $value = $this->config->get('settings.' . $key);
     if ($value == NULL) {
         return $defaultValue;
     }
     return $value;
 }
开发者ID:AohRveTPV,项目名称:security_review,代码行数:11,代码来源:CheckSettings.php

示例4: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     if ($this->sharethisSettings->get('location') === 'block') {
         $st_js = $this->sharethisManager->sharethisIncludeJs();
         $markup = $this->sharethisManager->blockContents();
         return ['#theme' => 'sharethis_block', '#content' => $markup, '#attached' => array('library' => array('sharethis/sharethispickerexternalbuttonsws', 'sharethis/sharethispickerexternalbuttons', 'sharethis/sharethis'), 'drupalSettings' => array('sharethis' => $st_js))];
     }
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:11,代码来源:SharethisBlock.php

示例5: refresh

 /**
  * {@inheritdoc}
  */
 public function refresh(FeedInterface $feed)
 {
     // Store feed URL to track changes.
     $feed_url = $feed->getUrl();
     // Fetch the feed.
     try {
         $success = $this->fetcherManager->createInstance($this->config->get('fetcher'))->fetch($feed);
     } catch (PluginException $e) {
         $success = FALSE;
         watchdog_exception('aggregator', $e);
     }
     // Store instances in an array so we dont have to instantiate new objects.
     $processor_instances = array();
     foreach ($this->config->get('processors') as $processor) {
         try {
             $processor_instances[$processor] = $this->processorManager->createInstance($processor);
         } catch (PluginException $e) {
             watchdog_exception('aggregator', $e);
         }
     }
     // We store the hash of feed data in the database. When refreshing a
     // feed we compare stored hash and new hash calculated from downloaded
     // data. If both are equal we say that feed is not updated.
     $hash = hash('sha256', $feed->source_string);
     $has_new_content = $success && $feed->getHash() != $hash;
     if ($has_new_content) {
         // Parse the feed.
         try {
             if ($this->parserManager->createInstance($this->config->get('parser'))->parse($feed)) {
                 if (!$feed->getWebsiteUrl()) {
                     $feed->setWebsiteUrl($feed->getUrl());
                 }
                 $feed->setHash($hash);
                 // Update feed with parsed data.
                 $feed->save();
                 // Log if feed URL has changed.
                 if ($feed->getUrl() != $feed_url) {
                     $this->logger->notice('Updated URL for feed %title to %url.', array('%title' => $feed->label(), '%url' => $feed->getUrl()));
                 }
                 $this->logger->notice('There is new syndicated content from %site.', array('%site' => $feed->label()));
                 // If there are items on the feed, let enabled processors process them.
                 if (!empty($feed->items)) {
                     foreach ($processor_instances as $instance) {
                         $instance->process($feed);
                     }
                 }
             }
         } catch (PluginException $e) {
             watchdog_exception('aggregator', $e);
         }
     }
     // Processing is done, call postProcess on enabled processors.
     foreach ($processor_instances as $instance) {
         $instance->postProcess($feed);
     }
     return $has_new_content;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:60,代码来源:ItemsImporter.php

示例6: __construct

 /**
  * Constructs a ImageEffectsPluginBase object.
  *
  * @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\Config\ConfigFactoryInterface $config_factory
  *   The configuration factory.
  * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator
  *   The URL generator.
  * @param \Psr\Log\LoggerInterface $logger
  *   The image_effects logger.
  */
 public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, UrlGeneratorInterface $url_generator, LoggerInterface $logger)
 {
     $this->config = $config_factory->getEditable('image_effects.settings');
     parent::__construct($configuration, $plugin_id, $plugin_definition);
     $this->pluginType = $configuration['plugin_type'];
     $config = $this->config->get($this->pluginType . '.plugin_settings.' . $plugin_id);
     $this->setConfiguration(array_merge($this->defaultConfiguration(), is_array($config) ? $config : array()));
     $this->urlGenerator = $url_generator;
     $this->logger = $logger;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:26,代码来源:ImageEffectsPluginBase.php

示例7: onTerminate

 /**
  * Run the automated cron if enabled.
  *
  * @param \Symfony\Component\HttpKernel\Event\PostResponseEvent $event
  *   The Event to process.
  */
 public function onTerminate(PostResponseEvent $event)
 {
     $interval = $this->config->get('interval');
     if ($interval > 0) {
         $cron_next = $this->state->get('system.cron_last', 0) + $interval;
         if ((int) $event->getRequest()->server->get('REQUEST_TIME') > $cron_next) {
             $this->cron->run();
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:16,代码来源:AutomatedCron.php

示例8: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = new Breadcrumb();
     $breadcrumb->addCacheContexts(['route']);
     $links[] = Link::createFromRoute($this->t('Home'), '<front>');
     $vocabulary = $this->entityManager->getStorage('taxonomy_vocabulary')->load($this->config->get('vocabulary'));
     $breadcrumb->addCacheableDependency($vocabulary);
     $links[] = Link::createFromRoute($vocabulary->label(), 'forum.index');
     return $breadcrumb->setLinks($links);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:ForumBreadcrumbBuilderBase.php

示例9: log

 /**
  * {@inheritdoc}
  */
 public function log($level, $message, array $context = array())
 {
     global $base_url;
     // Ensure we have a connection available.
     $this->openConnection();
     // Populate the message placeholders and then replace them in the message.
     $message_placeholders = $this->parser->parseMessagePlaceholders($message, $context);
     $message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
     $entry = strtr($this->config->get('format'), array('!base_url' => $base_url, '!timestamp' => $context['timestamp'], '!type' => $context['channel'], '!ip' => $context['ip'], '!request_uri' => $context['request_uri'], '!referer' => $context['referer'], '!uid' => $context['uid'], '!link' => strip_tags($context['link']), '!message' => strip_tags($message)));
     syslog($level, $entry);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:14,代码来源:SysLog.php

示例10: getPlugin

 public function getPlugin($plugin_id = NULL)
 {
     $plugin_id = $plugin_id ?: $this->config->get($this->getType() . '.plugin_id');
     $plugins = $this->getAvailablePlugins();
     // Check if plugin is available.
     if (!isset($plugins[$plugin_id]) || !class_exists($plugins[$plugin_id]['class'])) {
         trigger_error("image_effects " . $this->getType() . " handling plugin '{$plugin_id}' is no longer available.", E_USER_ERROR);
         $plugin_id = NULL;
     }
     return $this->createInstance($plugin_id, array('plugin_type' => $this->getType()));
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:11,代码来源:ImageEffectsPluginManager.php

示例11: canRedirect

 /**
  * Checks access to the route.
  *
  * @param string $route_name
  *   The current route name.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @return bool
  *   TRUE if access is granted.
  */
 public function canRedirect($route_name, Request $request)
 {
     $do_redirect = TRUE;
     /** @var \Symfony\Component\Routing\Route $route */
     $route = $this->routeProvider->getRouteByName($route_name);
     if ($this->config->get('access_check')) {
         $do_redirect &= $this->accessManager->check($route, $request, $this->account);
     }
     if ($this->config->get('ignore_admin_path')) {
         $do_redirect &= !(bool) $route->getOption('_admin_route');
     }
     return $do_redirect;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:24,代码来源:RedirectChecker.php

示例12: onTerminate

 /**
  * Run the automated cron if enabled.
  *
  * @param Symfony\Component\HttpKernel\Event\PostResponseEvent $event
  *   The Event to process.
  */
 public function onTerminate(PostResponseEvent $event)
 {
     // If the site is not fully installed, suppress the automated cron run.
     // Otherwise it could be triggered prematurely by Ajax requests during
     // installation.
     if ($this->state->get('install_task') == 'done') {
         $threshold = $this->config->get('threshold.autorun');
         if ($threshold > 0) {
             $cron_next = $this->state->get('system.cron_last', 0) + $threshold;
             if (REQUEST_TIME > $cron_next) {
                 $this->cron->run();
             }
         }
     }
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:21,代码来源:AutomaticCron.php

示例13: render

 /**
  * {@inheritdoc}
  */
 function render(ResultRow $values)
 {
     // Ensure Disqus comments are available on the entity and user has access to edit this entity.
     $entity = $this->getEntity($values);
     if (!$entity) {
         return;
     }
     $field = $this->disqusManager->getFields($entity->getEntityTypeId());
     if (!$entity->hasField(key($field))) {
         return;
     }
     if ($entity->get(key($field))->status && $this->currentUser->hasPermission('view disqus comments')) {
         // Build a renderable array for the link.
         $links['disqus_comments_num'] = array('title' => t('Comments'), 'url' => $entity->urlInfo(), 'fragment' => 'disqus_thread', 'attributes' => array('data-disqus-identifier' => "{$entity->getEntityTypeId()}/{$entity->id()}"));
         $content = array('#theme' => 'links', '#links' => $links, '#attributes' => array('class' => array('links', 'inline')));
         /**
          * This attaches disqus.js specified in the disqus.libraries.yml file,
          * which will look for the DOM variable disqusComments which is set below.
          * When found, the disqus javascript api replaces the html element with
          * the attribute: "data-disqus-identifier" and replaces the element with
          * the number of comments on the entity.
          */
         $content['#attached']['library'][] = 'disqus/disqus';
         $content['#attached']['drupalSettings']['disqusComments'] = $this->config->get('disqus_domain');
         return $content;
     }
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:30,代码来源:DisqusCommentCount.php

示例14: forbiddenMessage

 /**
  * {@inheritdoc}
  */
 public function forbiddenMessage(EntityInterface $entity, $field_name)
 {
     if (!isset($this->authenticatedCanPostComments)) {
         // We only output a link if we are certain that users will get the
         // permission to post comments by logging in.
         $this->authenticatedCanPostComments = $this->entityManager->getStorage('user_role')->load(RoleInterface::AUTHENTICATED_ID)->hasPermission('post comments');
     }
     if ($this->authenticatedCanPostComments) {
         // We cannot use the redirect.destination service here because these links
         // sometimes appear on /node and taxonomy listing pages.
         if ($entity->get($field_name)->getFieldDefinition()->getSetting('form_location') == CommentItemInterface::FORM_SEPARATE_PAGE) {
             $comment_reply_parameters = ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name];
             $destination = array('destination' => $this->url('comment.reply', $comment_reply_parameters, array('fragment' => 'comment-form')));
         } else {
             $destination = array('destination' => $entity->url('canonical', array('fragment' => 'comment-form')));
         }
         if ($this->userConfig->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
             // Users can register themselves.
             return $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to post comments', array(':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination)), ':register' => $this->urlGenerator->generateFromRoute('user.register', array(), array('query' => $destination))));
         } else {
             // Only admins can add new users, no public registration.
             return $this->t('<a href=":login">Log in</a> to post comments', array(':login' => $this->urlGenerator->generateFromRoute('user.login', array(), array('query' => $destination))));
         }
     }
     return '';
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:29,代码来源:CommentManager.php

示例15: initializeIterator

 /**
  * {@inheritdoc}
  */
 public function initializeIterator()
 {
     if ($disqus = disqus_api()) {
         try {
             $posts = $disqus->forums->listPosts(array('forum' => $this->config->get('disqus_domain')));
         } catch (\Exception $exception) {
             drupal_set_message(t('There was an error loading the forum details. Please check you API keys and try again.', 'error'));
             $this->logger->error('Error loading the Disqus PHP API. Check your forum name.', array());
             return FALSE;
         }
         $items = array();
         foreach ($posts as $post) {
             $id = $post['id'];
             $items[$id]['id'] = $id;
             $items[$id]['pid'] = $post['parent'];
             $thread = $disqus->threads->details(array('thread' => $post['thread']));
             $items[$id]['identifier'] = $thread['identifier'];
             $items[$id]['name'] = $post['author']['name'];
             $items[$id]['email'] = $post['author']['email'];
             $items[$id]['user_id'] = $post['author']['id'];
             $items[$id]['url'] = $post['author']['url'];
             $items[$id]['ipAddress'] = $post['ipAddress'];
             $items[$id]['isAnonymous'] = $post['author']['isAnonymous'];
             $items[$id]['createdAt'] = $post['createdAt'];
             $items[$id]['comment'] = $post['message'];
             $items[$id]['isEdited'] = $post['isEdited'];
         }
     }
     return new \ArrayIterator($items);
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:33,代码来源:DisqusComment.php


注:本文中的Drupal\Core\Config\Config::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。