• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Config\TypedConfigManagerInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: checkConfigSchema

 /**
  * Checks the TypedConfigManager has a valid schema for the configuration.
  *
  * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
  *   The TypedConfigManager.
  * @param string $config_name
  *   The configuration name.
  * @param array $config_data
  *   The configuration data, assumed to be data for a top-level config object.
  *
  * @return array|bool
  *   FALSE if no schema found. List of errors if any found. TRUE if fully
  *   valid.
  */
 public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data)
 {
     // We'd like to verify that the top-level type is either config_base,
     // config_entity, or a derivative. The only thing we can really test though
     // is that the schema supports having langcode in it. So add 'langcode' to
     // the data if it doesn't already exist.
     if (!isset($config_data['langcode'])) {
         $config_data['langcode'] = 'en';
     }
     $this->configName = $config_name;
     if (!$typed_config->hasConfigSchema($config_name)) {
         return FALSE;
     }
     $definition = $typed_config->getDefinition($config_name);
     $data_definition = $typed_config->buildDataDefinition($definition, $config_data);
     $this->schema = $typed_config->create($data_definition, $config_data);
     $errors = array();
     foreach ($config_data as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:39,代码来源:SchemaCheckTrait.php


示例2: setUp

 /**
  * {@inheritdoc}
  *
  * @covers ::__construct
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityType = $this->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
     $this->entityTypeId = 'test_entity_type';
     $this->entityType->expects($this->any())->method('getKey')->will($this->returnValueMap(array(array('id', 'id'), array('uuid', 'uuid'), array('langcode', 'langcode'))));
     $this->entityType->expects($this->any())->method('id')->will($this->returnValue($this->entityTypeId));
     $this->entityType->expects($this->any())->method('getConfigPrefix')->will($this->returnValue('the_config_prefix'));
     $this->entityType->expects($this->any())->method('getClass')->will($this->returnValue(get_class($this->getMockEntity())));
     $this->entityType->expects($this->any())->method('getListCacheTags')->willReturn(array('test_entity_type_list'));
     $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->uuidService = $this->getMock('Drupal\\Component\\Uuid\\UuidInterface');
     $this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $this->languageManager->expects($this->any())->method('getCurrentLanguage')->willReturn(new Language(array('id' => 'hu')));
     $this->configFactory = $this->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
     $this->entityQuery = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $this->entityStorage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->setConstructorArgs(array($this->entityType, $this->configFactory, $this->uuidService, $this->languageManager))->setMethods(array('getQuery'))->getMock();
     $this->entityStorage->expects($this->any())->method('getQuery')->will($this->returnValue($this->entityQuery));
     $this->entityStorage->setModuleHandler($this->moduleHandler);
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with('test_entity_type')->will($this->returnValue($this->entityType));
     $this->cacheTagsInvalidator = $this->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
     $this->typedConfigManager = $this->getMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
     $this->typedConfigManager->expects($this->any())->method('getDefinition')->will($this->returnValue(array('mapping' => array('id' => '', 'uuid' => '', 'dependencies' => ''))));
     $this->configManager = $this->getMock('Drupal\\Core\\Config\\ConfigManagerInterface');
     $this->cacheContextsManager = $this->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')->disableOriginalConstructor()->getMock();
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('config.typed', $this->typedConfigManager);
     $container->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
     $container->set('config.manager', $this->configManager);
     $container->set('language_manager', $this->languageManager);
     $container->set('cache_contexts_manager', $this->cacheContextsManager);
     \Drupal::setContainer($container);
 }
开发者ID:318io,项目名称:318-io,代码行数:40,代码来源:ConfigEntityStorageTest.php


示例3: checkConfigSchema

 /**
  * Checks the TypedConfigManager has a valid schema for the configuration.
  *
  * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config
  *   The TypedConfigManager.
  * @param string $config_name
  *   The configuration name.
  * @param array $config_data
  *   The configuration data.
  *
  * @return array|bool
  *   FALSE if no schema found. List of errors if any found. TRUE if fully
  *   valid.
  */
 public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $config_name, $config_data)
 {
     $this->configName = $config_name;
     if (!$typed_config->hasConfigSchema($config_name)) {
         return FALSE;
     }
     $definition = $typed_config->getDefinition($config_name);
     $data_definition = $typed_config->buildDataDefinition($definition, $config_data);
     $this->schema = $typed_config->create($data_definition, $config_data);
     $errors = array();
     foreach ($config_data as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (empty($errors)) {
         return TRUE;
     }
     return $errors;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:32,代码来源:SchemaCheckTrait.php


示例4: setUp

 /**
  * {@inheritdoc}
  *
  * @covers ::__construct()
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityType = $this->getMock('Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityTypeId = 'test_entity_type';
     $this->entityType->expects($this->any())->method('getKey')->will($this->returnValueMap(array(array('id', 'id'), array('uuid', 'uuid'))));
     $this->entityType->expects($this->any())->method('id')->will($this->returnValue($this->entityTypeId));
     $this->entityType->expects($this->any())->method('getConfigPrefix')->will($this->returnValue('the_config_prefix'));
     $this->entityType->expects($this->any())->method('getClass')->will($this->returnValue(get_class($this->getMockEntity())));
     $this->moduleHandler = $this->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
     $this->uuidService = $this->getMock('Drupal\\Component\\Uuid\\UuidInterface');
     $this->languageManager = $this->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
     $this->languageManager->expects($this->any())->method('getDefaultLanguage')->will($this->returnValue(new Language(array('langcode' => 'en'))));
     $this->configStorage = $this->getConfigStorageStub(array());
     $this->configFactory = $this->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
     $this->entityQuery = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $this->entityStorage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->setConstructorArgs(array($this->entityType, $this->configFactory, $this->configStorage, $this->uuidService, $this->languageManager))->setMethods(array('getQuery'))->getMock();
     $this->entityStorage->expects($this->any())->method('getQuery')->will($this->returnValue($this->entityQuery));
     $this->entityStorage->setModuleHandler($this->moduleHandler);
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with('test_entity_type')->will($this->returnValue($this->entityType));
     $this->cacheBackend = $this->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
     $this->typedConfigManager = $this->getMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
     $this->typedConfigManager->expects($this->any())->method('getDefinition')->will($this->returnValue(array('mapping' => array('id' => '', 'uuid' => '', 'dependencies' => ''))));
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('config.typed', $this->typedConfigManager);
     $container->set('cache.test', $this->cacheBackend);
     $container->setParameter('cache_bins', array('cache.test' => 'test'));
     \Drupal::setContainer($container);
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:36,代码来源:ConfigEntityStorageTest.php


示例5: installDefaultConfig

 /**
  * {@inheritdoc}
  */
 public function installDefaultConfig($type, $name)
 {
     $extension_path = $this->drupalGetPath($type, $name);
     // Refresh the schema cache if the extension provides configuration schema
     // or is a theme.
     if (is_dir($extension_path . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY) || $type == 'theme') {
         $this->typedConfig->clearCachedDefinitions();
     }
     $default_install_path = $this->getDefaultConfigDirectory($type, $name);
     if (is_dir($default_install_path)) {
         if (!$this->isSyncing()) {
             $storage = new FileStorage($default_install_path, StorageInterface::DEFAULT_COLLECTION);
             $prefix = '';
         } else {
             // The configuration importer sets the source storage on the config
             // installer. The configuration importer handles all of the
             // configuration entity imports. We only need to ensure that simple
             // configuration is created when the extension is installed.
             $storage = $this->getSourceStorage();
             $prefix = $name . '.';
         }
         // Gets profile storages to search for overrides if necessary.
         $profile_storages = $this->getProfileStorages($name);
         // Gather information about all the supported collections.
         $collection_info = $this->configManager->getConfigCollectionInfo();
         foreach ($collection_info->getCollectionNames() as $collection) {
             $config_to_create = $this->getConfigToCreate($storage, $collection, $prefix, $profile_storages);
             // If we're installing a profile ensure configuration that is overriding
             // is excluded.
             if ($name == $this->drupalGetProfile()) {
                 $existing_configuration = $this->getActiveStorages($collection)->listAll();
                 $config_to_create = array_diff_key($config_to_create, array_flip($existing_configuration));
             }
             if (!empty($config_to_create)) {
                 $this->createConfiguration($collection, $config_to_create);
             }
         }
     }
     // During a drupal installation optional configuration is installed at the
     // end of the installation process.
     // @see install_install_profile()
     if (!$this->isSyncing() && !$this->drupalInstallationAttempted()) {
         $optional_install_path = $extension_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
         if (is_dir($optional_install_path)) {
             // Install any optional config the module provides.
             $storage = new FileStorage($optional_install_path, StorageInterface::DEFAULT_COLLECTION);
             $this->installOptionalConfig($storage, '');
         }
         // Install any optional configuration entities whose dependencies can now
         // be met. This searches all the installed modules config/optional
         // directories.
         $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE);
         $this->installOptionalConfig($storage, [$type => $name]);
     }
     // Reset all the static caches and list caches.
     $this->configFactory->reset();
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:60,代码来源:ConfigInstaller.php


示例6: uninstall

 /**
  * {@inheritdoc}
  */
 public function uninstall($type, $name)
 {
     $entities = $this->getConfigEntitiesToChangeOnDependencyRemoval($type, [$name], FALSE);
     // Fix all dependent configuration entities.
     /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
     foreach ($entities['update'] as $entity) {
         $entity->save();
     }
     // Remove all dependent configuration entities.
     foreach ($entities['delete'] as $entity) {
         $entity->setUninstalling(TRUE);
         $entity->delete();
     }
     $config_names = $this->configFactory->listAll($name . '.');
     foreach ($config_names as $config_name) {
         $this->configFactory->getEditable($config_name)->delete();
     }
     // Remove any matching configuration from collections.
     foreach ($this->activeStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->activeStorage->createCollection($collection);
         $collection_storage->deleteAll($name . '.');
     }
     $schema_dir = drupal_get_path($type, $name) . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY;
     if (is_dir($schema_dir)) {
         // Refresh the schema cache if uninstalling an extension that provides
         // configuration schema.
         $this->typedConfigManager->clearCachedDefinitions();
     }
 }
开发者ID:frankcr,项目名称:sftw8,代码行数:32,代码来源:ConfigManager.php


示例7: uninstall

 /**
  * {@inheritdoc}
  */
 public function uninstall($type, $name)
 {
     // Remove all dependent configuration entities.
     $dependent_entities = $this->findConfigEntityDependentsAsEntities($type, array($name));
     // Reverse the array to that entities are removed in the correct order of
     // dependence. For example, this ensures that field instances are removed
     // before fields.
     foreach (array_reverse($dependent_entities) as $entity) {
         $entity->setUninstalling(TRUE);
         $entity->delete();
     }
     $config_names = $this->configFactory->listAll($name . '.');
     foreach ($config_names as $config_name) {
         $this->configFactory->get($config_name)->delete();
     }
     // Remove any matching configuration from collections.
     foreach ($this->activeStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->activeStorage->createCollection($collection);
         $collection_storage->deleteAll($name . '.');
     }
     $schema_dir = drupal_get_path($type, $name) . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY;
     if (is_dir($schema_dir)) {
         // Refresh the schema cache if uninstalling an extension that provides
         // configuration schema.
         $this->typedConfigManager->clearCachedDefinitions();
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:ConfigManager.php


示例8: installDefaultConfig

 /**
  * {@inheritdoc}
  */
 public function installDefaultConfig($type, $name)
 {
     $extension_path = drupal_get_path($type, $name);
     // If the extension provides configuration schema clear the definitions.
     if (is_dir($extension_path . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY)) {
         // Refresh the schema cache if installing default configuration and the
         // extension has a configuration schema directory.
         $this->typedConfig->clearCachedDefinitions();
     }
     // Gather information about all the supported collections.
     $collection_info = $this->configManager->getConfigCollectionInfo();
     $old_state = $this->configFactory->getOverrideState();
     $this->configFactory->setOverrideState(FALSE);
     // Read enabled extensions directly from configuration to avoid circular
     // dependencies with ModuleHandler and ThemeHandler.
     $extension_config = $this->configFactory->get('core.extension');
     $enabled_extensions = array_keys((array) $extension_config->get('module'));
     $enabled_extensions += array_keys((array) $extension_config->get('theme'));
     // Core can provide configuration.
     $enabled_extensions[] = 'core';
     foreach ($collection_info->getCollectionNames(TRUE) as $collection) {
         $config_to_install = $this->listDefaultConfigCollection($collection, $type, $name, $enabled_extensions);
         if (!empty($config_to_install)) {
             $this->createConfiguration($collection, $config_to_install);
         }
     }
     $this->configFactory->setOverrideState($old_state);
     // Reset all the static caches and list caches.
     $this->configFactory->reset();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:33,代码来源:ConfigInstaller.php


示例9: testToArray

 /**
  * @covers ::toArray
  */
 public function testToArray()
 {
     $this->typedConfigManager->expects($this->once())->method('getDefinition')->will($this->returnValue(array('mapping' => array('id' => '', 'dependencies' => ''))));
     $properties = $this->entity->toArray();
     $this->assertInternalType('array', $properties);
     $this->assertEquals(array('id' => $this->entity->id(), 'dependencies' => array()), $properties);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:10,代码来源:ConfigEntityBaseUnitTest.php


示例10: getConfigSchema

 /**
  * Provides configuration schema.
  *
  * @param string $name
  *   A string config key.
  *
  * @return array|null
  */
 public function getConfigSchema($name)
 {
     $old_state = $this->configFactory->getOverrideState();
     $this->configFactory->setOverrideState(FALSE);
     $config_schema = $this->typedConfigManager->get($name);
     $this->configFactory->setOverrideState($old_state);
     return $config_schema;
 }
开发者ID:njcameron,项目名称:ncmd,代码行数:16,代码来源:ConfigInspectorManager.php


示例11: getSchemaWrapper

 /**
  * Gets the schema wrapper for the whole configuration object.
  *
  * The schema wrapper is dependent on the configuration name and the whole
  * data structure, so if the name or the data changes in any way, the wrapper
  * should be reset.
  *
  * @return \Drupal\Core\Config\Schema\Element
  */
 protected function getSchemaWrapper()
 {
     if (!isset($this->schemaWrapper)) {
         $definition = $this->typedConfigManager->getDefinition($this->name);
         $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $this->data);
         $this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data);
     }
     return $this->schemaWrapper;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:18,代码来源:StorableConfigBase.php


示例12: hasSchema

 /**
  * {@inheritdoc}
  */
 public function hasSchema()
 {
     foreach ($this->getConfigNames() as $name) {
         if (!$this->typedConfigManager->hasConfigSchema($name)) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ConfigNamesMapper.php


示例13: validate

 /**
  * Validates the config against the schema.
  *
  * @param array $config
  *   The configuration data.
  *
  * @throws \Exception
  *   If the configuration doesn't validate.
  */
 protected function validate(array $config)
 {
     $this->configName = 'display_variant.plugin.panels_variant';
     $definition = $this->typedConfigManager->getDefinition($this->configName);
     $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $config);
     $this->schema = $this->typedConfigManager->create($data_definition, $config);
     $errors = array();
     foreach ($config as $key => $value) {
         $errors = array_merge($errors, $this->checkValue($key, $value));
     }
     if (!empty($errors)) {
         $error_list = [];
         foreach ($errors as $key => $error) {
             $error_list[] = $key . ': ' . $error;
         }
         throw new \Exception("Config for Panels display doesn't validate: " . implode(', ', $error_list));
     }
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:27,代码来源:PanelsDisplayManager.php


示例14: testToArray

 /**
  * @covers ::toArray()
  */
 public function testToArray()
 {
     $field = new FieldConfig(array('field_name' => $this->fieldStorage->getName(), 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'field_type' => 'test_field'), $this->entityTypeId);
     $expected = array('id' => 'test_entity_type.test_bundle.field_test', 'uuid' => NULL, 'status' => TRUE, 'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED, 'field_name' => 'field_test', 'entity_type' => 'test_entity_type', 'bundle' => 'test_bundle', 'label' => '', 'description' => '', 'required' => FALSE, 'default_value' => array(), 'default_value_callback' => '', 'settings' => array(), 'dependencies' => array(), 'field_type' => 'test_field');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
     $this->entityType->expects($this->once())->method('getKey')->with('id')->will($this->returnValue('id'));
     $this->typedConfigManager->expects($this->once())->method('getDefinition')->will($this->returnValue(array('mapping' => array_fill_keys(array_keys($expected), ''))));
     $export = $field->toArray();
     $this->assertEquals($expected, $export);
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:13,代码来源:FieldConfigEntityUnitTest.php


示例15: uninstall

 /**
  * {@inheritdoc}
  */
 public function uninstall($type, $name)
 {
     // Remove all dependent configuration entities.
     $extension_dependent_entities = $this->findConfigEntityDependentsAsEntities($type, array($name));
     // Give config entities a chance to become independent of the entities we
     // are going to delete.
     foreach ($extension_dependent_entities as $entity) {
         $entity_dependencies = $entity->getDependencies();
         if (empty($entity_dependencies)) {
             // No dependent entities nothing to do.
             continue;
         }
         // Work out if any of the entity's dependencies are going to be affected
         // by the uninstall.
         $affected_dependencies = array('entity' => array(), 'module' => array(), 'theme' => array());
         if (isset($entity_dependencies['entity'])) {
             foreach ($extension_dependent_entities as $extension_dependent_entity) {
                 if (in_array($extension_dependent_entity->getConfigDependencyName(), $entity_dependencies['entity'])) {
                     $affected_dependencies['entity'][] = $extension_dependent_entity;
                 }
             }
         }
         // Check if the extension being uninstalled is a dependency of the entity.
         if (isset($entity_dependencies[$type]) && in_array($name, $entity_dependencies[$type])) {
             $affected_dependencies[$type] = array($name);
         }
         // Inform the entity.
         $entity->onDependencyRemoval($affected_dependencies);
     }
     // Recalculate the dependencies, some config entities may have fixed their
     // dependencies on the to-be-removed entities.
     $extension_dependent_entities = $this->findConfigEntityDependentsAsEntities($type, array($name));
     // Reverse the array to that entities are removed in the correct order of
     // dependence. For example, this ensures that fields are removed before
     // field storages.
     foreach (array_reverse($extension_dependent_entities) as $extension_dependent_entity) {
         $extension_dependent_entity->setUninstalling(TRUE);
         $extension_dependent_entity->delete();
     }
     $config_names = $this->configFactory->listAll($name . '.');
     foreach ($config_names as $config_name) {
         $this->configFactory->get($config_name)->delete();
     }
     // Remove any matching configuration from collections.
     foreach ($this->activeStorage->getAllCollectionNames() as $collection) {
         $collection_storage = $this->activeStorage->createCollection($collection);
         $collection_storage->deleteAll($name . '.');
     }
     $schema_dir = drupal_get_path($type, $name) . '/' . InstallStorage::CONFIG_SCHEMA_DIRECTORY;
     if (is_dir($schema_dir)) {
         // Refresh the schema cache if uninstalling an extension that provides
         // configuration schema.
         $this->typedConfigManager->clearCachedDefinitions();
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:58,代码来源:ConfigManager.php


示例16: getTranslatableDefaultConfig

 /**
  * Gets array of translated strings for Locale translatable configuration.
  *
  * @param string $name
  *   Configuration object name.
  *
  * @return array
  *   Array of Locale translatable elements of the default configuration in
  *   $name.
  */
 public function getTranslatableDefaultConfig($name)
 {
     if ($this->isSupported($name)) {
         // Create typed configuration wrapper based on install storage data.
         $data = $this->defaultConfigStorage->read($name);
         $type_definition = $this->typedConfigManager->getDefinition($name);
         $data_definition = $this->typedConfigManager->buildDataDefinition($type_definition, $data);
         $typed_config = $this->typedConfigManager->create($data_definition, $data);
         if ($typed_config instanceof TraversableTypedDataInterface) {
             return $this->getTranslatableData($typed_config);
         }
     }
     return array();
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:24,代码来源:LocaleConfigManager.php


示例17: get

 /**
  * Gets locale wrapper with typed configuration data.
  *
  * @param string $name
  *   Configuration object name.
  *
  * @return \Drupal\locale\LocaleTypedConfig
  *   Locale-wrapped configuration element.
  */
 public function get($name)
 {
     // Read default and current configuration data.
     $default = $this->installStorage->read($name);
     $updated = $this->configStorage->read($name);
     // We get only the data that didn't change from default.
     $data = $this->compareConfigData($default, $updated);
     $definition = $this->typedConfigManager->getDefinition($name);
     $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $data);
     // Unless the configuration has a explicit language code we assume English.
     $langcode = isset($default['langcode']) ? $default['langcode'] : 'en';
     $wrapper = new LocaleTypedConfig($data_definition, $name, $langcode, $this, $this->typedConfigManager);
     $wrapper->setValue($data);
     return $wrapper;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:24,代码来源:LocaleConfigManager.php


示例18: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_values = $form_state->getValue(array('translation', 'config_names'));
     foreach ($this->mapper->getConfigNames() as $name) {
         $schema = $this->typedConfigManager->get($name);
         // Set configuration values based on form submission and source values.
         $base_config = $this->configFactory()->getEditable($name);
         $config_translation = $this->languageManager->getLanguageConfigOverride($this->language->getId(), $name);
         $element = $this->createFormElement($schema);
         $element->setConfig($base_config, $config_translation, $form_values[$name]);
         // If no overrides, delete language specific configuration file.
         $saved_config = $config_translation->get();
         if (empty($saved_config)) {
             $config_translation->delete();
         } else {
             $config_translation->save();
         }
     }
     $form_state->setRedirect($this->mapper->getOverviewRoute(), $this->mapper->getOverviewRouteParameters());
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:23,代码来源:ConfigTranslationFormBase.php


示例19: buildForm

 /**
  * Implements \Drupal\Core\Form\FormInterface::buildForm().
  *
  * Builds configuration form with metadata and values from the source
  * language.
  *
  * @param array $form
  *   An associative array containing the structure of the form.
  * @param array $form_state
  *   An associative array containing the current state of the form.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   (optional) Page request object.
  * @param string $plugin_id
  *   (optional) The plugin ID of the mapper.
  * @param string $langcode
  *   (optional) The language code of the language the form is adding or
  *   editing.
  *
  * @return array
  *   The form structure.
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  *   Throws an exception if the language code provided as a query parameter in
  *   the request does not match an active language.
  */
 public function buildForm(array $form, array &$form_state, Request $request = NULL, $plugin_id = NULL, $langcode = NULL)
 {
     /** @var \Drupal\config_translation\ConfigMapperInterface $mapper */
     $mapper = $this->configMapperManager->createInstance($plugin_id);
     $mapper->populateFromRequest($request);
     $language = language_load($langcode);
     if (!$language) {
         throw new NotFoundHttpException();
     }
     $this->mapper = $mapper;
     $this->language = $language;
     $this->sourceLanguage = $this->mapper->getLanguageWithFallback();
     // Get base language configuration to display in the form before setting the
     // language to use for the form. This avoids repetitively settings and
     // resetting the language to get original values later.
     $config_factory = $this->configFactory();
     $old_state = $config_factory->getOverrideState();
     $config_factory->setOverrideState(FALSE);
     $this->baseConfigData = $this->mapper->getConfigData();
     $config_factory->setOverrideState($old_state);
     // Set the translation target language on the configuration factory.
     $original_language = $this->languageManager->getConfigOverrideLanguage();
     $this->languageManager->setConfigOverrideLanguage($this->language);
     // Add some information to the form state for easier form altering.
     $form_state['config_translation_mapper'] = $this->mapper;
     $form_state['config_translation_language'] = $this->language;
     $form_state['config_translation_source_language'] = $this->sourceLanguage;
     $form['#attached']['library'][] = 'config_translation/drupal.config_translation.admin';
     $form['config_names'] = array('#type' => 'container', '#tree' => TRUE);
     foreach ($this->mapper->getConfigNames() as $name) {
         $form['config_names'][$name] = array('#type' => 'container');
         $form['config_names'][$name] += $this->buildConfigForm($this->typedConfigManager->get($name), $config_factory->get($name)->get(), $this->baseConfigData[$name]);
     }
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save translation'), '#button_type' => 'primary');
     // Set the configuration language back.
     $this->languageManager->setConfigOverrideLanguage($original_language);
     return $form;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:64,代码来源:ConfigTranslationFormBase.php


示例20: getConfigSchema

 /**
  * Provides configuration schema.
  *
  * @param string $name
  *   A string config key.
  *
  * @return array|null
  */
 public function getConfigSchema($name)
 {
     return $this->typedConfigManager->get($name);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:12,代码来源:ConfigInspectorManager.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\ConfigEntityBase类代码示例发布时间:2022-05-23
下一篇:
PHP Config\StorageInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap