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

PHP Config\StorageInterface类代码示例

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

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



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

示例1: copyConfig

 /**
  * Copies configuration objects from source storage to target storage.
  *
  * @param \Drupal\Core\Config\StorageInterface $source_storage
  *   The source config storage service.
  * @param \Drupal\Core\Config\StorageInterface $target_storage
  *   The target config storage service.
  */
 protected function copyConfig(StorageInterface $source_storage, StorageInterface $target_storage)
 {
     $target_storage->deleteAll();
     foreach ($source_storage->listAll() as $name) {
         $target_storage->write($name, $source_storage->read($name));
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:ConfigTestTrait.php


示例2: filterWrite

 public function filterWrite($name, array $data, StorageInterface $storage)
 {
     if ($name != 'core.extension') {
         return $data;
     }
     $originalData = $storage->read($name);
     return $this->filterOutIgnored($data, $storage->read($name));
 }
开发者ID:bjargud,项目名称:drush,代码行数:8,代码来源:CoreExtensionFilter.php


示例3: filterWrite

 public function filterWrite($name, array $data, StorageInterface $storage)
 {
     if ($name == 'core.extension') {
         return $this->filterOutIgnored($data, $storage->read($name));
     }
     $dependent_configs = $this->getAllDependentConfigs($storage);
     if (in_array($name, $dependent_configs)) {
         $data = ($existing = $storage->read($name)) ? $existing : NULL;
     }
     return $data;
 }
开发者ID:gaelg,项目名称:drush,代码行数:11,代码来源:CoreExtensionFilter.php


示例4: getActiveStorage

 /**
  * Gets the configuration storage that provides the active configuration.
  *
  * @param string $collection
  *   (optional) The configuration collection. Defaults to the default
  *   collection.
  *
  * @return \Drupal\Core\Config\StorageInterface
  *   The configuration storage that provides the default configuration.
  */
 protected function getActiveStorage($collection = StorageInterface::DEFAULT_COLLECTION)
 {
     if ($this->activeStorage->getCollectionName() != $collection) {
         $this->activeStorage = $this->activeStorage->createCollection($collection);
     }
     return $this->activeStorage;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:17,代码来源:ConfigInstaller.php


示例5: getCollectionPrefix

 /**
  * Returns a cache ID prefix to use for the collection.
  *
  * @return string
  *   The cache ID prefix.
  */
 protected function getCollectionPrefix()
 {
     $collection = $this->storage->getCollectionName();
     if ($collection == StorageInterface::DEFAULT_COLLECTION) {
         return '';
     }
     return $collection . ':';
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:CachedStorage.php


示例6: getAllCollectionNames

 /**
  * {@inheritdoc}
  */
 public function getAllCollectionNames($include_default = TRUE)
 {
     $collections = array_unique(array_merge($this->sourceStorage->getAllCollectionNames(), $this->targetStorage->getAllCollectionNames()));
     if ($include_default) {
         array_unshift($collections, StorageInterface::DEFAULT_COLLECTION);
     }
     return $collections;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:11,代码来源:StorageComparer.php


示例7: loadOverrides

 /**
  * {@inheritdoc}
  */
 public function loadOverrides($names)
 {
     $overrides = array();
     // loadOverrides() runs on config entities, which means that if we try
     // to run this routine on our own data, then we end up in an infinite loop.
     // So ensure that we are _not_ looking up a domain.record.*.
     $check = current($names);
     $list = explode('.', $check);
     if (isset($list[0]) && isset($list[1]) && $list[0] == 'domain' && $list[1] == 'record') {
         return $overrides;
     }
     $this->initiateContext();
     if (!empty($this->domain)) {
         foreach ($names as $name) {
             $config_name = $this->getDomainConfigName($name, $this->domain);
             // Check to see if the config storage has an appropriately named file
             // containing override data.
             if ($override = $this->storage->read($config_name['langcode'])) {
                 $overrides[$name] = $override;
             } elseif ($override = $this->storage->read($config_name['domain'])) {
                 $overrides[$name] = $override;
             }
         }
     }
     return $overrides;
 }
开发者ID:dropdog,项目名称:play,代码行数:29,代码来源:DomainConfigOverrider.php


示例8: getConfigNames

 protected function getConfigNames($config_type)
 {
     $this->configStorage = $this->getDrupalService('config.storage');
     // For a given entity type, load all entities.
     if ($config_type && $config_type !== 'system.simple') {
         $entity_storage = $this->entityManager->getStorage($config_type);
         foreach ($entity_storage->loadMultiple() as $entity) {
             $entity_id = $entity->id();
             $label = $entity->label() ?: $entity_id;
             $names[$entity_id] = $label;
         }
     } else {
         // Gather the config entity prefixes.
         $config_prefixes = array_map(function ($definition) {
             return $definition->getConfigPrefix() . '.';
         }, $this->definitions);
         // Find all config, and then filter our anything matching a config prefix.
         $names = $this->configStorage->listAll();
         $names = array_combine($names, $names);
         foreach ($names as $config_name) {
             foreach ($config_prefixes as $config_prefix) {
                 if (strpos($config_name, $config_prefix) === 0) {
                     unset($names[$config_name]);
                 }
             }
         }
     }
     return $names;
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:29,代码来源:ExportSingleCommand.php


示例9: getAllFolders

 /**
  * Returns a map of all config object names and their folders.
  *
  * The list is based on enabled modules and themes. The active configuration
  * storage is used rather than \Drupal\Core\Extension\ModuleHandler and
  *  \Drupal\Core\Extension\ThemeHandler in order to resolve circular
  * dependencies between these services and \Drupal\Core\Config\ConfigInstaller
  * and \Drupal\Core\Config\TypedConfigManager.
  *
  * @return array
  *   An array mapping config object names with directories.
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $this->folders = array();
         $this->folders += $this->getComponentNames('core', array('core'));
         $extensions = $this->configStorage->read('core.extension');
         if (!empty($extensions['module'])) {
             $modules = $extensions['module'];
             if (!$this->includeProfile) {
                 if ($install_profile = Settings::get('install_profile')) {
                     unset($modules[$install_profile]);
                 }
             }
             $this->folders += $this->getComponentNames('module', array_keys($modules));
         }
         if (!empty($extensions['theme'])) {
             $this->folders += $this->getComponentNames('theme', array_keys($extensions['theme']));
         }
         // The install profile can override module default configuration. We do
         // this by replacing the config file path from the module/theme with the
         // install profile version if there are any duplicates.
         $profile_folders = $this->getComponentNames('profile', array(drupal_get_profile()));
         $folders_to_replace = array_intersect_key($profile_folders, $this->folders);
         if (!empty($folders_to_replace)) {
             $this->folders = array_merge($this->folders, $folders_to_replace);
         }
     }
     return $this->folders;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:41,代码来源:ExtensionInstallStorage.php


示例10: testRename

 /**
  * @covers ::rename
  */
 public function testRename()
 {
     $old = new Config($this->randomMachineName(), $this->storage, $this->eventDispatcher, $this->typedConfig);
     $new = new Config($this->randomMachineName(), $this->storage, $this->eventDispatcher, $this->typedConfig);
     $this->storage->expects($this->exactly(2))->method('readMultiple')->willReturnMap([[[$old->getName()], $old->getRawData()], [[$new->getName()], $new->getRawData()]]);
     $this->cacheTagsInvalidator->expects($this->once())->method('invalidateTags')->with($old->getCacheTags());
     $this->storage->expects($this->once())->method('rename')->with($old->getName(), $new->getName());
     $this->configFactory->rename($old->getName(), $new->getName());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:12,代码来源:ConfigFactoryTest.php


示例11: getAllFolders

 /**
  * Returns a map of all config object names and their folders.
  *
  * The list is based on enabled modules and themes. The active configuration
  * storage is used rather than \Drupal\Core\Extension\ModuleHandler and
  *  \Drupal\Core\Extension\ThemeHandler in order to resolve circular
  * dependencies between these services and \Drupal\Core\Config\ConfigInstaller
  * and \Drupal\Core\Config\TypedConfigManager.
  *
  * @return array
  *   An array mapping config object names with directories.
  */
 protected function getAllFolders()
 {
     if (!isset($this->folders)) {
         $this->folders = array();
         $this->folders += $this->getCoreNames();
         $install_profile = Settings::get('install_profile');
         $profile = drupal_get_profile();
         $extensions = $this->configStorage->read('core.extension');
         // @todo Remove this scan as part of https://www.drupal.org/node/2186491
         $listing = new ExtensionDiscovery(\Drupal::root());
         if (!empty($extensions['module'])) {
             $modules = $extensions['module'];
             // Remove the install profile as this is handled later.
             unset($modules[$install_profile]);
             $profile_list = $listing->scan('profile');
             if ($profile && isset($profile_list[$profile])) {
                 // Prime the drupal_get_filename() static cache with the profile info
                 // file location so we can use drupal_get_path() on the active profile
                 // during the module scan.
                 // @todo Remove as part of https://www.drupal.org/node/2186491
                 drupal_get_filename('profile', $profile, $profile_list[$profile]->getPathname());
             }
             $module_list_scan = $listing->scan('module');
             $module_list = array();
             foreach (array_keys($modules) as $module) {
                 if (isset($module_list_scan[$module])) {
                     $module_list[$module] = $module_list_scan[$module];
                 }
             }
             $this->folders += $this->getComponentNames($module_list);
         }
         if (!empty($extensions['theme'])) {
             $theme_list_scan = $listing->scan('theme');
             foreach (array_keys($extensions['theme']) as $theme) {
                 if (isset($theme_list_scan[$theme])) {
                     $theme_list[$theme] = $theme_list_scan[$theme];
                 }
             }
             $this->folders += $this->getComponentNames($theme_list);
         }
         if ($this->includeProfile) {
             // The install profile can override module default configuration. We do
             // this by replacing the config file path from the module/theme with the
             // install profile version if there are any duplicates.
             if (isset($profile)) {
                 if (!isset($profile_list)) {
                     $profile_list = $listing->scan('profile');
                 }
                 if (isset($profile_list[$profile])) {
                     $profile_folders = $this->getComponentNames(array($profile_list[$profile]));
                     $this->folders = $profile_folders + $this->folders;
                 }
             }
         }
     }
     return $this->folders;
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:69,代码来源:ExtensionInstallStorage.php


示例12: getDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDefinitions()
 {
     $definitions = array();
     foreach ($this->schemaStorage->readMultiple($this->schemaStorage->listAll()) as $schema) {
         foreach ($schema as $type => $definition) {
             $definitions[$type] = $definition;
         }
     }
     return $definitions;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:ConfigSchemaDiscovery.php


示例13: findConfiguration

 /**
  * Handles switching the configuration type selector.
  */
 protected function findConfiguration($config_type)
 {
     $names = array('' => $this->t('- Select -'));
     // For a given entity type, load all entities.
     if ($config_type && $config_type !== 'system.simple') {
         $entity_storage = $this->entityManager->getStorage($config_type);
         foreach ($entity_storage->loadMultiple() as $entity) {
             $entity_id = $entity->id();
             if ($label = $entity->label()) {
                 $names[$entity_id] = new TranslatableMarkup('@label (@id)', ['@label' => $label, '@id' => $entity_id]);
             } else {
                 $names[$entity_id] = $entity_id;
             }
         }
     } else {
         // Gather the config entity prefixes.
         $config_prefixes = array_map(function (EntityTypeInterface $definition) {
             return $definition->getConfigPrefix() . '.';
         }, $this->definitions);
         // Find all config, and then filter our anything matching a config prefix.
         $names = $this->configStorage->listAll();
         $names = array_combine($names, $names);
         foreach ($names as $config_name) {
             foreach ($config_prefixes as $config_prefix) {
                 if (strpos($config_name, $config_prefix) === 0) {
                     unset($names[$config_name]);
                 }
             }
         }
     }
     return $names;
 }
开发者ID:318io,项目名称:318-io,代码行数:35,代码来源:ConfigSingleExportForm.php


示例14: getStorage

 /**
  * {@inheritdoc}
  */
 public function getStorage($langcode)
 {
     if (!isset($this->storages[$langcode])) {
         $this->storages[$langcode] = $this->baseStorage->createCollection($this->createConfigCollectionName($langcode));
     }
     return $this->storages[$langcode];
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:LanguageConfigFactoryOverride.php


示例15: getFromExtension

 /**
  * {@inheritdoc}
  */
 public function getFromExtension($type, $name)
 {
     $full_name = $this->getFullName($type, $name);
     $value = $this->extensionConfigStorage->read($full_name);
     if (!$value) {
         $value = $this->extensionOptionalConfigStorage->read($full_name);
     }
     return $value;
 }
开发者ID:curveagency,项目名称:intranet,代码行数:12,代码来源:ConfigReverter.php


示例16: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     if ($path = $form_state->getValue('import_tarball')) {
         $this->configStorage->deleteAll();
         try {
             $archiver = new ArchiveTar($path, 'gz');
             $files = array();
             foreach ($archiver->listContent() as $file) {
                 $files[] = $file['filename'];
             }
             $archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY));
             drupal_set_message($this->t('Your configuration files were successfully uploaded, ready for import.'));
             $form_state->setRedirect('config.sync');
         } catch (\Exception $e) {
             drupal_set_message($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', array('@message' => $e->getMessage())), 'error');
         }
         drupal_unlink($path);
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:22,代码来源:ConfigImportForm.php


示例17: testImportCurrencyLocaleWithExistingCurrency

 /**
  * @covers ::importCurrencyLocale
  */
 public function testImportCurrencyLocaleWithExistingCurrency()
 {
     $locale = $this->randomMachineName();
     $currency_locale = $this->getMock(CurrencyLocaleInterface::class);
     $this->currencyLocaleStorage->expects($this->never())->method('create');
     $this->currencyLocaleStorage->expects($this->once())->method('load')->with($locale)->willReturn($currency_locale);
     $this->configStorage->expects($this->never())->method('read');
     $this->sut->setConfigStorage($this->configStorage);
     $this->assertFalse($this->sut->importCurrencyLocale($locale));
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:ConfigImporterTest.php


示例18: testSubscribers

 /**
  * Test the import subscriber.
  */
 public function testSubscribers()
 {
     // Without this the config exporter breaks.
     \Drupal::service('config.installer')->installDefaultConfig('module', 'config_devel');
     $filename = vfsStream::url('public://' . static::CONFIGNAME . '.yml');
     drupal_mkdir(vfsStream::url('public://exported'));
     $exported_filename = vfsStream::url('public://exported/' . static::CONFIGNAME . '.yml');
     \Drupal::configFactory()->getEditable('config_devel.settings')->set('auto_import', array(array('filename' => $filename, 'hash' => '')))->set('auto_export', array($exported_filename))->save();
     $this->storage = \Drupal::service('config.storage');
     $this->assertFalse($this->storage->exists(static::CONFIGNAME));
     $subscriber = \Drupal::service('config_devel.auto_import_subscriber');
     for ($i = 2; $i; $i--) {
         $data['label'] = $this->randomString();
         file_put_contents($filename, Yaml::encode($data));
         // The import fires an export too.
         $subscriber->autoImportConfig();
         $this->doAssert($data, Yaml::decode(file_get_contents($exported_filename)));
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:22,代码来源:ConfigDevelSubscriberTestBase.php


示例19: addConfigList

 protected function addConfigList($full_name, &$list) {
   if (!in_array($full_name, $list)) {
     array_unshift($list, $full_name);
     $value = $this->extensionStorage->read($full_name);
     if (isset($value['dependencies']['config'])) {
       foreach ($value['dependencies']['config'] as $config_name) {
         $this->addConfigList($config_name, $list);
       }
     }
   }
 }
开发者ID:jeetendrasingh,项目名称:manage_profile,代码行数:11,代码来源:FeaturesManager.php


示例20: predefinedConfiguredLanguages

 /**
  * Compute the list of configuration names that match predefined languages.
  *
  * @return array
  *   The list of configuration names that match predefined languages.
  */
 protected function predefinedConfiguredLanguages()
 {
     $names = $this->configStorage->listAll('language.entity.');
     $predefined_languages = $this->languageManager->getStandardLanguageList();
     foreach ($names as $id => $name) {
         $langcode = str_replace('language.entity.', '', $name);
         if (!isset($predefined_languages[$langcode])) {
             unset($names[$id]);
         }
     }
     return array_values($names);
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:18,代码来源:LocaleDefaultConfigStorage.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Config\TypedConfigManagerInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Config\ConfigImporter类代码示例发布时间: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