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


PHP Config\TypedConfigManagerInterface类代码示例

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


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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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