本文整理汇总了PHP中Drupal\Core\Config\ConfigFactoryInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFactoryInterface类的具体用法?PHP ConfigFactoryInterface怎么用?PHP ConfigFactoryInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConfigFactoryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@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);
}
示例2: __construct
/**
* 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');
}
示例3: __construct
/**
* 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;
}
示例4: __construct
/**
* 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();
}
示例5: __construct
/**
* 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;
}
示例6: __construct
/**
* 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;
}
示例7: __construct
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();
}
示例8: __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;
}
示例9: __construct
/**
* 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;
}
示例10: __construct
/**
* 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;
}
示例11: 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;
}
示例12: loginToDrupal
/**
* 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);
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}